spotify-downloader icon indicating copy to clipboard operation
spotify-downloader copied to clipboard

Save file not working

Open 1RandomDev opened this issue 2 years ago • 4 comments

System OS

Linux

Python Version

3.10 (CPython)

Install Source

GitHub

Install version / commit hash

6e28a50614f4d0e4ea8fc916bc2a998be5712d88

Expected Behavior vs Actual Behavior

The downloaded song should be saved in the specified archive.spotdl file, but the script crashes after the download.

Steps to reproduce - Ensure to include actual links!

Download a random song with the --save-file option.

Traceback

$ spotdl --save-file archive.spotdl download https://open.spotify.com/track/6r2CWMp5OOcIzFQzzBdsDI
Downloaded "Ramo - KOKAIN & DOLLARS": https://www.youtube.com/watch?v=ks5j84eHC3U

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /usr/local/lib/python3.8/dist-packages/spotdl/console/entry_point.py:256 in entry_point          │
│                                                                                                  │
│   255 │   │   # based on the name and run it!                                                    │
│ ❱ 256 │   │   OPERATIONS[arguments.operation](                                                   │
│   257 │   │   │   query=arguments.query,                                                         │
│                                                                                                  │
│ /usr/local/lib/python3.8/dist-packages/spotdl/console/download.py:46 in download                 │
│                                                                                                  │
│   45 │   │   with open(save_path, "w", encoding="utf-8") as save_file:                           │
│ ❱ 46 │   │   │   json.dump(songs, save_file, indent=4, ensure_ascii=False)                       │
│   47                                                                                             │
│                                                                                                  │
│ /usr/lib/python3.8/json/__init__.py:179 in dump                                                  │
│                                                                                                  │
│   178 │   # a debuggability cost                                                                 │
│ ❱ 179 │   for chunk in iterable:                                                                 │
│   180 │   │   fp.write(chunk)                                                                    │
│                                                                                                  │
│ /usr/lib/python3.8/json/encoder.py:429 in _iterencode                                            │
│                                                                                                  │
│   428 │   │   elif isinstance(o, (list, tuple)):                                                 │
│ ❱ 429 │   │   │   yield from _iterencode_list(o, _current_indent_level)                          │
│   430 │   │   elif isinstance(o, dict):                                                          │
│                                                                                                  │
│ /usr/lib/python3.8/json/encoder.py:325 in _iterencode_list                                       │
│                                                                                                  │
│   324 │   │   │   │   │   chunks = _iterencode(value, _current_indent_level)                     │
│ ❱ 325 │   │   │   │   yield from chunks                                                          │
│   326 │   │   if newline_indent is not None:                                                     │
│                                                                                                  │
│ /usr/lib/python3.8/json/encoder.py:438 in _iterencode                                            │
│                                                                                                  │
│   437 │   │   │   │   markers[markerid] = o                                                      │
│ ❱ 438 │   │   │   o = _default(o)                                                                │
│   439 │   │   │   yield from _iterencode(o, _current_indent_level)                               │
│                                                                                                  │
│ /usr/lib/python3.8/json/encoder.py:179 in default                                                │
│                                                                                                  │
│   178 │   │   """                                                                                │
│ ❱ 179 │   │   raise TypeError(f'Object of type {o.__class__.__name__} '                          │
│   180 │   │   │   │   │   │   f'is not JSON serializable')                                       │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: Object of type Song is not JSON serializable

Other details

The download part works flawlessly, but right after is finished the script crashes. After the crash the archive file is being created but only contains a single [.

1RandomDev avatar Jul 09 '22 19:07 1RandomDev

Will fix this in a sec, thanks for letting us know

xnetcat avatar Jul 09 '22 19:07 xnetcat

The error is fixed in df641ca4fbe537bba9bb57236a8e6ed361d26f5b but now the save file gets overwritten on every download which makes it quite useless

1RandomDev avatar Jul 15 '22 11:07 1RandomDev

Have you changed save file in config

xnetcat avatar Jul 15 '22 11:07 xnetcat

No it's set to null. Didn't even knew until now that spotdl has a config lol. But I have specified it in the command.

Edit: It only happens when downloading from different playlists or single tracks.

1RandomDev avatar Jul 15 '22 11:07 1RandomDev

This issue has been automatically marked stale because there hasn't been any activity for the last 30 days.

stale[bot] avatar Aug 15 '22 23:08 stale[bot]

@1RandomDev

Can you please confirm if this still exists in rc3?

Update your spotDL to the latest release candidate: python -m pip install -U pip pip install -U --force spotdl==4.0.0rc3

Silverarmor avatar Aug 23 '22 11:08 Silverarmor

fixed on dev

xnetcat avatar Aug 30 '22 20:08 xnetcat