ycdl/utilities/download_thumbnails.py

22 lines
488 B
Python
Raw Normal View History

2016-12-07 06:11:09 +00:00
import os
2016-12-13 03:50:41 +00:00
import traceback
2016-12-07 06:11:09 +00:00
from voussoirkit import downloady
import ycdl
2021-10-16 04:00:04 +00:00
ycdldb = ycdl.ycdldb.YCDLDB()
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()