ycdl/utilities/download_thumbnails.py
2020-01-06 22:01:23 -08:00

26 lines
656 B
Python

import logging
logging.basicConfig(level=logging.WARNING)
import bot3 as bot
import os
import traceback
import ycdl
import ycdl_repl
from voussoirkit import downloady
youtube_core = ycdl.ytapi.Youtube(bot.get_youtube_key())
youtube = ycdl.YCDL(youtube_core)
DIRECTORY = '.\\youtube thumbnails'
videos = ycdl_repl.ydl.get_videos()
for video in videos:
try:
thumbnail_path = os.path.join(DIRECTORY, video['id']) + '.jpg'
if os.path.exists(thumbnail_path):
continue
result = downloady.download_file(video['thumbnail'], thumbnail_path)
print(result)
except Exception as e:
traceback.print_exc()