diff --git a/update_db.py b/update_db.py index 5f43424..3d551a0 100644 --- a/update_db.py +++ b/update_db.py @@ -141,7 +141,6 @@ def update_tables ( api_data: list[VideoResult], now: datetime, ) -> None: - video_ids: list[int] = [] for datum in api_data: tag_names: list[str] = datum['tags'].split () video = VideoDto (code = datum['contentId'], @@ -150,7 +149,6 @@ def update_tables ( uploaded_at = datetime.fromisoformat (datum['startTime'])) video_dao.upsert (video, False) if video.id_ is not None: - video_ids.append (video.id_) video_history = VideoHistoryDto (video_id = video.id_, fetched_at = now, views_count = datum['viewCounter']) @@ -160,7 +158,7 @@ def update_tables ( for vt in video_tags: tag = tag_dao.find (vt.tag_id) if (tag is not None - and (tag.name.upper () not in [tn.upper () for tn in tag_names]) + and (tag.name.upper () not in map (str.upper, tag_names)) and (tag.id_ is not None)): tag_ids.append (tag.id_) video_tag_dao.untag_all (video.id_, tag_ids, now) @@ -535,7 +533,7 @@ class VideoTagDao: video_tags WHERE video_id = %s - AND (untagged_at IS NULL) + AND untagged_at IS NULL ORDER BY id""", (video_id,)) print (c._executed) @@ -562,7 +560,8 @@ class VideoTagDao: video_tags WHERE video_id = %s - AND tag_id = %s""", (video_id, tag_id)) + AND tag_id = %s + AND untagged_at IS NULL""", (video_id, tag_id)) print (c._executed) row = cast (VideoTagRow, c.fetchone ()) if row is None: