1
0
Fork 0
mirror of https://gitlab.jonasled.de/jonasled/discordbot synced 2024-06-18 08:08:19 +02:00

fixed music bot

This commit is contained in:
Jonas Leder 2020-12-02 12:45:21 +01:00
parent 3788382e82
commit dafa9bcf1f

15
bot.py
View file

@ -8,7 +8,7 @@ from config import *
from requests import get
from json import loads
from os import remove, listdir
from youtube_dl import YoutubeDL
from youtube_dlc import YoutubeDL
from time import time
from asyncio import sleep
from io import BytesIO
@ -738,6 +738,7 @@ async def checkForNextSong(): # background task, that runs every second and che
try:
if (player != None) and not player.is_playing() and (
len(playerQue) > 0): # check if the player is active and the song ended
print("song ended")
if (playing): # check if the player played previously
print("clear last")
playerQue.remove(playerQue[0]) # remove the first entry from the que and the first title
@ -755,12 +756,14 @@ async def checkForNextSong(): # background task, that runs every second and che
if 'entries' in data:
# take first item from a playlist
data = data['entries'][0]
for format in data["formats"]:
if(format["format_id"] == "140"):
try:
filename = data["formats"][0]["manifest_url"]
except:
filename = data["formats"][0]["url"]
try:
filename = data["formats"][0]["manifest_url"]
except:
filename = data["formats"][0]["url"]
print("start playback: " + filename)
audioPlayer = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(filename, **{
'options': '-vn'})) # convert the audio player to a volume audio player
player.play(audioPlayer)