PythonistaGuild / Wavelink

A powerful Lavalink library for Discord.py.
https://wavelink.dev
MIT License
393 stars 180 forks source link

Spotify albums always plays same song #219

Closed Goodname15 closed 1 year ago

Goodname15 commented 1 year ago

When using the iterator method for a Spotify Album, it returns correct track names and IDs but for some reason that I can't figure out, it always plays this regardless of the Album provided:

None - Life Has Gone On Long Enough (Full Album)

I have tested the same code, but swapping an Album for a playlist and it works flawlessly. Also I am using the fix from #212.

My code is as follows

from discord.ext import commands
import wavelink
from wavelink.ext import spotify

TOKEN = 'TOKEN_HERE'

SPOTIFY_ID = 'SPOTIFY_CLIENT_ID_HERE'
SPOTIFY_SECRET = 'SPOTIFY_CLIENT_SECRET_HERE'

intents = discord.Intents.default()
intents.message_content = True

prefix = '!'

client = commands.Bot(command_prefix=prefix, intents=intents)

@client.event
async def on_ready():
    node: wavelink.Node = wavelink.Node(uri='http://localhost:2333', password='youshallnotpass')

    sc = spotify.SpotifyClient(
        client_id=SPOTIFY_ID,
        client_secret=SPOTIFY_SECRET
        )

    await wavelink.NodePool.connect(client=client, nodes=[node], spotify=sc)
    print('Bot ready')

@client.command(aliases=['p'])
async def play(ctx, query):
    if not ctx.voice_client:
        vc: wavelink.Player = await ctx.author.voice.channel.connect(cls=wavelink.Player)
    else:
        vc: wavelink.Player = ctx.voice_client

    decoded = spotify.decode_url(query)

    if decoded['type'] == spotify.SpotifySearchType.album:
        async for track in spotify.SpotifyTrack.iterator(query=query, type=spotify.SpotifySearchType.album):
            await vc.play(track)

client.run(TOKEN)
EvieePy commented 1 year ago

Potentially fixed with #222

Please consider updating your version of wavelink: pip install -U git+https://github.com/PythonistaGuild/Wavelink.git --force-reinstall to test these changes.

Goodname15 commented 1 year ago

It seems as if the issue is indeed resolved