mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 01:36:27 +00:00
Add manga bundle announcements (#1083)
* add announcements * fix url * don't check version if frozen * comment * update * use bindle and python 3.11 * privacy update
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
# PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
from datetime import datetime, timezone
|
||||
import itertools
|
||||
from pathlib import Path
|
||||
from PySide6.QtCore import (QSize, QUrl, Qt, Signal, QIODeviceBase, QEvent, QThread, QSettings)
|
||||
@@ -124,7 +125,7 @@ class Icons:
|
||||
self.EPUBFormat = QIcon()
|
||||
self.EPUBFormat.addPixmap(QPixmap(":/Formats/icons/EPUB.png"), QIcon.Mode.Normal, QIcon.State.Off)
|
||||
self.KFXFormat = QIcon()
|
||||
self.KFXFormat.addPixmap(QPixmap(":/Formats/icons/KFX.png"), QIcon.Normal, QIcon.Off)
|
||||
self.KFXFormat.addPixmap(QPixmap(":/Formats/icons/KFX.png"), QIcon.Mode.Normal, QIcon.State.Off)
|
||||
|
||||
self.info = QIcon()
|
||||
self.info.addPixmap(QPixmap(":/Status/icons/info.png"), QIcon.Mode.Normal, QIcon.State.Off)
|
||||
@@ -136,6 +137,15 @@ class Icons:
|
||||
self.programIcon = QIcon()
|
||||
self.programIcon.addPixmap(QPixmap(":/Icon/icons/comic2ebook.png"), QIcon.Mode.Normal, QIcon.State.Off)
|
||||
|
||||
self.kofi = QIcon()
|
||||
self.kofi.addPixmap(QPixmap(":/Brand/icons/kofi_symbol.png"), QIcon.Mode.Normal, QIcon.State.Off)
|
||||
|
||||
self.humble = QIcon()
|
||||
self.humble.addPixmap(QPixmap(":/Brand/icons/Humble_H-Red.png"), QIcon.Mode.Normal, QIcon.State.Off)
|
||||
|
||||
self.bindle = QIcon()
|
||||
self.bindle.addPixmap(QPixmap(":/Brand/icons/Bindle_Red.png"), QIcon.Mode.Normal, QIcon.State.Off)
|
||||
|
||||
|
||||
class VersionThread(QThread):
|
||||
def __init__(self):
|
||||
@@ -150,19 +160,50 @@ class VersionThread(QThread):
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
json_parser = requests.get("https://api.github.com/repos/ciromattia/kcc/releases/latest").json()
|
||||
# unauthenticated API requests limit is 60 req/hour
|
||||
if getattr(sys, 'frozen', False):
|
||||
json_parser = requests.get("https://api.github.com/repos/ciromattia/kcc/releases/latest").json()
|
||||
|
||||
html_url = json_parser["html_url"]
|
||||
latest_version = json_parser["tag_name"]
|
||||
latest_version = re.sub(r'^v', "", latest_version)
|
||||
html_url = json_parser["html_url"]
|
||||
latest_version = json_parser["tag_name"]
|
||||
latest_version = re.sub(r'^v', "", latest_version)
|
||||
|
||||
if ("b" not in __version__ and Version(latest_version) > Version(__version__)) \
|
||||
or ("b" in __version__
|
||||
and Version(latest_version) >= Version(re.sub(r'b.*', '', __version__))):
|
||||
MW.addMessage.emit('<a href="' + html_url + '"><b>The new version is available!</b></a>', 'warning',
|
||||
False)
|
||||
if ("b" not in __version__ and Version(latest_version) > Version(__version__)) \
|
||||
or ("b" in __version__
|
||||
and Version(latest_version) >= Version(re.sub(r'b.*', '', __version__))):
|
||||
MW.addMessage.emit('<a href="' + html_url + '"><b>The new version is available!</b></a>', 'warning',
|
||||
False)
|
||||
except Exception:
|
||||
return
|
||||
pass
|
||||
|
||||
try:
|
||||
announcements = requests.get('https://api.github.com/repos/axu2/kcc-messages/contents/links.json',
|
||||
headers={
|
||||
'Accept': 'application/vnd.github.raw+json',
|
||||
'X-GitHub-Api-Version': '2022-11-28'}).json()
|
||||
for category, payloads in announcements.items():
|
||||
for payload in payloads:
|
||||
expiration = datetime.fromisoformat(payload['expiration'])
|
||||
if expiration < datetime.now(timezone.utc):
|
||||
continue
|
||||
delta = expiration - datetime.now(timezone.utc)
|
||||
time_left = f"{delta.days} day(s) left"
|
||||
icon = 'info'
|
||||
if category == 'humbleBundles':
|
||||
icon = 'bindle'
|
||||
if category == 'kofi':
|
||||
icon = 'kofi'
|
||||
message = f"<b>{payload.get('name')}</b>"
|
||||
if payload.get('link'):
|
||||
message = '<a href="{}"><b>{}</b></a>'.format(payload.get('link'), payload.get('name'))
|
||||
if payload.get('showDeadline'):
|
||||
message += f': {time_left}'
|
||||
if category == 'humbleBundles':
|
||||
message += ' [referral]'
|
||||
MW.addMessage.emit(message, icon , False)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
def setAnswer(self, dialoganswer):
|
||||
self.answer = dialoganswer
|
||||
@@ -1185,7 +1226,6 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
||||
statusBarLabel.setOpenExternalLinks(True)
|
||||
GUI.statusBar.addPermanentWidget(statusBarLabel, 1)
|
||||
|
||||
self.addMessage('<b>Welcome!</b>', 'info')
|
||||
self.addMessage('<b>Tip:</b> Hover mouse over options to see additional information in tooltips.', 'info')
|
||||
self.addMessage('<b>Tip:</b> You can drag and drop image folders or comic files/archives into this window to convert.', 'info')
|
||||
if self.startNumber < 5:
|
||||
|
||||
Reference in New Issue
Block a user