Skip to content

KeyError: 'videoDetails' when downloading from youtube links #2375

@blastbeng

Description

@blastbeng

### System OS

Linux

Python Version

3.11.2

Install Source

pip / PyPi

Install version / commit hash

4.2.11

Expected Behavior vs Actual Behavior

I expect to sync the songs correctly but spotdl crashes.

Steps to reproduce - Ensure to include actual links!

launch some intensive spotdl process, like a very long list of songs (000000_track_list.txt contains a very long list of yt music links - 5000+):

mapfile -t <000000_track_list.txt; /home/$USER/.local/bin/spotdl sync ${MAPFILE[@]} --config --headless --ignore-albums "live" "mixes" "in concert" "tour" --save-file 000000_sync.spotdl

start the sync process;

/home/$USER/.local/bin/spotdl sync --config --headless --ignore-albums "live" "mixes" "in concert" "tour" --save-file 000000_sync.spotdl --scan-for-songs --overwrite metadata

Traceback

[13:50:50] ERROR    MainThread - An error occurred                                                                                                                                                                                                                                                                                                       entry_point.py:177
                    ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
                    │ /home/blast/.local/lib/python3.11/site-packages/spotdl/console/entry_point.py:160 in entry_point                                                                                                                                                                                                                                 │
                    │                                                                                                                                                                                                                                                                                                                                  │
                    │   157 │   try:                                                                                                                                                                                                                                                                                                                   │
                    │   158 │   │   # Pick the operation to perform                                                                                                                                                                                                                                                                                    │
                    │   159 │   │   # based on the name and run it!                                                                                                                                                                                                                                                                                    │
                    │ ❱ 160 │   │   OPERATIONS[arguments.operation](                                                                                                                                                                                                                                                                                   │
                    │   161 │   │   │   query=arguments.query,                                                                                                                                                                                                                                                                                         │
                    │   162 │   │   │   downloader=downloader,                                                                                                                                                                                                                                                                                         │
                    │   163 │   │   )                                                                                                                                                                                                                                                                                                                  │
                    │                                                                                                                                                                                                                                                                                                                                  │
                    │ /home/blast/.local/lib/python3.11/site-packages/spotdl/console/sync.py:53 in sync                                                                                                                                                                                                                                                │
                    │                                                                                                                                                                                                                                                                                                                                  │
                    │    50 │   │   │   )                                                                                                                                                                                                                                                                                                              │
                    │    51 │   │                                                                                                                                                                                                                                                                                                                      │
                    │    52 │   │   # Parse the query                                                                                                                                                                                                                                                                                                  │
                    │ ❱  53 │   │   songs_list = parse_query(                                                                                                                                                                                                                                                                                          │
                    │    54 │   │   │   query=query,                                                                                                                                                                                                                                                                                                   │
                    │    55 │   │   │   threads=downloader.settings["threads"],                                                                                                                                                                                                                                                                        │
                    │    56 │   │   │   use_ytm_data=downloader.settings["ytm_data"],                                                                                                                                                                                                                                                                  │
                    │                                                                                                                                                                                                                                                                                                                                  │
                    │ /home/blast/.local/lib/python3.11/site-packages/spotdl/utils/search.py:98 in parse_query                                                                                                                                                                                                                                         │
                    │                                                                                                                                                                                                                                                                                                                                  │
                    │    95 │   - List of song objects                                                                                                                                                                                                                                                                                                 │
                    │    96 │   """                                                                                                                                                                                                                                                                                                                    │
                    │    97 │                                                                                                                                                                                                                                                                                                                          │
                    │ ❱  98 │   songs: List[Song] = get_simple_songs(                                                                                                                                                                                                                                                                                  │
                    │    99 │   │   query,                                                                                                                                                                                                                                                                                                             │
                    │   100 │   │   use_ytm_data=use_ytm_data,                                                                                                                                                                                                                                                                                         │
                    │   101 │   │   playlist_numbering=playlist_numbering,                                                                                                                                                                                                                                                                             │
                    │                                                                                                                                                                                                                                                                                                                                  │
                    │ /home/blast/.local/lib/python3.11/site-packages/spotdl/utils/search.py:178 in get_simple_songs                                                                                                                                                                                                                                   │
                    │                                                                                                                                                                                                                                                                                                                                  │
                    │   175 │   │   │   track_data = get_ytm_client().get_song(request.split("?v=", 1)[1])                                                                                                                                                                                                                                             │
                    │   176 │   │   │                                                                                                                                                                                                                                                                                                                  │
                    │   177 │   │   │   yt_song = Song.from_search_term(                                                                                                                                                                                                                                                                               │
                    │ ❱ 178 │   │   │   │   f"{track_data['videoDetails']['author']} -                                                                                                                                                                                                                                                                 │
                    │       {track_data['videoDetails']['title']}"                                                                                                                                                                                                                                                                                     │
                    │   179 │   │   │   )                                                                                                                                                                                                                                                                                                              │
                    │   180 │   │   │                                                                                                                                                                                                                                                                                                                  │
                    │   181 │   │   │   if use_ytm_data:                                                                                                                                                                                                                                                                                               │
                    ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
                    KeyError: 'videoDetails'
ERROR:spotdl.console.entry_point:An error occurred
Traceback (most recent call last):
  File "/home/blast/.local/lib/python3.11/site-packages/spotdl/console/entry_point.py", line 160, in entry_point
    OPERATIONS[arguments.operation](
  File "/home/blast/.local/lib/python3.11/site-packages/spotdl/console/sync.py", line 53, in sync
    songs_list = parse_query(
                 ^^^^^^^^^^^^
  File "/home/blast/.local/lib/python3.11/site-packages/spotdl/utils/search.py", line 98, in parse_query
    songs: List[Song] = get_simple_songs(
                        ^^^^^^^^^^^^^^^^^
  File "/home/blast/.local/lib/python3.11/site-packages/spotdl/utils/search.py", line 178, in get_simple_songs
    f"{track_data['videoDetails']['author']} - {track_data['videoDetails']['title']}"
       ~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'videoDetails'

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugUnexpected problem or unintended behavior that needs to be fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions