Skip to content

Commit

Permalink
Add tidal support
Browse files Browse the repository at this point in the history
  • Loading branch information
justin025 committed Dec 12, 2024
1 parent f116d85 commit 054c724
Show file tree
Hide file tree
Showing 13 changed files with 616 additions and 68 deletions.
4 changes: 2 additions & 2 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ Customize **OnTheSpot** to fit your preferences by adjusting the settings in the
| **Windows 10 Explorer Thumbnails** | Embed thumbnails in a format that respects Windows 10 explorer and media player, this is an older format of ID3 and not widely supported. |
| **Close To Tray** | Close application to tray on exit. |
| **Check for Updates** | Automatically check for application updates. |
| **File Bitrate** | Set the bitrate of a converted file, default value is 320k. This setting is ignored if a lossless file format is selected. |
| **File Hertz** | Set the hertz of a converted file, default value is 44100 |
| **Track/Episode Format** | Select the audio format for your downloaded music or podcasts (e.g. `mp3`, `flac`, `ogg`, `m4a`). |
| [**Track/Episode Path**](#trackplaylist-path-format) | Customize the file naming pattern for tracks, episodes, and playlists using variables like `{artist}`, `{album}`, etc. |
| **Use Custom Playlist Path** | Enable the use of a custom path format for playlists. |
Expand All @@ -102,8 +104,6 @@ Customize **OnTheSpot** to fit your preferences by adjusting the settings in the
| **Download Lyrics\*** | Enable downloading of lyrics for each track/episode. *This feature requires a premium account.* |
| **Download Synced Lyrics Only\*** | Only download synced lyrics for tracks. *This feature requires a premium account.*|
| **Save LRC File\*** | Save lyrics in an `.lrc` file alongside the track. *This feature requires a premium account.* |
| **File Bitrate** | Set the bitrate of a converted file, default value is 320k |
| **File Hertz** | Set the hertz of a converted file, default value is 44100 |
| **Rotate Active Account** | Automatically rotate between added accounts for downloading to minimize the chance of hitting rate limits. |
| **Raw Media Download** | Downloads an unmodified file from whatever service is selected. With this enabled file conversion and the embedding of any metadata is skipped. |
| **Download Delay** | Time (in seconds) to wait before initiating the next download. Helps prevent Spotify's rate limits. |
Expand Down
20 changes: 15 additions & 5 deletions src/onthespot/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .api.deezer import deezer_login_user, deezer_get_token
from .api.youtube import youtube_login_user
from .api.bandcamp import bandcamp_login_user
from .api.tidal import tidal_login_user, tidal_get_token

logger = get_logger("accounts")

Expand Down Expand Up @@ -56,10 +57,6 @@ def run(self):
if self.gui is True:
self.progress.emit(self.tr('Session created for\n{0}!').format(account['login']['client_id']), True)
continue
elif valid_login:
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)
Expand All @@ -82,14 +79,27 @@ def run(self):
self.progress.emit(self.tr('Login failed for \n{0}!').format(account['login']['username']), True)
continue

elif service == 'tidal':
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)
continue

elif service == 'youtube':
youtube_login_user(account)
continue

self.finished.emit()



def get_account_token(item_service):
if item_service in ('bandcamp', 'youtube'):
return
Expand Down
27 changes: 13 additions & 14 deletions src/onthespot/api/deezer.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,19 @@ def deezer_get_search_results(token, search_term, content_types):

search_results = []

if 'track' in content_types:
track_search = requests.get(track_url, params=params).json()
for track in track_search['data']:
search_results.append({
'item_id': track['id'],
'item_name': track['title'],
'item_by': track['artist']['name'],
'item_type': "track",
'item_service': "deezer",
'item_url': track['link'],
'item_thumbnail_url': track["album"]["cover"]
})

if 'album' in content_types:
album_search = requests.get(album_url, params=params).json()
for album in album_search['data']:
Expand All @@ -308,7 +321,6 @@ def deezer_get_search_results(token, search_term, content_types):
'item_thumbnail_url': album["cover"]
})


if 'artist' in content_types:
artist_search = requests.get(artist_url, params=params).json()
for artist in artist_search['data']:
Expand All @@ -335,18 +347,5 @@ def deezer_get_search_results(token, search_term, content_types):
'item_thumbnail_url': playlist["picture"]
})

if 'track' in content_types:
track_search = requests.get(track_url, params=params).json()
for track in track_search['data']:
search_results.append({
'item_id': track['id'],
'item_name': track['title'],
'item_by': track['artist']['name'],
'item_type': "track",
'item_service': "deezer",
'item_url': track['link'],
'item_thumbnail_url': track["album"]["cover"]
})

logger.info(search_results)
return search_results
Loading

0 comments on commit 054c724

Please sign in to comment.