Skip to content

Commit

Permalink
Fix account table problems
Browse files Browse the repository at this point in the history
  • Loading branch information
justin025 committed Dec 11, 2024
1 parent a3ae669 commit e8468a0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 28 deletions.
23 changes: 6 additions & 17 deletions src/onthespot/api/soundcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,12 @@ def soundcloud_login_user(account):
assert client_id_match is not None
client_id = client_id_match.group(1)

accounts = config.get('accounts')
# Remove public from list
accounts = [account for account in accounts if account["uuid"] != "public_soundcloud"]

new_user = {
"uuid": "public_soundcloud",
"service": "soundcloud",
"active": True,
"login": {
"client_id": client_id,
"app_version": app_version,
"app_locale": "en",
}
}
accounts.insert(0, new_user)

config.set_('accounts', accounts)
cfg_copy = config.get('accounts').copy()
for account in cfg_copy:
if account["uuid"] == "public_soundcloud":
account['login']['client_id'] = client_id
account['login']['app_version'] = app_version
config.set_('accounts', cfg_copy)
config.update()

account_pool.append({
Expand Down
16 changes: 10 additions & 6 deletions src/onthespot/gui/mainui.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,11 +575,14 @@ def user_table_remove_click(self):
config.update()

self.tbl_sessions.removeRow(index)
if config.get('parsing_acc_sn') == index and len(account_pool) != 0:
if config.get('parsing_acc_sn') == index or config.get('parsing_acc_sn') >= len(account_pool):
config.set_('parsing_acc_sn', 0)
config.update()
self.tbl_sessions.cellWidget(0, 0).setChecked(True)

try:
self.tbl_sessions.cellWidget(0, 0).setChecked(True)
except AttributeError:
# Account Table is empty
pass
self.__show_popup_dialog(self.tr("Account was removed successfully."))


Expand All @@ -596,7 +599,7 @@ def set_login_fields(self):
self.inp_login_password.hide()
self.btn_login_add.clicked.disconnect()
self.btn_login_add.show()
self.btn_login_add.setText(self.tr("Add Public Account"))
self.btn_login_add.setText(self.tr("Add Bandcamp Account"))
self.btn_login_add.clicked.connect(lambda:
(self.__show_popup_dialog(self.tr("Public account added, please restart the app.\nLogging into personal accounts is currently unsupported, if you have any premium purchases please consider lending it to the dev team.")) or True) and
bandcamp_add_account()
Expand All @@ -607,6 +610,7 @@ def set_login_fields(self):
self.lb_login_username.hide()
self.inp_login_username.hide()
self.lb_login_password.show()
self.inp_login_password.setPlaceholderText("Enter your deezer arl")
self.lb_login_password.setText(self.tr("ARL"))
self.inp_login_password.show()
self.btn_login_add.clicked.disconnect()
Expand All @@ -632,7 +636,7 @@ def set_login_fields(self):
#self.inp_login_password.show()
self.btn_login_add.clicked.disconnect()
self.btn_login_add.show()
self.btn_login_add.setText(self.tr("Add Public Account"))
self.btn_login_add.setText(self.tr("Add Soundcloud Account"))
self.btn_login_add.clicked.connect(lambda:
(self.__show_popup_dialog(self.tr("Public account added, please restart the app.\nLogging into personal accounts is currently unsupported, if you have a GO+ account please consider lending it to the dev team.")) or True) and
soundcloud_add_account()
Expand Down Expand Up @@ -661,7 +665,7 @@ def set_login_fields(self):
self.inp_login_password.hide()
self.btn_login_add.clicked.disconnect()
self.btn_login_add.show()
self.btn_login_add.setText(self.tr("Add Public Account"))
self.btn_login_add.setText(self.tr("Add Youtube Account"))
self.btn_login_add.clicked.connect(lambda:
(self.__show_popup_dialog(self.tr("Public account added, please restart the app.")) or True) and
youtube_add_account()
Expand Down
10 changes: 5 additions & 5 deletions src/onthespot/otsconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ def __init__(self, cfg_path=None):
"download_delete_btn": False, # Add delete button to downloads
"theme": "dark", # Light\Dark
"accounts": [
{
"uuid": "public_bandcamp",
"service": "bandcamp",
"active": True,
},
{
"uuid": "public_soundcloud",
"service": "soundcloud",
Expand All @@ -147,11 +152,6 @@ def __init__(self, cfg_path=None):
"service": "youtube",
"active": True,
},
{
"uuid": "public_bandcamp",
"service": "bandcamp",
"active": True,
}
] # Saved account information
}
if os.path.isfile(self.__cfg_path):
Expand Down

0 comments on commit e8468a0

Please sign in to comment.