diff --git a/robot.py b/robot.py index 2f0171c..5e33ac1 100755 --- a/robot.py +++ b/robot.py @@ -3,6 +3,7 @@ import logging import os import shutil import sys +from glob import glob import requests import youtube_dl @@ -35,14 +36,17 @@ def datestr(date): def download_ydl(urls, date): ydl_opts = { 'noplaylist': True, + 'restrictfilenames': True, 'download_archive': DIR + '/downloaded.lst', 'outtmpl': TMP_DIR + '/' + datestr(date) + '__%(title)s__%(id)s.%(ext)s' } with youtube_dl.YoutubeDL(ydl_opts) as ydl: ydl.download(urls) for filename in map(ydl.prepare_filename, map(ydl.extract_info, urls)): - logger.info("Moving %s to %s..." % (filename, OUT_DIR)) - shutil.move(filename, OUT_DIR) + globbeds = glob(os.path.splitext(filename)[0] + '.*') + for globbed in globbeds: + logger.info("Moving %s to %s..." % (globbed, OUT_DIR)) + shutil.move(globbed, OUT_DIR) def download_raw(url, date):