fix youtube dl timeout
This commit is contained in:
parent
84dd36208f
commit
d1f7d91485
1 changed files with 9 additions and 5 deletions
|
@ -16,6 +16,8 @@ import requests
|
|||
import youtube_dl
|
||||
import configparser
|
||||
import argparse
|
||||
import typing
|
||||
import functools
|
||||
|
||||
from bs4 import BeautifulSoup as bs
|
||||
from discord.ext import tasks, commands
|
||||
|
@ -40,6 +42,7 @@ stream_handler = logging.StreamHandler()
|
|||
stream_handler.setLevel(logging.INFO)
|
||||
logger.addHandler(stream_handler)
|
||||
|
||||
|
||||
class Mybot(commands.Cog):
|
||||
#Fonctions necesaires pour Kabot.
|
||||
def __init__(
|
||||
|
@ -348,11 +351,12 @@ class Mybot(commands.Cog):
|
|||
}],
|
||||
}
|
||||
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
||||
ydl.download([url])
|
||||
info_dict = ydl.extract_info(url, download=False)
|
||||
out_file = ydl.prepare_filename(info_dict)
|
||||
extension = out_file.split('.')[-1]
|
||||
out_file = out_file.replace(extension, 'mp3')
|
||||
if not os.path.isfile(out_file):
|
||||
await asyncio.get_running_loop().run_in_executor(None, ydl.download,[url])
|
||||
self.sounds.append((out_file, ctx))
|
||||
|
||||
@commands.command()
|
||||
|
|
Loading…
Reference in a new issue