def yt_queue(s, m):
global prev, song, voice, player, yt
ydl_opts = {
'format': 'bestaudio/best',
'noplaylist': True,
'nocheckcertificate': True,
'quiet': True,
'outtmpl': ytDir + '%(id)s',
'default_search': 'auto'
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
meta = ydl.extract_info(s, download=False)
yt[meta['id']] = {
'id': meta['id'],
'title': meta['title'],
'artist': meta['uploader'],
'album': 'YouTube',
'composer': None, # meta['view_count'] / meta['like_count'] / meta['dislike_count']
'length': meta['duration'],
'file': meta['id']
}
if (meta['id'] in prev):
mainMessage = '[' + m.author.display_name + ']?The song [YT] _' + meta['title'] + '_ has already been played recently'
elif (meta['id'] in queue):
mainMessage = '[' + m.author.display_name + ']?The song [YT] _' + meta['title'] + '_ is already in the queue'
elif (meta['duration'] > 900):
mainMessage = '[' + m.author.display_name + ']?The song [YT] _' + meta['title'] + '_ is too long (max 15 minutes)'
else:
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([s])
queue.append(meta['id'])
dprint(Fore.MAGENTA + m.author.display_name + ' queued:' + Style.NORMAL + ' [YT] ' + meta['uploader'] + ' - ' + meta['title'])
mainMessage = '[' + m.author.display_name + ']?Queued [YT] _' + meta['title'] + '_'
await client.send_message(m.channel, mainMessage)
if (m.server): await client.delete_message(m)
评论列表
文章目录