Hi,
First I would like to thank you for all your work.
I would like to know if you could add an option to prefix the output file name with the number indicating the position of the track in the playlist ?
Thanks in advance for your feedback.
Regards,
Julien.
Hi Julien,
check out this wiki page: https://github.com/ritiek/spotify-downloader/wiki/Advanced-usage, especially the section "Set custom filenames" - I believe it fits exactly your needs. If not, feel free to elaborate and reopen the issue :)
the {track_number} give the track position from the song's Album but not the position in a custom playlist.
Ah, got it. I'm not sure if we get the song's position in the playlist from Spotify, but I'll look into it in the next few days.
Thanks a lot.
The --playlist flag, the only way to download custom playlists, saves the list of urls to a .txt file, then the only sensible way to do this would be to track the song number in the actual .txt, not the playlist.
the only sensible way to do this would be to track the song number in the actual .txt, not the playlist.
Yep, this seems to be the only way for now. IMO this will introduce many changes in the code for this very specific feature which doesn't seem worth it to me. It shouldn't be hard to write an external python script that renames the tracks based on their creation or modification time (order of tracks in spotify playlist and order of download are both same).
For example, this python script will rename all files ending with .mp3 in the present working directory to include their position in the playlist in the beginning of the filename:
import os
tracks = [ f for f in os.listdir('.')
if f.endswith(".mp3") ]
sorted_tracks = sorted(os.listdir('.'), key=os.path.getctime)
for n, track in enumerate(sorted_tracks, 1):
rename_to = "{}. {}".format(n, track)
os.rename(track, rename_to)
not the greatest solution, since some tracks aren't found, so this approach will count incorrectly and will make it difficult to insert missing tracks acquired elsewhere manually.
and on unix you will want numbers of the same order or it won't sort right, so rename_to = "{:0>2d}. {}".format(n, track) (assuming < 100 tracks)
plus the provided code is invalid - it adds numbers to non-mp3 files too.
Here is a corrected version:
#!/usr/bin/env python3
import os
sorted_tracks = [f for f in sorted(os.listdir('.'), key=os.path.getctime) if f.endswith(".mp3")]
for n, track in enumerate(sorted_tracks, 1):
rename_to = "{:0>2d}. {}".format(n, track)
os.rename(track, rename_to)
Good idea. Why don't you open a new issue and reference it under new features?
These use cases aren't supported in v3 as of now.
I know it's late, just clearing out old issues.
Most helpful comment
not the greatest solution, since some tracks aren't found, so this approach will count incorrectly and will make it difficult to insert missing tracks acquired elsewhere manually.
and on unix you will want numbers of the same order or it won't sort right, so
rename_to = "{:0>2d}. {}".format(n, track)(assuming < 100 tracks)plus the provided code is invalid - it adds numbers to non-mp3 files too.
Here is a corrected version: