From 90dbe5ff59699175aaba8d5035ca898c292e31f6 Mon Sep 17 00:00:00 2001 From: Justin Donofrio Date: Mon, 21 Oct 2024 15:01:22 -0400 Subject: [PATCH] Remove unused settings, fix rotate accounts function, fix remove account bug --- src/onthespot/accounts.py | 21 ++--- src/onthespot/api/spotify.py | 1 - src/onthespot/downloader.py | 2 +- src/onthespot/gui/mainui.py | 9 +- src/onthespot/gui/qtui/main.ui | 161 +++++++-------------------------- src/onthespot/gui/settings.py | 4 - 6 files changed, 48 insertions(+), 150 deletions(-) diff --git a/src/onthespot/accounts.py b/src/onthespot/accounts.py index 40f3ca4..baffec7 100644 --- a/src/onthespot/accounts.py +++ b/src/onthespot/accounts.py @@ -59,18 +59,15 @@ def run(self): def get_account_token(download=False): - parsing_index = config.get('parsing_acc_sn') - 1 + parsing_index = config.get('parsing_acc_sn') service = account_pool[parsing_index]['service'] - + if config.get("rotate_acc_sn") is True and download is True: - #for account in account_pool: - # if account["service"] == service: - # print(account["uuid"]) # Print the UUID - #if download == True and parsing_index < (len(config.get('accounts'))-1): - # config.set_('parsing_acc_sn', parsing_index + 1) - #else: - # config.set_('parsing_acc_sn', 0) - selected_uuid = config.get('accounts')[parsing_index][0] + for i in range(parsing_index + 1, parsing_index + len(account_pool) + 1): + index = i % len(account_pool) + if account_pool[index]['service'] == service: + config.set_('parsing_acc_sn', index) + config.update + return globals()[f"{service}_get_token"](index) else: - token = globals()[f"{service}_get_token"](parsing_index) - return token \ No newline at end of file + return globals()[f"{service}_get_token"](parsing_index) diff --git a/src/onthespot/api/spotify.py b/src/onthespot/api/spotify.py index 5a6b6ae..eabb432 100644 --- a/src/onthespot/api/spotify.py +++ b/src/onthespot/api/spotify.py @@ -457,7 +457,6 @@ def check_premium(session): def spotify_get_track_metadata(session, item_id): - print(session) token = session.tokens().get("user-read-email") headers = {"Authorization": f"Bearer {token}"} track_data = make_call(f'https://api.spotify.com/v1/tracks?ids={item_id}&market=from_token', headers=headers) diff --git a/src/onthespot/downloader.py b/src/onthespot/downloader.py index ff1c31a..ddca37b 100644 --- a/src/onthespot/downloader.py +++ b/src/onthespot/downloader.py @@ -50,7 +50,7 @@ def run(self): if self.gui: self.progress.emit(item, self.tr("Downloading"), 0) - token = get_account_token() + token = get_account_token(download=True) try: item_metadata = globals()[f"{item_service}_get_{item_type}_metadata"](token, item_id) diff --git a/src/onthespot/gui/mainui.py b/src/onthespot/gui/mainui.py index 6fad8f9..238f8fa 100644 --- a/src/onthespot/gui/mainui.py +++ b/src/onthespot/gui/mainui.py @@ -53,8 +53,8 @@ def fill_account_table(self): rows = self.tbl_sessions.rowCount() radiobutton = QRadioButton() - radiobutton.clicked.connect(lambda: config.set_('parsing_acc_sn', self.tbl_sessions.currentRow() + 1) and config.update()) - if sn == config.get("parsing_acc_sn"): + radiobutton.clicked.connect(lambda: config.set_('parsing_acc_sn', self.tbl_sessions.currentRow()) and config.update()) + if sn == config.get("parsing_acc_sn") + 1: radiobutton.setChecked(True) btn = QPushButton(self.tbl_sessions) @@ -539,6 +539,11 @@ def session_load_done(self): self.__splash_dialog.run(self.tr("

An update is available at the link below,

https://github.com/justin025/onthespot/releases/latest")) def user_table_remove_click(self, index): + if config.get('parsing_acc_sn') == self.tbl_sessions.currentRow(): + config.set_('parsing_acc_sn', self.tbl_sessions.currentRow() - 1) + self.tbl_sessions.cellWidget(self.tbl_sessions.currentRow() - 1, 0).setChecked(True) + if config.get('parsing_acc_sn') == "0": + self.tbl_sessions.cellWidget(0, 0).setChecked(True) accounts = config.get('accounts').copy() del accounts[index] config.set_('accounts', accounts) diff --git a/src/onthespot/gui/qtui/main.ui b/src/onthespot/gui/qtui/main.ui index bd8b586..3cdae1a 100644 --- a/src/onthespot/gui/qtui/main.ui +++ b/src/onthespot/gui/qtui/main.ui @@ -9,8 +9,8 @@ 0 0 - 683 - 584 + 687 + 527 @@ -569,9 +569,9 @@ 0 - -401 - 630 - 3263 + -1370 + 631 + 3181 @@ -1822,23 +1822,23 @@ - + false - + - + - Max Download Workers + Download Chunk Size - + Qt::Horizontal @@ -1851,15 +1851,18 @@ - + - 80 + 0 0 + + 10000 + - 999999 + 10000000 @@ -1878,54 +1881,6 @@ true - - - - - - - false - - - - - - Max Retries - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - 1 - - - 99 - - - - - - @@ -1974,66 +1929,6 @@ - - - - - - - - - - true - - - - - - - - - false - - - - - - Download Chunk Size - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - 10000 - - - 10000000 - - - - - - @@ -2083,29 +1978,32 @@ - + true - + - + - + + false + + - + - Skip Bytes at End + Max Retries - + Qt::Horizontal @@ -2118,15 +2016,18 @@ - + 0 0 + + 1 + - 999999999 + 99 diff --git a/src/onthespot/gui/settings.py b/src/onthespot/gui/settings.py index d24b1b1..6fd450b 100644 --- a/src/onthespot/gui/settings.py +++ b/src/onthespot/gui/settings.py @@ -38,7 +38,6 @@ def load_config(self): # Text self.inp_language.setCurrentIndex(config.get("language_index")) - self.inp_max_threads.setValue(config.get("max_threads")) self.inp_explicit_label.setText(config.get("explicit_label")) self.inp_download_root.setText(config.get("download_root")) self.inp_download_delay.setValue(config.get("download_delay")) @@ -54,7 +53,6 @@ def load_config(self): self.inp_m3u_name_formatter.setText(config.get("m3u_name_formatter")) self.inp_album_cover_format.setText(config.get("album_cover_format")) self.inp_max_recdl_delay.setValue(config.get("recoverable_fail_wait_delay")) - self.inp_dl_endskip.setValue(config.get("dl_end_padding_bytes")) self.inp_search_thumb_height.setValue(config.get("search_thumb_height")) self.inp_metadata_seperator.setText(config.get("metadata_seperator")) @@ -115,7 +113,6 @@ def load_config(self): def save_config(self): # Missing Theme config.set_('language_index', self.inp_language.currentIndex()) - config.set_('max_threads', self.inp_max_threads.value()) config.set_('explicit_label', self.inp_explicit_label.text()) config.set_('download_root', self.inp_download_root.text()) config.set_('track_path_formatter', self.inp_track_formatter.text()) @@ -126,7 +123,6 @@ def save_config(self): config.set_('download_delay', self.inp_download_delay.value()) config.set_('chunk_size', self.inp_chunk_size.value()) config.set_('recoverable_fail_wait_delay', self.inp_max_recdl_delay.value()) - config.set_('dl_end_padding_bytes', self.inp_dl_endskip.value()) config.set_('search_thumb_height', self.inp_search_thumb_height.value()) config.set_('max_retries', self.inp_max_retries.value()) config.set_('disable_bulk_dl_notices', self.inp_disable_bulk_popup.isChecked())