diff --git a/robot.py b/robot.py index 38c5d33..2f0171c 100755 --- a/robot.py +++ b/robot.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import logging import os +import shutil import sys import requests @@ -13,6 +14,7 @@ logging.basicConfig(level=logging.INFO, logger = logging.getLogger("kunsax") DIR = os.path.dirname(os.path.realpath(__file__)) +TMP_DIR = '/tmp' OUT_DIR = DIR + '/out' @@ -34,10 +36,13 @@ def download_ydl(urls, date): ydl_opts = { 'noplaylist': True, 'download_archive': DIR + '/downloaded.lst', - 'outtmpl': OUT_DIR + '/' + datestr(date) + '__%(title)s__%(id)s.%(ext)s' + '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) def download_raw(url, date):