diff --git a/src/onthespot/__init__.py b/src/onthespot/__init__.py
index aeae298..111e258 100644
--- a/src/onthespot/__init__.py
+++ b/src/onthespot/__init__.py
@@ -50,6 +50,12 @@ def main():
if isinstance(config.get("file_hertz"), str):
config.set_("file_hertz", int(config.get("file_hertz")))
+ # Migration (>v1.0.4)
+ if config.get('theme') == 'dark':
+ config.set_('theme', f'background-color: #282828; color: white;')
+ elif config.get('theme') == 'light':
+ config.set_('theme', f'background-color: white; color: black;')
+
# Set Application Version
version = "v1.0.4"
logger.info(f'OnTheSpot Version: {version}')
diff --git a/src/onthespot/accounts.py b/src/onthespot/accounts.py
index 6b571c7..2576255 100644
--- a/src/onthespot/accounts.py
+++ b/src/onthespot/accounts.py
@@ -1,3 +1,4 @@
+from time import sleep
from PyQt6.QtCore import QThread, pyqtSignal
from .api.apple_music import apple_music_login_user, apple_music_get_token
from .api.bandcamp import bandcamp_login_user
@@ -40,6 +41,7 @@ def run(self):
else:
if self.gui is True:
self.progress.emit(self.tr('Login failed for \n{0}!').format(account['login']['pltvcid']), True)
+ sleep(0.5)
continue
elif service == 'bandcamp':
@@ -61,6 +63,7 @@ def run(self):
except Exception as e:
if self.gui is True:
self.progress.emit(self.tr('Login failed for \n{0}...!').format(account['login']['arl'][:30]), True)
+ sleep(0.5)
continue
elif service == 'soundcloud':
@@ -75,6 +78,7 @@ def run(self):
else:
if self.gui is True:
self.progress.emit(self.tr('Login failed for \n{0}!').format(account['login']['client_id']), True)
+ sleep(0.5)
continue
elif service == 'spotify':
@@ -92,6 +96,7 @@ def run(self):
except Exception as e:
if self.gui is True:
self.progress.emit(self.tr('Login failed for \n{0}!').format(account['login']['username']), True)
+ sleep(0.5)
continue
elif service == 'tidal':
@@ -106,6 +111,7 @@ def run(self):
else:
if self.gui is True:
self.progress.emit(self.tr('Login failed for \n{0}!').format(account['login']['username']), True)
+ sleep(0.5)
continue
elif service == 'youtube':
diff --git a/src/onthespot/api/deezer.py b/src/onthespot/api/deezer.py
index de2b1f2..49fb858 100644
--- a/src/onthespot/api/deezer.py
+++ b/src/onthespot/api/deezer.py
@@ -223,8 +223,9 @@ def genurlkey(songid, md5origin, mediaver=4, fmt=1):
def deezer_login_user(account):
uuid = account['uuid']
arl = account['login']['arl']
- if uuid == 'public_deezer':
- try:
+
+ try:
+ if uuid == 'public_deezer':
# I have no idea why rentry 403s every scraping trick I've tried
ia_url = f"http://archive.org/wayback/available?url=https://rentry.co/firehawk52"
response = requests.get(ia_url)
@@ -251,11 +252,7 @@ def deezer_login_user(account):
public_arl = re.search(r'(.*?)
', row)
public_arls.append(public_arl.group(1))
arl = random.choice(public_arls)
- except Exception as e:
- logger.error('Failed to fetch firehawk52 shared deezer accounts.')
- return False
- try:
headers = {
'Origin': 'https://www.deezer.com',
'Accept-Encoding': 'utf-8',
diff --git a/src/onthespot/api/soundcloud.py b/src/onthespot/api/soundcloud.py
index a7adca1..5d90115 100644
--- a/src/onthespot/api/soundcloud.py
+++ b/src/onthespot/api/soundcloud.py
@@ -93,7 +93,7 @@ def soundcloud_login_user(account):
logger.error(f"Unknown Exception: {str(e)}")
account_pool.append({
"uuid": "public_soundcloud",
- "username": "N/A",
+ "username": account['login']['client_id'],
"service": "soundcloud",
"status": "error",
"account_type": "N/A",
diff --git a/src/onthespot/gui/mainui.py b/src/onthespot/gui/mainui.py
index e2f1cf4..8d214d5 100644
--- a/src/onthespot/gui/mainui.py
+++ b/src/onthespot/gui/mainui.py
@@ -6,7 +6,7 @@
from PyQt6 import uic, QtGui
from PyQt6.QtCore import QThread, QDir, Qt, pyqtSignal, QObject, QTimer
from PyQt6.QtGui import QIcon
-from PyQt6.QtWidgets import QApplication, QMainWindow, QHeaderView, QLabel, QPushButton, QProgressBar, QTableWidgetItem, QFileDialog, QRadioButton, QHBoxLayout, QWidget
+from PyQt6.QtWidgets import QApplication, QMainWindow, QHeaderView, QLabel, QPushButton, QProgressBar, QTableWidgetItem, QFileDialog, QRadioButton, QHBoxLayout, QWidget, QColorDialog
from ..accounts import get_account_token, FillAccountPool
from ..api.apple_music import apple_music_add_account, apple_music_get_track_metadata
from ..api.bandcamp import bandcamp_add_account, bandcamp_get_track_metadata
@@ -91,6 +91,7 @@ def __init__(self, _dialog, start_url=''):
QApplication.setStyle("fusion")
uic.loadUi(os.path.join(self.path, "qtui", "main.ui"), self)
self.setWindowIcon(self.get_icon('onthespot'))
+ self.centralwidget.setStyleSheet(config.get('theme'))
self.start_url = start_url
self.inp_version.setText(config.get("version"))
@@ -126,23 +127,6 @@ def __init__(self, _dialog, start_url=''):
# Bind button click
self.bind_button_inputs()
- # Set application theme
- self.toggle_theme_button.clicked.connect(self.toggle_theme)
- self.theme = config.get("theme")
- self.theme_path = os.path.join(config.app_root,'resources', 'themes', f'{self.theme}.qss')
- if self.theme == "dark":
- self.toggle_theme_button.setText(self.tr(" Light Theme"))
- theme_icon = 'light'
- elif self.theme == "light":
- self.toggle_theme_button.setText(self.tr(" Dark Theme"))
- theme_icon = 'dark'
- self.toggle_theme_button.setIcon(self.get_icon(theme_icon))
-
- with open(self.theme_path, 'r') as f:
- theme = f.read()
- self.setStyleSheet(theme)
- logger.info(f"Set theme {self.theme}!")
-
# Set the table header properties
self.set_table_props()
logger.info("Main window init completed !")
@@ -155,31 +139,23 @@ def get_icon(self, name):
return self.icon_cache[name]
- def load_dark_theme(self):
- self.theme = "dark"
- self.theme_path = os.path.join(config.app_root,'resources', 'themes', f'{self.theme}.qss')
- self.toggle_theme_button.setIcon(self.get_icon('light'))
- self.toggle_theme_button.setText(self.tr(" Light Theme"))
- with open(self.theme_path, 'r') as f:
- dark_theme = f.read()
- self.setStyleSheet(dark_theme)
-
-
- def load_light_theme(self):
- self.theme = "light"
- self.theme_path = os.path.join(config.app_root,'resources', 'themes', f'{self.theme}.qss')
- self.toggle_theme_button.setIcon(self.get_icon('dark'))
- self.toggle_theme_button.setText(self.tr(" Dark Theme"))
- with open(self.theme_path, 'r') as f:
- light_theme = f.read()
- self.setStyleSheet(light_theme)
+ def open_theme_dialog(self):
+ color = QColorDialog().getColor()
+ if color.isValid():
+ r, g, b = color.red(), color.green(), color.blue()
+ luminance = (0.299 * r + 0.587 * g + 0.114 * b)
- def toggle_theme(self):
- if self.theme == "light":
- self.load_dark_theme()
- elif self.theme == "dark":
- self.load_light_theme()
+ if luminance < 128:
+ # Dark color, set light font
+ stylesheet = f'background-color: {color.name()}; color: white;'
+ else:
+ # Light color, set dark font
+ stylesheet = f'background-color: {color.name()}; color: black;'
+ config.set_('theme', stylesheet)
+ config.update()
+ self.centralwidget.setStyleSheet(stylesheet)
+ self.__splash_dialog.update_theme(stylesheet)
def bind_button_inputs(self):
@@ -191,6 +167,8 @@ def bind_button_inputs(self):
self.btn_save_config.clicked.connect(self.update_config)
self.btn_reset_config.clicked.connect(self.reset_app_config)
+ self.toggle_theme_button.clicked.connect(self.open_theme_dialog)
+
self.btn_progress_retry_all.clicked.connect(self.retry_all_failed_downloads)
self.btn_progress_cancel_all.clicked.connect(self.cancel_all_downloads)
self.btn_download_root_browse.clicked.connect(self.__select_dir)
diff --git a/src/onthespot/gui/minidialog.py b/src/onthespot/gui/minidialog.py
index aaacff8..9b918f1 100644
--- a/src/onthespot/gui/minidialog.py
+++ b/src/onthespot/gui/minidialog.py
@@ -17,22 +17,15 @@ def __init__(self, parent=None):
uic.loadUi(os.path.join(self.path, 'qtui', 'notice.ui'), self)
self.btn_close.clicked.connect(self.hide)
logger.debug('Dialog item is ready..')
-
- # Set theme
- self.theme = config.get("theme")
- self.theme_path = os.path.join(config.app_root, 'resources', 'themes', f'{self.theme}.qss')
- if self.theme == "dark":
- with open(self.theme_path, 'r') as f:
- dark_theme = f.read()
- self.setStyleSheet(dark_theme)
- elif self.theme == "light":
- with open(self.theme_path, 'r') as f:
- light_theme = f.read()
- self.setStyleSheet(light_theme)
+ self.setStyleSheet(config.get('theme'))
self.lb_main.mousePressEvent = self.on_label_click
+ def update_theme(self, stylesheet):
+ self.setStyleSheet(stylesheet)
+
+
def on_label_click(self, event):
if event.button() == Qt.MouseButton.LeftButton:
match = re.search(r"href='(https?://[^']+)'", self.lb_main.text())
@@ -45,6 +38,7 @@ def on_label_click(self, event):
# No url in label
pass
+
def run(self, content, btn_hidden=False):
if btn_hidden:
self.btn_close.hide()
diff --git a/src/onthespot/gui/qtui/main.ui b/src/onthespot/gui/qtui/main.ui
index f1d1e47..9b31c3a 100644
--- a/src/onthespot/gui/qtui/main.ui
+++ b/src/onthespot/gui/qtui/main.ui
@@ -656,7 +656,7 @@
0
- -1543
+ -213
627
3255
@@ -918,7 +918,7 @@
-
- Dark/Light Theme
+ Set Theme
diff --git a/src/onthespot/gui/settings.py b/src/onthespot/gui/settings.py
index 4dec1bd..7f2eba3 100644
--- a/src/onthespot/gui/settings.py
+++ b/src/onthespot/gui/settings.py
@@ -20,6 +20,8 @@ def load_config(self):
self.group_download_items.hide()
# Icons
+ self.toggle_theme_button.setIcon(self.get_icon('light'))
+
self.inp_language.insertItem(0, self.get_icon('en_US'), "English")
self.inp_language.insertItem(1, self.get_icon('de_DE'), "Deutsch")
self.inp_language.insertItem(2, self.get_icon('pt_PT'), "Português")
diff --git a/src/onthespot/otsconfig.py b/src/onthespot/otsconfig.py
index 9ec27f4..7fad80d 100755
--- a/src/onthespot/otsconfig.py
+++ b/src/onthespot/otsconfig.py
@@ -131,7 +131,7 @@ def __init__(self, cfg_path=None):
"download_open_btn": True, # Add open button to downloads
"download_locate_btn": True, # Add locate button to downloads
"download_delete_btn": False, # Add delete button to downloads
- "theme": "dark", # Light\Dark
+ "theme": "background-color: #282828; color: white;", # Custom stylesheet
"accounts": [
{
"uuid": "public_bandcamp",
diff --git a/src/onthespot/resources/icons/dark.png b/src/onthespot/resources/icons/dark.png
deleted file mode 100644
index 6b03390..0000000
Binary files a/src/onthespot/resources/icons/dark.png and /dev/null differ
diff --git a/src/onthespot/resources/themes/__init__.py b/src/onthespot/resources/themes/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/src/onthespot/resources/themes/dark.qss b/src/onthespot/resources/themes/dark.qss
deleted file mode 100644
index e97c1f1..0000000
--- a/src/onthespot/resources/themes/dark.qss
+++ /dev/null
@@ -1,48 +0,0 @@
-QWidget {
- background-color: #282828;
- color: #fff;
-}
-QWidget:item:selected
-{
- background-color: #2596BE;
- color: #fff;
-}
-QToolTip {
- background-color: #282828;
- color: #fff;
- padding: 4px;
- border: 1px solid #000;
-}
-QCheckBox::indicator:unchecked {
- background-color: #424242;
-}
-QProgressBar {
- text-align: center;
-}
-QProgressBar::chunk {
- background: #2596BE;
- color: #fff;
-}
-QScrollBar {
- border: 1px solid #424242;
- background: #424242;
- margin: 0px 0px 0px 0px;
-}
-QScrollBar:vertical {
- width:10px;
-}
-QScrollBar:horizontal {
- height:10px;
-}
-QScrollBar::handle {
- background: #616161;
- border-radius: 4px;
-}
-QScrollBar::add-line {
- background: #616161;
- height: 0px;
-}
-QScrollBar::sub-line {
- background: #616161;
- height: 0 px;
-}
diff --git a/src/onthespot/resources/themes/light.qss b/src/onthespot/resources/themes/light.qss
deleted file mode 100644
index 59da6bb..0000000
--- a/src/onthespot/resources/themes/light.qss
+++ /dev/null
@@ -1,49 +0,0 @@
-QWidget {
- background-color: #fff;
- color: #000;
-}
-QWidget:item:selected
-{
- background-color: #81D4FA;
- color: #000;
-}
-QToolTip {
- background-color: #fff;
- color: #000;
- padding: 4px;
- border: 1px solid #000;
-}
-QCheckBox::indicator:unchecked {
- background-color: #fff;
- border: 1px solid #BDBDBD;
-}
-QProgressBar {
- text-align: center;
-}
-QProgressBar::chunk {
- background: #81D4FA;
- color: #fff;
-}
-QScrollBar {
- border: 1px solid #EEEEEE;
- background: #EEEEEE;
- margin: 0px 0px 0px 0px;
-}
-QScrollBar:vertical {
- width:10px;
-}
-QScrollBar:horizontal {
- height:10px;
-}
-QScrollBar::handle {
- background: #BDBDBD;
- border-radius: 4px;
-}
-QScrollBar::add-line {
- background: #BDBDBD;
- height: 0px;
-}
-QScrollBar::sub-line {
- background: #BDBDBD;
- height: 0 px;
-}