SathyaBhat / spotify-dl

Downloads songs from your Spotify Playlist
http://sathyasays.com/2015/12/29/spotify-dl-download-your-spotify-my-music-songs-as-mp3/
MIT License
1.72k stars 211 forks source link

URL unchecked #317

Open Hsad1644 opened 1 year ago

Hsad1644 commented 1 year ago

Describe the bug I'm using this library via a batch file on a Windows 10 22H1. The batch file is called dlspty.bat and the command format is simply

dlspty.bat [spotify playlist link] 

The batch file itself looks like this

set SPOTIPY_CLIENT_ID=***
set SPOTIPY_CLIENT_SECRET=***
spotify_dl -l $1 -o D:\Music\Music

The output with error

C:\Users\anupa>spotify_dl -l $1 -o D:\Music\Music
[21:08:47] Starting spotify_dl v8.5.0                                                                                                                    spotify_dl.py:118
Sponsorblock enabled?: no
Traceback (most recent call last):
  File "C:\Users\anupa\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\anupa\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\anupa\AppData\Local\Programs\Python\Python310\Scripts\spotify_dl.exe\__main__.py", line 7, in <module>
  File "C:\Users\anupa\AppData\Local\Programs\Python\Python310\lib\site-packages\spotify_dl\spotify_dl.py", line 162, in spotify_dl
    valid_urls = validate_spotify_urls(args.url)
  File "C:\Users\anupa\AppData\Local\Programs\Python\Python310\lib\site-packages\spotify_dl\spotify.py", line 252, in validate_spotify_urls
    item_type, item_id = parse_spotify_url(url)
  File "C:\Users\anupa\AppData\Local\Programs\Python\Python310\lib\site-packages\spotify_dl\spotify.py", line 224, in parse_spotify_url
    item_id = parsed_url.split("/")[1]
IndexError: list index out of range
Sentry is attempting to send 2 pending error messages
Waiting up to 2 seconds
Press Ctrl-Break to quit

I refer the playlist link to the main spotify_dl command using $1 in my batch file. Since it's an IndexError, spotify_dl is likely not checking to verify if $1 is a URL or simply whether the URL field is empty. From the thrown errors I'm guessing the fix is somewhere here.

Is this a cache issue? My API credentials are good too. There has to be some issue with the parser.

To Reproduce Use my batch file method descried at the beginning. For Linux users -

export SPOTIPY_CLIENT_ID=***
export SPOTIPY_CLIENT_SECRET=***
spotify_dl -l $1 -o ~/Music

Expected behavior —for it to proceed nominally. This same script has worked before, but I've been encountering this problem after updating to v8.5.0. Matter of fact, this same error has popped during/after a previous update too (on my Linux machine). In both cases they fixed themselves after a few restarts. I'm hoping for the same this time too :')

Screenshots image

Desktop

SathyaBhat commented 1 year ago

if it works intermittently then it's likely that the variables are not set correctly/passed to the script

Hsad1644 commented 1 year ago

if it works intermittently then it's likely that the variables are not set correctly/passed to the script

I think there is something wrong with the .bat version of the downloader script. Likely something with arguments in cmd because the error is in the URL parsing. I'll edit the issue title if it turns out to be so.

It works fine when run as source downloader_script.sh i.e, its shell version run on git bash in Win10. Please help fix my script mentioned in the issue description. I will try on my end as well.

Thanks!