minor improvement

This commit is contained in:
voussoir 2017-05-21 13:59:07 -07:00
parent a8faad6573
commit 72e121d585
2 changed files with 8 additions and 6 deletions

View file

@ -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:

View file

@ -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,10 +234,11 @@ 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)
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()