Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SongError: Invalid URL when attempting to download a playlist with spotify.link URL #1939

Closed
periode opened this issue Oct 24, 2023 · 1 comment · Fixed by #1919
Closed
Labels
Bug Unexpected problem or unintended behavior that needs to be fixed

Comments

@periode
Copy link

periode commented Oct 24, 2023

System OS

Linux

Python Version

3.11 (CPython)

Install Source

Arch User Repository (Unofficial)

Install version / commit hash

v4.2.1

Expected Behavior vs Actual Behavior

Hello!

First of all, thanks for the project, it works like a charm!

However, I did encounter a small issue: I attempted to run spotdl https://spotify.link/alWo6b7P9Db and I got an invalid URL error.

When I open the link into my browser, it expands into an open.spotify.com link and if I try to download this one, it works like charm, so the issue does not seem to be on the playlist side.

Steps to reproduce - Ensure to include actual links!

  1. spotdl https://spotify.link/alWo6b7P9Db
  2. fail

Traceback

An error occurred                                                                                                                                                                                                                              
╭───────────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ /usr/lib/python3.11/site-packages/spotdl/console/entry_point.py:125 in console_entry_point                                                                                                                                                  │
│                                                                                                                                                                                                                                             │
│   122 │   try:                                                                                                                                                                                                                              │
│   123 │   │   # Pick the operation to perform                                                                                                                                                                                               │
│   124 │   │   # based on the name and run it!                                                                                                                                                                                               │
│ ❱ 125 │   │   OPERATIONS[arguments.operation](                                                                                                                                                                                              │
│   126 │   │   │   query=arguments.query,                                                                                                                                                                                                    │
│   127 │   │   │   downloader=downloader,                                                                                                                                                                                                    │
│   128 │   │   )                                                                                                                                                                                                                             │
│                                                                                                                                                                                                                                             │
│ /usr/lib/python3.11/site-packages/spotdl/console/download.py:25 in download                                                                                                                                                                 │
│                                                                                                                                                                                                                                             │
│   22 │   """                                                                                                                                                                                                                                │
│   23 │                                                                                                                                                                                                                                      │
│   24 │   # Parse the query                                                                                                                                                                                                                  │
│ ❱ 25 │   songs = get_simple_songs(                                                                                                                                                                                                          │
│   26 │   │   query,                                                                                                                                                                                                                         │
│   27 │   │   use_ytm_data=downloader.settings["ytm_data"],                                                                                                                                                                                  │
│   28 │   │   playlist_numbering=downloader.settings["playlist_numbering"],                                                                                                                                                                  │
│                                                                                                                                                                                                                                             │
│ /usr/lib/python3.11/site-packages/spotdl/utils/search.py:237 in get_simple_songs                                                                                                                                                            │
│                                                                                                                                                                                                                                             │
│   234 │   │   │   songs.append(Song.from_url(url=request))                                                                                                                                                                                  │
│   235 │   │   elif "https://spotify.link/" in request:                                                                                                                                                                                      │
│   236 │   │   │   resp = requests.head(request, allow_redirects=True, timeout=10)                                                                                                                                                           $
│ ❱ 237 │   │   │   songs.append(Song.from_url(url=resp.url))                                                                                                                                                                                 │
│   238 │   │   elif "open.spotify.com" in request and "playlist" in request:                                                                                                                                                                 │
│   239 │   │   │   lists.append(Playlist.from_url(request, fetch_songs=False))                                                                                                                                                               │
│   240 │   │   elif "open.spotify.com" in request and "album" in request:                                                                                                                                                                    │
│                                                                                                                                                                                                                                             │
│ /usr/lib/python3.11/site-packages/spotdl/types/song.py:76 in from_url                                                                                                                                                                       │
│                                                                                                                                                                                                                                             │
│    73 │   │   """                                                                                                                                                                                                                           │
│    74 │   │                                                                                                                                                                                                                                 │
│    75 │   │   if "open.spotify.com" not in url or "track" not in url:                                                                                                                                                                       │
│ ❱  76 │   │   │   raise SongError(f"Invalid URL: {url}")                                                                                                                                                                                    │
│    77 │   │                                                                                                                                                                                                                                 │
│    78 │   │   # query spotify for song, artist, album details                                                                                                                                                                               │
│    79 │   │   spotify_client = SpotifyClient()                                                                                                                                                                                              │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
SongError: Invalid URL: https://open.spotify.com/playlist/6bgxFmiFXOi9EXSV3OmVbp?si=tdQKAMClTaSYfUPDfgR6YQ&utm_source=copy-link&utm_medium=copy-link&nd=1&_branch_match_id=link-1245341361340097978

Other details

I also ran spotdl --check-for-updates and no updates are available, so it seems like I'm running the latest version.

From what I can see, spotdl is attempting to append a playlist URL to a song object?

@periode periode added the Bug Unexpected problem or unintended behavior that needs to be fixed label Oct 24, 2023
@xnetcat xnetcat linked a pull request Oct 27, 2023 that will close this issue
@bkdwt
Copy link

bkdwt commented Nov 11, 2023

I am getting an error with Spotify too.

Fetching Song...

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\mario\AppData\Local\Programs\Python\Python312\Scripts\spotdl.exe\__main__.py", line 7, in <module>
  File "C:\Users\mario\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotdl\console\__init__.py", line 78, in console_entry_point
    song_list = parse_query(
                ^^^^^^^^^^^^
  File "C:\Users\mario\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotdl\parsers\query_parser.py", line 29, in parse_query
    parse_request(
  File "C:\Users\mario\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotdl\parsers\query_parser.py", line 87, in parse_request
    song = song_gatherer.from_spotify_url(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\mario\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotdl\search\song_gatherer.py", line 43, in from_spotify_url
    raw_track_meta, raw_artist_meta, raw_album_meta = metadata_provider.from_url(
                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\mario\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotdl\providers\metadata_provider.py", line 11, in from_url
    raw_track_meta = spotify_client.track(spotify_url)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\mario\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotipy\client.py", line 370, in track
    trid = self._get_id("track", track_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\mario\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotipy\client.py", line 1990, in _get_id
    raise SpotifyException(400, -1, "Unsupported URL / URI.")
spotipy.exceptions.SpotifyException: http status: 400, code:-1 - Unsupported URL / URI., reason: None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Unexpected problem or unintended behavior that needs to be fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants