nathom / streamrip

A scriptable music downloader for Qobuz, Tidal, SoundCloud, and Deezer
GNU General Public License v3.0
2.55k stars 219 forks source link

[BUG] Album can't download if it has reserved/forbidden characters, e.g. ":", ">", etc. #542

Closed Tom4tot closed 7 months ago

Tom4tot commented 7 months ago

Describe the bug

Hi,

in my config, my albums are downloaded this way:

[filepaths]
# Create folders for single tracks within the downloads directory using the folder_format
# template
add_singles_to_folder = true
# Available keys: "albumartist", "title", "year", "bit_depth", "sampling_rate",
# "id", and "albumcomposer"
folder_format = "{albumartist} - {year} - {title}"

It mostly works, however, I tried to download an album that has ":" in its title, and it didn't work (in my case, it's Codename: Dustsucker)

Here is the message I got:

C:\Users\Tom\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\Scripts>rip url https://play.qobuz.com/album/h0mubco43kfjb
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in _run_module_as_main:198                                                                       │
│ in _run_code:88                                                                                  │
│                                                                                                  │
│                                     ... 13 frames hidden ...                                     │
│                                                                                                  │
│ C:\Users\Tom\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCach │
│ e\local-packages\Python312\site-packages\streamrip\media\album.py:63 in resolve                  │
│                                                                                                  │
│   60 │   │   tracklist = get_album_track_ids(self.client.source, resp)                           │
│   61 │   │   folder = self.config.session.downloads.folder                                       │
│   62 │   │   album_folder = self._album_folder(folder, meta)                                     │
│ ❱ 63 │   │   os.makedirs(album_folder, exist_ok=True)                                            │
│   64 │   │   embed_cover, _ = await download_artwork(                                            │
│   65 │   │   │   self.client.session,                                                            │
│   66 │   │   │   album_folder,                                                                   │
│ in makedirs:225                                                                                  │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
NotADirectoryError: [WinError 267] The directory name is invalid: 'C:\\Users\\Tom\\Downloads\\1-Music\\2-Streamrip\\Bark
Psychosis - 2004 - Codename: Dustsucker'

If I change my config file so the album title is not included, the album is downloaded normally.

Streamrip should ignore/replace reserved characters (you can find the list here: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file ) < (less than)

(greater than) : (colon) " (double quote) / (forward slash) \ (backslash) | (vertical bar or pipe) ? (question mark)

  • (asterisk)

Command Used

rip url https://play.qobuz.com/album/h0mubco43kfjb

Debug Traceback

-

Config File

-

Operating System

Windows 11

streamrip version

2.0.2

Screenshots and recordings

No response

Additional context

No response

herovaxy commented 7 months ago

Same problem as well. There's album that have characters such as "?" and since Windows doesn't allow "?" to be renamed on Folders. Suddenly, streamrip decides to not download it.

NighthawkUK commented 7 months ago

Yes, same here, Hoping for an update to ignore these characters since windows doesn't like them on folders!

snucker-fod commented 7 months ago

Same issue on WSL


Track 6  ━━━━╸━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.9% • 1.7 MB/s • 0:00:22
Track 18 ━━━━━╸━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.4% • 1.8 MB/s • 0:00:16
Track 13 ━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.0% • 1.8 MB/s • 0:00:14
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/snucker/.local/bin/rip:8 in <module>                                                       │
│                                                                                                  │
│   5 from streamrip.rip import rip                                                                │
│   6 if __name__ == '__main__':                                                                   │
│   7 │   sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])                         │
│ ❱ 8 │   sys.exit(rip())                                                                          │
│   9                                                                                              │
│                                                                                                  │
│ /home/snucker/.local/lib/python3.10/site-packages/click/core.py:1157 in __call__                 │
│                                                                                                  │
│                                     ... 19 frames hidden ...                                     │
│                                                                                                  │
│ /home/snucker/.local/lib/python3.10/site-packages/streamrip/metadata/track.py:55 in from_qobuz   │
│                                                                                                  │
│    52 │   │   composer = typed(resp.get("composer", {}).get("name"), str | None)                 │
│    53 │   │   tracknumber = typed(resp.get("track_number", 1), int)                              │
│    54 │   │   discnumber = typed(resp.get("media_number", 1), int)                               │
│ ❱  55 │   │   artist = typed(                                                                    │
│    56 │   │   │   safe_get(                                                                      │
│    57 │   │   │   │   resp,                                                                      │
│    58 │   │   │   │   "performer",                                                               │
│                                                                                                  │
│ /home/snucker/.local/lib/python3.10/site-packages/streamrip/metadata/util.py:24 in typed         │
│                                                                                                  │
│   21                                                                                             │
│   22                                                                                             │
│   23 def typed(thing, expected_type: Type[T]) -> T:                                              │
│ ❱ 24 │   assert isinstance(thing, expected_type)                                                 │
│   25 │   return thing                                                                            │
│   26                                                                                             │
│   27                                                                                             │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AssertionError
sys:1: RuntimeWarning: coroutine 'Artist._download_async.<locals>._rip' was never awaited

rip --version
rip, version 2.0.3```
nathom commented 7 months ago

@herovaxy @NighthawkUK @snucker-fod fixed in v2.0.3