Skip to content

Commit

Permalink
Add qobuz
Browse files Browse the repository at this point in the history
  • Loading branch information
justin025 committed Dec 21, 2024
1 parent df334d4 commit bb1f35c
Show file tree
Hide file tree
Showing 13 changed files with 407 additions and 104 deletions.
94 changes: 10 additions & 84 deletions src/onthespot/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .api.apple_music import apple_music_login_user, apple_music_get_token
from .api.bandcamp import bandcamp_login_user
from .api.deezer import deezer_login_user, deezer_get_token
from .api.qobuz import qobuz_login_user, qobuz_get_token
from .api.soundcloud import soundcloud_login_user, soundcloud_get_token
from .api.spotify import spotify_login_user, spotify_get_token
from .api.tidal import tidal_login_user, tidal_get_token
Expand All @@ -29,93 +30,18 @@ def run(self):
if not account['active']:
continue

if service == 'apple_music':
if self.gui is True:
self.progress.emit(self.tr('Attempting to create session for\n{0}...').format(account['login']['pltvcid']), True)

valid_login = apple_music_login_user(account)
if valid_login:
if self.gui is True:
self.progress.emit(self.tr('Session created for\n{0}!').format(account['login']['pltvcid']), True)
continue
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':
bandcamp_login_user(account)
continue
if self.gui is True:
self.progress.emit(self.tr('Attempting to create session for\n{0}...').format(account['uuid']), True)

elif service == 'deezer':
valid_login = globals()[f"{service}_login_user"](account)
if valid_login:
if self.gui is True:
self.progress.emit(self.tr('Attempting to create session for\n{0}...').format(account['login']['arl'][:30]), True)
try:
if deezer_login_user(account) is True:
if self.gui is True:
self.progress.emit(self.tr('Session created for\n{0}...!').format(account['login']['arl'][:30]), True)
continue
else:
if self.gui is True:
self.progress.emit(self.tr('Login failed for \n{0}...!').format(account['login']['arl'][:30]), True)
continue
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':
if self.gui is True:
self.progress.emit(self.tr('Attempting to create session for\n{0}...').format(account['login']['client_id']), True)

valid_login = soundcloud_login_user(account)
if valid_login and account['uuid'] == 'public_soundcloud':
if self.gui is True:
self.progress.emit(self.tr('Session created for\n{0}!').format(account['login']['client_id']), True)
continue
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':
if self.gui is True:
self.progress.emit(self.tr('Attempting to create session for\n{0}...').format(account['login']['username']), True)
try:
if spotify_login_user(account) is True:
if self.gui is True:
self.progress.emit(self.tr('Session created for\n{0}!').format(account['login']['username']), True)
continue
else:
if self.gui is True:
self.progress.emit(self.tr('Login failed for \n{0}!').format(account['login']['username']), True)
continue
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':
self.progress.emit(self.tr('Session created for\n{0}!').format(account['uuid']), True)
continue
else:
if self.gui is True:
self.progress.emit(self.tr('Attempting to create session for\n{0}...').format(account['login']['username']), True)

valid_login = tidal_login_user(account)
if valid_login:
if self.gui is True:
self.progress.emit(self.tr('Session created for\n{0}!').format(account['login']['username']), True)
continue
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':
youtube_login_user(account)
self.progress.emit(self.tr('Login failed for \n{0}!').format(account['uuid']), True)
sleep(0.5)
continue

self.finished.emit()
Expand Down
2 changes: 1 addition & 1 deletion src/onthespot/api/apple_music.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def apple_music_get_search_results(session, search_term, content_types):
params['limit'] = config.get("max_search_results")
params['types'] = ",".join(search_types)

results = make_call(f"{BASE_URL}/catalog/{session.cookies.get("itua")}/search", params=params, session=session, skip_cache=True)
results = make_call(f'{BASE_URL}/catalog/{session.cookies.get("itua")}/search', params=params, session=session, skip_cache=True)

search_results = []
for result in results['results']:
Expand Down
Loading

0 comments on commit bb1f35c

Please sign in to comment.