Skip to content

[p]play does not accept spotify links with regional codes #6446

@M4th12

Description

@M4th12

When a link contains an /intl-XX code (ie https://open.spotify.com/intl-it/track/6KmrCHbuNOsdoeDOpwetr7?si=5314fcead96a4042, https://open.spotify.com/intl-es/track/6CIMoDfTsvFVGhFi3v9Izn?si=acea235e19c74922, etc), Audio raises an error and fails to play the track. This can be fixed by simply removing the /intl-XX portion of the URL. Logic to do this automatically should be added to the spotify track interpretation logic of Audio.

Original issue below:

What Red version are you using?

3.5.13

What were you trying to do?

Trying to listen some music using Spotify links

What did you expect to happen?

Start the music

What actually happened?

Nothing, except error on console

[2024-09-05 00:28:12] [INFO] discord.client: logging in using static token
[2024-09-05 00:28:13] [INFO] red: Loading packages...
[2024-09-05 00:28:14] [ERROR] red.core.cogs.Streams: Twitch OAuth2 API request failed with status code 400 and error message: missing client id
[2024-09-05 00:28:14] [INFO] red: Loaded packages: permissions, admin, alias, audio, cleanup, customcom, downloader, economy, filter, general, image, mod, modlog, mutes, reports, streams, trivia, warnings
[2024-09-05 00:28:15] [INFO] discord.gateway: Shard ID 0 has connected to Gateway (Session ID: 7abdb0e66d8351927cde110f0bc14d8b).
[2024-09-05 00:28:15] [INFO] red: Connected to Discord. Getting ready...
[2024-09-05 00:28:18] [INFO] red.Audio.manager: Managed Lavalink node startup command: 'C:\Program Files\Java\jdk-17\bin\java.exe' -Xms64M -Xmx7G -jar 'C:\Users\Server\AppData\Local\Red-DiscordBot\cogs\Audio\Lavalink.jar'
[2024-09-05 00:28:18] [INFO] red.Audio.manager: Managed Lavalink node started. PID: 12088
[2024-09-05 00:28:18] [INFO] red.Audio.manager: Waiting for Managed Lavalink node to be ready
[2024-09-05 00:28:25] [INFO] red.Audio.manager: Managed Lavalink node is ready to receive requests.
[2024-09-05 00:28:25] [INFO] red.Audio.WS.LLNode: Lavalink WS connecting to ws://localhost:2333 with headers {'Authorization': 'youshallnotpass', 'User-Id': '1194401660861157557', 'Num-Shards': '1', 'Client-Name': 'Red-Lavalink/0.11.0', 'Resume-Key': 'Red-Core-Audio-1194401660861157557-YTBot'}
[2024-09-05 00:28:27] [INFO] red.Audio.WS.LLNode: Lavalink WS connected to ws://localhost:2333
[2024-09-05 00:28:45] [ERROR] red: KeyError
Traceback (most recent call last):
File "C:\Users\Server\redenv\Lib\site-packages\discord\ext\commands\core.py", line 235, in wrapped
ret = await coro(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Server\redenv\Lib\site-packages\redbot\cogs\audio\core\commands\player.py", line 128, in command_play
return await self._get_spotify_tracks(ctx, query)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Server\redenv\Lib\site-packages\redbot\cogs\audio\core\utilities\player.py", line 283, in _get_spotify_tracks
raise e
File "C:\Users\Server\redenv\Lib\site-packages\redbot\cogs\audio\core\utilities\player.py", line 262, in _get_spotify_tracks
res = await self.api_interface.spotify_query(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Server\redenv\Lib\site-packages\redbot\cogs\audio\apis\interface.py", line 392, in spotify_query
urls = await self.fetch_spotify_query(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Server\redenv\Lib\site-packages\redbot\cogs\audio\apis\interface.py", line 223, in fetch_spotify_query
) = await self.spotify_api.get_spotify_track_info(track, ctx)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Server\redenv\Lib\site-packages\redbot\cogs\audio\apis\spotify.py", line 67, in get_spotify_track_info
track_name = track_data["name"]
~~~~~~~~~~^^^^^^^^
KeyError: 'name'

How can we reproduce this error?

1.Start the bot
2.Use the command to add a song from spotify (%play https://open.spotify.com/intl-it/track/6KmrCHbuNOsdoeDOpwetr7?si=5314fcead96a4042)

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Category: Cogs - AudioThis is related to the Audio cog.Status: PRs WelcomeNo one is currently assigned to this issue, but we'd be grateful if anyone made a PR.Type: BugUnexpected behavior, result, or exception. In case of PRs, it is a fix for the foregoing.

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions