Move code to new method Video.check_is_shorts.

This commit is contained in:
voussoir 2026-03-08 14:33:51 -07:00
parent 80236e7a2b
commit 587c8e4976
2 changed files with 11 additions and 7 deletions

View file

@ -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):

View file

@ -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)