spotDL / spotify-downloader

Download your Spotify playlists and songs along with album art and metadata (from YouTube if a match is found).
https://spotdl.readthedocs.io/en/latest/
MIT License
15.55k stars 1.48k forks source link

FileNotFound exception when playlist/album has backward slashes #2091

Open neufter opened 1 month ago

neufter commented 1 month ago

System OS

Windows

Python Version

3.11 (CPython)

Install Source

pip / PyPi

Install version / commit hash

v4.2.5

Expected Behavior vs Actual Behavior

Expected: Songs are downloaded and a m3u file with the album/playlist name is created, with incompatible characters removed or substituted. Actual: FileNotFound error is produced

Steps to reproduce - Ensure to include actual links!

  1. Pick a playlist or album with backwards slashes in the name, like "C:/System32/media" as I used
  2. Use download command with --m3u {list} option
  3. Wait until m3u file is attempted to be created

Traceback

Processing query: https://open.spotify.com/intl-pt/album/1Y74BzuV0yvV3toKu2w9bW
Found 7 songs in C:\System32\media (Album)
Skipping androidWG - intro.midi (file already exists) (duplicate)
androidWG - intro.midi: Skipped
Skipping androidWG - reality_coprocessor.midi (file already exists) (duplicate)
1/7 complete
androidWG - reality_coprocessor.midi: Skipped
Skipping androidWG - intermission.midi (file already exists) (duplicate)
androidWG - intermission.midi: Skipped
3/7 complete
Skipping androidWG - architecture.midi (file already exists) (duplicate)
Skipping androidWG - my_trip_to_canada.midi (file already exists) (duplicate)
androidWG - architecture.midi: Skipped
Skipping androidWG - rest.midi (file already exists) (duplicate)
androidWG - my_trip_to_canada.midi: Skipped
5/7 complete
androidWG - rest.midi: Skipped
6/7 complete
androidWG - kakkoii.midi: Downloading
androidWG - kakkoii.midi: Embedding metadata
androidWG - kakkoii.midi: Done
7/7 complete
Downloaded "androidWG - kakkoii.midi": https://music.youtube.com/watch?v=f_oz92naOGE
An error occurred
╭──────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────╮
│ C:\Users\samu-\AppData\Local\Programs\Python\Python311\Lib\site-packages\spotdl\console\entry_point.py:142 │
│ in console_entry_point                                                                                     │
│                                                                                                            │
│   139 │   try:                                                                                             │
│   140 │   │   # Pick the operation to perform                                                              │
│   141 │   │   # based on the name and run it!                                                              │
│ ❱ 142 │   │   OPERATIONS[arguments.operation](                                                             │
│   143 │   │   │   query=arguments.query,                                                                   │
│   144 │   │   │   downloader=downloader,                                                                   │
│   145 │   │   )                                                                                            │
│                                                                                                            │
│ C:\Users\samu-\AppData\Local\Programs\Python\Python311\Lib\site-packages\spotdl\console\download.py:34 in  │
│ download                                                                                                   │
│                                                                                                            │
│   31 │   )                                                                                                 │
│   32 │                                                                                                     │
│   33 │   # Download the songs                                                                              │
│ ❱ 34 │   downloader.download_multiple_songs(songs)                                                         │
│   35                                                                                                       │
│                                                                                                            │
│ C:\Users\samu-\AppData\Local\Programs\Python\Python311\Lib\site-packages\spotdl\download\downloader.py:328 │
│ in download_multiple_songs                                                                                 │
│                                                                                                            │
│   325 │   │   │   │   if path or self.settings["add_unavailable"]                                          │
│   326 │   │   │   ]                                                                                        │
│   327 │   │   │                                                                                            │
│ ❱ 328 │   │   │   gen_m3u_files(                                                                           │
│   329 │   │   │   │   song_list,                                                                           │
│   330 │   │   │   │   self.settings["m3u"],                                                                │
│   331 │   │   │   │   self.settings["output"],                                                             │
│                                                                                                            │
│ C:\Users\samu-\AppData\Local\Programs\Python\Python311\Lib\site-packages\spotdl\utils\m3u.py:119 in        │
│ gen_m3u_files                                                                                              │
│                                                                                                            │
│   116 │   if "{list}" in file_name:                                                                        │
│   117 │   │   # Create multiple m3u files if there are multiple lists                                      │
│   118 │   │   for list_name, song_list in lists_object.items():                                            │
│ ❱ 119 │   │   │   create_m3u_file(                                                                         │
│   120 │   │   │   │   file_name.format(                                                                    │
│   121 │   │   │   │   │   list=list_name,                                                                  │
│   122 │   │   │   │   ),                                                                                   │
│                                                                                                            │
│ C:\Users\samu-\AppData\Local\Programs\Python\Python311\Lib\site-packages\spotdl\utils\m3u.py:188 in        │
│ create_m3u_file                                                                                            │
│                                                                                                            │
│   185 │   │   detect_formats,                                                                              │
│   186 │   )                                                                                                │
│   187 │                                                                                                    │
│ ❱ 188 │   with open(file_name, "w", encoding="utf-8") as m3u_file:                                         │
│   189 │   │   m3u_file.write(m3u_content)                                                                  │
│   190 │                                                                                                    │
│   191 │   return m3u_content                                                                               │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\System32\\media.m3u8'

Other details

This issue seems to happen even with --restrict ascii added