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

"WARNING:root:NoneType: None" when using search query #20282

Closed
ghost opened this issue Mar 8, 2019 · 0 comments
Closed

"WARNING:root:NoneType: None" when using search query #20282

ghost opened this issue Mar 8, 2019 · 0 comments

Comments

@ghost
Copy link

@ghost ghost commented Mar 8, 2019

I'm having a rather strange issue that I can't figure out. I've been using youtube-dl on my discord bot for months now and have had no issues but all of a sudden if I try and search for a video using a search query it'll download the video but then say "WARNING:root:NoneType: None" and I'm not able to play it. However, if I use a URL instead it works fine. I can't understand what's happening here as I used to be able to use search query's with no problem. I'm on the latest version and have tried multiple previous versions to no avail.
Here's the code I have for my discord bot if anyone is interested.

@client.command(pass_context=True)
async def play(ctx,*, url):
user=ctx.message.author
voice_channel=user.voice.voice_channel
server = ctx.message.server
if voice_channel!= None:
    if "542354976966705192" in [role.id for role in ctx.message.author.roles]:
        try:
            await client.join_voice_channel(ctx.message.author.voice.voice_channel)
        except discord.errors.ClientException:
            pass
        voice_client = client.voice_client_in(server)
    
        embed=discord.Embed(title=("🎶 Getting the audio... 🎶"), color=0x9400D3)
        await client.say(embed=embed)
       
        
        try:
            if players[server.id].is_playing():
                server = ctx.message.server
                voice_client = client.voice_client_in(server)
                before_args="-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5"
                player = await voice_client.create_ytdl_player(url, before_options = before_args, ytdl_options={'default_search': 'auto'}, after = lambda: check_queue(server.id))
            
            
                if server.id in queues:
                    queues[server.id].append(player)
                else:
                    queues[server.id] = [player]
                
                
                
                embed=discord.Embed(title=(player.uploader),  description=(player.description), color=0x9400D3)
                embed.set_author(name=(player.title), url=(player.url) , icon_url='https://upload.wikimedia.org/wikipedia/commons/7/73/YouTube_Music.png')
                embed.add_field(name="Duration(in seconds):", value=(player.duration), inline=True)
                embed.add_field(name="Current Views:", value=(player.views), inline=True)
                embed.add_field(name="Likes:", value=(player.likes), inline=True)
                embed.add_field(name="Dislikes:", value=(player.dislikes), inline=True)
                embed.set_footer(text=random.choice(messages))
                await client.say(embed=embed)
                await client.say('``↪️Video will play once the current video has finished, or is stopped.↩️``{}'.format(ctx.message.author.mention) + " added this video the queue, blame him if it's shit." )
            
            else:
                server = ctx.message.server
                voice_client = client.voice_client_in(server)
                before_args="-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5"
                player = await voice_client.create_ytdl_player(url, before_options = before_args,  ytdl_options={'default_search': 'auto'}, after =lambda: check_queue(server.id))
                players[server.id] = player
                player.volume = 0.18
                embed=discord.Embed(title=("⏬ Audio downloaded succesfully ⏬"), color=0x9400D3)
                await client.say(embed=embed)
                await asyncio.sleep(0.2)
                embed=discord.Embed(title=(player.uploader), description=(player.description), color=0x9400D3)
                embed.set_author(name=(player.title), url=(player.url) , icon_url='https://upload.wikimedia.org/wikipedia/commons/7/73/YouTube_Music.png')
                embed.add_field(name="Duration(in seconds):", value=(player.duration), inline=True)
                embed.add_field(name="Current Views:", value=(player.views), inline=True)
                embed.add_field(name="Likes:", value=(player.likes), inline=True)
                embed.add_field(name="Dislikes:", value=(player.dislikes), inline=True)
                embed.set_footer(text=random.choice(messages))
                await client.say(embed=embed)
                players[server.id] = player
                player.start()
                await asyncio.sleep(0.2)
                embed=discord.Embed(title=("🎶 Now Playing 🎶"), color=0x9400D3)
                await client.say(embed=embed)
            
        except KeyError:
            server = ctx.message.server
            voice_client = client.voice_client_in(server)
            before_args="-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5"
            player = await voice_client.create_ytdl_player(url, before_options=before_args,  ytdl_options={'default_search': 'auto'}, after =lambda: check_queue(server.id))
            players[server.id] = player
            player.volume = 0.18
            embed=discord.Embed(title=("⏬ Audio downloaded succesfully ⏬"), color=0x9400D3)
            await client.say(embed=embed)
            await asyncio.sleep(0.2)
            embed=discord.Embed(title=(player.uploader),  description=(player.description), color=0x9400D3)
            embed.set_author(name=(player.title), url=(player.url), icon_url='https://upload.wikimedia.org/wikipedia/commons/7/73/YouTube_Music.png')
            embed.add_field(name="Duration(in seconds):", value=(player.duration), inline=True)
            embed.add_field(name="Current Views:", value=(player.views), inline=True)
            embed.add_field(name="Likes:", value=(player.likes), inline=True)
            embed.add_field(name="Dislikes:", value=(player.dislikes), inline=True)
            embed.set_footer(text=random.choice(messages))
            await client.say(embed=embed)
            players[server.id] = player
            player.start()
            await asyncio.sleep(0.2)
            embed=discord.Embed(title=("🎶 Now Playing 🎶"), color=0x9400D3)
            await client.say(embed=embed)
         
    else: 
        embed=discord.Embed(title=("❗ You have been banned from using this function. ❗"), color=0xFF0000)
        await client.say(embed=embed)
else:
    embed=discord.Embed(title=("❗ User is not in a channel. Join a voice channel and try again. ❗"), color=0xFF0000)
    await client.say(embed=embed)
@ghost ghost closed this Mar 8, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
0 participants
You can’t perform that action at this time.