diff --git a/ycdl/objects.py b/ycdl/objects.py index 9115ac0..dbeef25 100644 --- a/ycdl/objects.py +++ b/ycdl/objects.py @@ -23,6 +23,13 @@ class Channel(Base): self.directory = db_row['directory'] 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): query = 'SELECT 1 FROM videos WHERE author_id == ? AND download == "pending" LIMIT 1' bindings = [self.id] @@ -93,6 +100,12 @@ class Video(Base): except exceptions.NoSuchChannel: 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): ''' Mark the video as ignored, pending, or downloaded.