diff --git a/download_thumbnails.py b/download_thumbnails.py index eb1e52c..51b2710 100644 --- a/download_thumbnails.py +++ b/download_thumbnails.py @@ -3,13 +3,13 @@ import os import traceback import ycdl import ytapi - +import ycdl_repl from voussoirkit import downloady youtube_core = ytapi.Youtube(bot.YOUTUBE_KEY) youtube = ycdl.YCDL(youtube_core) -DIRECTORY = 'C:\\users\\owner\\youtube thumbnails' +DIRECTORY = '.\\youtube thumbnails' videos = ycdl_repl.youtube.get_videos() for video in videos: diff --git a/ycdl.py b/ycdl.py index 9edec9f..4c52785 100644 --- a/ycdl.py +++ b/ycdl.py @@ -106,13 +106,14 @@ class YCDL: statements = DB_INIT.split(';') for statement in statements: self.cur.execute(statement) + self.sql.commit() def add_channel( self, channel_id, - commit=False, + commit=True, download_directory=None, - get_videos=True, + get_videos=False, name=None, ): if self.get_channel(channel_id) is not None: @@ -233,11 +234,12 @@ class YCDL: videos.sort(key=lambda x: x['published'], reverse=True) return videos - def insert_video(self, video, commit=True): + def insert_video(self, video, *, add_channel=True, commit=True): if not isinstance(video, ytapi.Video): video = self.youtube.get_video(video) - self.add_channel(video.author_id, get_videos=False, commit=False) + if add_channel: + self.add_channel(video.author_id, get_videos=False, commit=False) self.cur.execute('SELECT * FROM videos WHERE id == ?', [video.id]) fetch = self.cur.fetchone() if fetch is not None: