Add methods Channel.delete and Video.delete.

This commit is contained in:
voussoir 2020-06-18 09:01:05 -07:00
parent 3f9565b874
commit 226bc03bff

View file

@ -23,6 +23,13 @@ class Channel(Base):
self.directory = db_row['directory'] self.directory = db_row['directory']
self.automark = db_row['automark'] or "pending" self.automark = db_row['automark'] or "pending"
def delete(self, commit=True):
self.ycdldb.sql_delete(table='videos', pairs={'author_id': self.id})
self.ycdldb.sql_delete(table='channels', pairs={'id': self.id})
if commit:
self.ycdldb.commit()
def has_pending(self): def has_pending(self):
query = 'SELECT 1 FROM videos WHERE author_id == ? AND download == "pending" LIMIT 1' query = 'SELECT 1 FROM videos WHERE author_id == ? AND download == "pending" LIMIT 1'
bindings = [self.id] bindings = [self.id]
@ -93,6 +100,12 @@ class Video(Base):
except exceptions.NoSuchChannel: except exceptions.NoSuchChannel:
return None return None
def delete(self, commit=True):
self.ycdldb.sql_delete(table='videos', pairs={'id': self.id})
if commit:
self.ycdldb.commit()
def mark_state(self, state, commit=True): def mark_state(self, state, commit=True):
''' '''
Mark the video as ignored, pending, or downloaded. Mark the video as ignored, pending, or downloaded.