From 587c8e4976230e4e6e27169ac328ff3a383eef9e Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 8 Mar 2026 14:33:51 -0700 Subject: [PATCH] Move code to new method Video.check_is_shorts. --- frontends/ycdl_flask/backend/common.py | 9 ++------- ycdl/objects.py | 9 +++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/frontends/ycdl_flask/backend/common.py b/frontends/ycdl_flask/backend/common.py index 2d651db..d6b1ea5 100644 --- a/frontends/ycdl_flask/backend/common.py +++ b/frontends/ycdl_flask/backend/common.py @@ -150,16 +150,11 @@ def ignore_shorts_thread(rate): with ycdldb.transaction: for video in videos: try: - is_shorts = ycdl.ytapi.video_is_shorts(video.id) + if video.check_is_shorts(): + video.mark_state('ignored') except Exception as exc: log.warning(traceback.format_exc()) continue - video.is_shorts = is_shorts - pairs = {'id': video.id, 'is_shorts': int(is_shorts)} - if is_shorts: - pairs['state'] = 'ignored' - video.state = 'ignored' - ycdldb.update(table=ycdl.objects.Video, pairs=pairs, where_key='id') time.sleep(rate) def start_refresher_thread(rate): diff --git a/ycdl/objects.py b/ycdl/objects.py index 16fe3aa..f9874b2 100644 --- a/ycdl/objects.py +++ b/ycdl/objects.py @@ -12,6 +12,7 @@ log = vlogging.getLogger(__name__) from . import constants from . import exceptions +from . import ytapi from . import ytrss class ObjectBase(worms.Object): @@ -369,6 +370,14 @@ class Video(ObjectBase): except exceptions.NoSuchChannel: return None + @worms.atomic + def check_is_shorts(self): + is_shorts = ytapi.video_is_shorts(self.id) + self.is_shorts = is_shorts + pairs = {'id': self.id, 'is_shorts': int(is_shorts)} + self.ycdldb.update(table=Video, pairs=pairs, where_key='id') + return is_shorts + @worms.atomic def delete(self): log.info('Deleting %s.', self)