From e320952430abad72362837ef493291cca89aeea7 Mon Sep 17 00:00:00 2001 From: girst Date: Mon, 24 Apr 2023 21:59:30 +0000 Subject: [PATCH] [DATABASE CHANGE: Migration below] store is-shorts flag in subscriptions this will allow us to filter shorts from the subscription feed. ALTER TABLE videos ADD COLUMN shorts BOOLEAN DEFAULT NULL; --- app/common/common.py | 12 ++++++++---- config/setup.sql | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/common/common.py b/app/common/common.py index fc5c0b2..32b6b86 100644 --- a/app/common/common.py +++ b/app/common/common.py @@ -129,6 +129,7 @@ def update_channel(db, xmldata, from_webhook=False): length = None livestream = None premiere = None + shorts = None if meta: meta = video_metadata(meta) published2 = dateutil.parser.parse(meta['published']) @@ -137,6 +138,7 @@ def update_channel(db, xmldata, from_webhook=False): length = meta['length'] livestream = meta['livestream'] premiere = meta['premiere'] + shorts = meta['shorts'] now = datetime.now(timezone.utc) @@ -150,8 +152,8 @@ def update_channel(db, xmldata, from_webhook=False): c.execute(""" INSERT OR IGNORE INTO videos - (id, channel_id, title, length, livestream, premiere, published, crawled) - VALUES (?, ?, ?, ?, ?, ?, datetime(?), datetime(?)) + (id, channel_id, title, length, livestream, premiere, shorts, published, crawled) + VALUES (?, ?, ?, ?, ?, ?, ?, datetime(?), datetime(?)) """, ( video['video_id'], video['channel_id'], @@ -159,6 +161,7 @@ def update_channel(db, xmldata, from_webhook=False): length, livestream, premiere, + shorts, published, timestamp )) @@ -374,8 +377,8 @@ def store_video_metadata(video_id): if meta: meta = video_metadata(meta) c.execute(""" - INSERT OR IGNORE INTO videos (id, channel_id, title, length, livestream, premiere, published, crawled) - VALUES (?, ?, ?, ?, ?, ?, datetime(?), datetime(?)) + INSERT OR IGNORE INTO videos (id, channel_id, title, length, livestream, premiere, shorts, published, crawled) + VALUES (?, ?, ?, ?, ?, ?, ?, datetime(?), datetime(?)) """, ( video_id, meta['channel_id'], @@ -383,6 +386,7 @@ def store_video_metadata(video_id): meta['length'], meta['livestream'], meta['premiere'], + meta['shorts'], meta['published'], meta['published'], )) diff --git a/config/setup.sql b/config/setup.sql index 4514e83..1f76da4 100644 --- a/config/setup.sql +++ b/config/setup.sql @@ -21,6 +21,7 @@ CREATE TABLE IF NOT EXISTS videos( length INTEGER, livestream BOOLEAN DEFAULT 0, premiere BOOLEAN DEFAULT 0, + shorts BOOLEAN DEFAULT NULL, published DATETIME, crawled DATETIME DEFAULT CURRENT_TIMESTAMP); CREATE TABLE IF NOT EXISTS playlist_videos( -- 2.39.3