Skip to content

Commit

Permalink
Remove unused settings, fix rotate accounts function, fix remove acco…
Browse files Browse the repository at this point in the history
…unt bug
  • Loading branch information
justin025 committed Oct 21, 2024
1 parent 8a01d17 commit 90dbe5f
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 150 deletions.
21 changes: 9 additions & 12 deletions src/onthespot/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
return globals()[f"{service}_get_token"](parsing_index)
1 change: 0 additions & 1 deletion src/onthespot/api/spotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/onthespot/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions src/onthespot/gui/mainui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -539,6 +539,11 @@ def session_load_done(self):
self.__splash_dialog.run(self.tr("<p>An update is available at the link below,<p><a style='color: #6495ed;' href='https://github.com/justin025/onthespot/releases/latest'>https://github.com/justin025/onthespot/releases/latest</a>"))

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)
Expand Down
161 changes: 31 additions & 130 deletions src/onthespot/gui/qtui/main.ui
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>683</width>
<height>584</height>
<width>687</width>
<height>527</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -569,9 +569,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-401</y>
<width>630</width>
<height>3263</height>
<y>-1370</y>
<width>631</width>
<height>3181</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_16">
Expand Down Expand Up @@ -1822,23 +1822,23 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_129">
<widget class="QGroupBox" name="groupBox_8">
<property name="title">
<string/>
</property>
<property name="flat">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_236">
<layout class="QHBoxLayout" name="horizontalLayout_19">
<item>
<widget class="QLabel" name="lb_max_recdl_delay_3">
<widget class="QLabel" name="lb_chunk_size">
<property name="text">
<string>Max Download Workers</string>
<string> Download Chunk Size</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_47">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand All @@ -1851,15 +1851,18 @@
</spacer>
</item>
<item>
<widget class="QSpinBox" name="inp_max_threads">
<widget class="QSpinBox" name="inp_chunk_size">
<property name="minimumSize">
<size>
<width>80</width>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="minimum">
<number>10000</number>
</property>
<property name="maximum">
<number>999999</number>
<number>10000000</number>
</property>
</widget>
</item>
Expand All @@ -1878,54 +1881,6 @@
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_231">
<item>
<widget class="QGroupBox" name="groupBox_130">
<property name="title">
<string/>
</property>
<property name="flat">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_238">
<item>
<widget class="QLabel" name="lb_chunk_size_4">
<property name="text">
<string>Max Retries</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_48">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="inp_max_retries">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>99</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_131">
<property name="title">
Expand Down Expand Up @@ -1974,66 +1929,6 @@
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb1_22">
<property name="title">
<string/>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_237">
<item>
<widget class="QGroupBox" name="groupBox_8">
<property name="title">
<string/>
</property>
<property name="flat">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_19">
<item>
<widget class="QLabel" name="lb_chunk_size">
<property name="text">
<string> Download Chunk Size</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="inp_chunk_size">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="minimum">
<number>10000</number>
</property>
<property name="maximum">
<number>10000000</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_22">
<property name="title">
Expand Down Expand Up @@ -2083,29 +1978,32 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb1_5">
<widget class="QGroupBox" name="gb1_22">
<property name="title">
<string/>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_41">
<layout class="QHBoxLayout" name="horizontalLayout_237">
<item>
<widget class="QGroupBox" name="groupBox_23">
<widget class="QGroupBox" name="groupBox_130">
<property name="title">
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_23">
<property name="flat">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_238">
<item>
<widget class="QLabel" name="lb_dl_endskip">
<widget class="QLabel" name="lb_chunk_size_4">
<property name="text">
<string> Skip Bytes at End</string>
<string>Max Retries</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_15">
<spacer name="horizontalSpacer_48">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand All @@ -2118,15 +2016,18 @@
</spacer>
</item>
<item>
<widget class="QSpinBox" name="inp_dl_endskip">
<widget class="QSpinBox" name="inp_max_retries">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999999999</number>
<number>99</number>
</property>
</widget>
</item>
Expand Down
4 changes: 0 additions & 4 deletions src/onthespot/gui/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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"))

Expand Down Expand Up @@ -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())
Expand All @@ -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())
Expand Down

0 comments on commit 90dbe5f

Please sign in to comment.