ycdl/utilities/download_thumbnails.py

23 lines
575 B
Python
Raw Normal View History

import bot3 as bot
2016-12-07 06:11:09 +00:00
import os
2016-12-13 03:50:41 +00:00
import traceback
import ycdl
2016-12-07 06:11:09 +00:00
from voussoirkit import downloady
2020-01-07 06:01:23 +00:00
youtube_core = ycdl.ytapi.Youtube(bot.get_youtube_key())
ycdldb = ycdl.ycdldb.YCDLDB(youtube_core)
2016-12-13 03:50:41 +00:00
2017-05-21 20:59:07 +00:00
DIRECTORY = '.\\youtube thumbnails'
2016-12-07 06:11:09 +00:00
videos = ycdldb.get_videos()
2016-12-07 06:11:09 +00:00
for video in videos:
2016-12-13 03:50:41 +00:00
try:
thumbnail_path = os.path.join(DIRECTORY, video.id) + '.jpg'
2016-12-13 03:50:41 +00:00
if os.path.exists(thumbnail_path):
continue
result = downloady.download_file(video.thumbnail, thumbnail_path)
2016-12-13 03:50:41 +00:00
print(result)
except Exception as e:
traceback.print_exc()