ydl -> ytdl (cosmetics; ocd)

This commit is contained in:
Tomáš Mládek 2019-05-29 13:45:56 +02:00
parent 4c585496a9
commit 12f625a432

View file

@ -175,23 +175,23 @@ class DelojzaBot:
# noinspection PyUnusedLocal # noinspection PyUnusedLocal
def download_ytdl(self, urls, out_path, date, message, audio=False, filetitle=None): def download_ytdl(self, urls, out_path, date, message, audio=False, filetitle=None):
ydl_opts = { ytdl = {
'noplaylist': True, 'noplaylist': True,
'restrictfilenames': True, 'restrictfilenames': True,
'outtmpl': os.path.join(self.tmp_dir, '{}__%(title)s__%(id)s.%(ext)s'.format(datestr(date))) 'outtmpl': os.path.join(self.tmp_dir, '{}__%(title)s__%(id)s.%(ext)s'.format(datestr(date)))
} }
if audio: if audio:
ydl_opts['format'] = 'bestaudio/best' ytdl['format'] = 'bestaudio/best'
ydl_opts['postprocessors'] = [{ ytdl['postprocessors'] = [{
'key': 'FFmpegExtractAudio', 'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3', 'preferredcodec': 'mp3',
'preferredquality': '256' 'preferredquality': '256'
}] }]
filenames = [] filenames = []
with youtube_dl.YoutubeDL(ydl_opts) as ydl: with youtube_dl.YoutubeDL(ytdl) as ytdl:
ydl.download(urls) ytdl.download(urls)
for info in [ydl.extract_info(url, download=False) for url in urls]: for info in [ytdl.extract_info(url, download=False) for url in urls]:
filename = ydl.prepare_filename(info) filename = ytdl.prepare_filename(info)
globbeds = glob(os.path.splitext(filename)[0] + '.*') globbeds = glob(os.path.splitext(filename)[0] + '.*')
for globbed in globbeds: for globbed in globbeds:
if globbed.endswith("mp3"): if globbed.endswith("mp3"):