Skip to content

Commit

Permalink
Add playlist number and service to track path
Browse files Browse the repository at this point in the history
  • Loading branch information
justin025 committed Nov 17, 2024
1 parent 94c445f commit 9791aea
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/onthespot/api/deezer.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,5 @@ def deezer_get_search_results(token, search_term, content_types):
'item_thumbnail_url': track["album"]["cover"]
})


logger.info(search_results)
return search_results
1 change: 1 addition & 0 deletions src/onthespot/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def run(self):
'is_playlist_item': item['is_playlist_item'],
'playlist_name': playlist_name,
'playlist_by': playlist_by,
'playlist_number': item['playlist_number']
}
time.sleep(1)
continue
Expand Down
3 changes: 1 addition & 2 deletions src/onthespot/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ def run(self):

try:
item_metadata = globals()[f"{item_service}_get_{item_type}_metadata"](token, item_id)

item_path = format_track_path(item_metadata, item_service, item_type, item['parent_category'], item['playlist_name'], item['playlist_by'])
item_path = format_track_path(item, item_metadata)

except (Exception, KeyError):
item['item_status'] = "Failed"
Expand Down
1 change: 1 addition & 0 deletions src/onthespot/gui/mainui.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ def add_item_to_download_list(self, item, item_metadata):
'parent_category': item['parent_category'],
'playlist_name': playlist_name,
'playlist_by': playlist_by,
'playlist_number': item.get('playlist_number', ''),
"gui": {
"status_label": status_label,
"progress_bar": pbar,
Expand Down
13 changes: 9 additions & 4 deletions src/onthespot/parse_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ def parsingworker():
'item_id': item_id,
'parent_category': 'playlist',
'playlist_name': playlist_name,
'playlist_by': playlist_by
'playlist_by': playlist_by,
'playlist_number': str(index + 1)
}
print(pending)
except TypeError:
logger.error(f'TypeError for {item}')
continue
Expand Down Expand Up @@ -147,7 +149,8 @@ def parsingworker():
'item_id': item_id,
'parent_category': 'playlist',
'playlist_name': 'Liked Songs',
'playlist_by': 'me'
'playlist_by': 'me',
'playlist_number': str(index + 1)
}
continue

Expand All @@ -161,7 +164,8 @@ def parsingworker():
'item_id': item_id,
'parent_category': 'playlist',
'playlist_name': 'Your Episodes',
'playlist_by': 'me'
'playlist_by': 'me',
'playlist_number': str(index + 1)
}
continue

Expand Down Expand Up @@ -212,7 +216,8 @@ def parsingworker():
'item_id': item_id,
'parent_category': 'playlist',
'playlist_name': playlist_name,
'playlist_by': playlist_by
'playlist_by': playlist_by,
'playlist_number': str(index + 1)
}
continue
elif current_type == "artist":
Expand Down
14 changes: 8 additions & 6 deletions src/onthespot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,23 @@ def conv_list_format(items):
return (config.get('metadata_seperator')).join(items)


def format_track_path(item_metadata, item_service, item_type, parent_category, playlist_name, playlist_by):
def format_track_path(item, item_metadata):
if config.get("translate_file_path"):
name = translate(item_metadata.get('title', ''))
album = translate(item_metadata.get('album_name', ''))
else:
name = item_metadata.get('title', '')
album = item_metadata.get('album_name', '')

if parent_category == 'playlist' and config.get("use_playlist_path"):
if item['parent_category'] == 'playlist' and config.get("use_playlist_path"):
path = config.get("playlist_path_formatter")
elif item_type == 'track':
elif item['item_type'] == 'track':
path = config.get("track_path_formatter")
elif item_type == 'episode':
elif item['item_type'] == 'episode':
path = config.get("podcast_path_formatter")

item_path = path.format(
service=sanitize_data(item.get('item_service', '')).title(),
artist=sanitize_data(item_metadata.get('artists', '')),
album=sanitize_data(album),
album_artist=sanitize_data(item_metadata.get('album_artists', '')),
Expand All @@ -122,8 +123,9 @@ def format_track_path(item_metadata, item_service, item_type, parent_category, p
explicit=sanitize_data(str(config.get('explicit_label')) if item_metadata.get('explicit') else ''),
trackcount=item_metadata.get('total_tracks', ''),
disccount=item_metadata.get('total_discs', ''),
playlist_name=sanitize_data(playlist_name),
playlist_owner=sanitize_data(playlist_by),
playlist_name=sanitize_data(item.get('playlist_name', '')),
playlist_owner=sanitize_data(item.get('playlist_by', '')),
playlist_number=sanitize_data(item.get('playlist_number', '')),
)

return item_path

0 comments on commit 9791aea

Please sign in to comment.