Move code to new method Video.check_is_shorts.
This commit is contained in:
parent
80236e7a2b
commit
587c8e4976
2 changed files with 11 additions and 7 deletions
|
|
@ -150,16 +150,11 @@ def ignore_shorts_thread(rate):
|
||||||
with ycdldb.transaction:
|
with ycdldb.transaction:
|
||||||
for video in videos:
|
for video in videos:
|
||||||
try:
|
try:
|
||||||
is_shorts = ycdl.ytapi.video_is_shorts(video.id)
|
if video.check_is_shorts():
|
||||||
|
video.mark_state('ignored')
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
log.warning(traceback.format_exc())
|
log.warning(traceback.format_exc())
|
||||||
continue
|
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)
|
time.sleep(rate)
|
||||||
|
|
||||||
def start_refresher_thread(rate):
|
def start_refresher_thread(rate):
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ log = vlogging.getLogger(__name__)
|
||||||
|
|
||||||
from . import constants
|
from . import constants
|
||||||
from . import exceptions
|
from . import exceptions
|
||||||
|
from . import ytapi
|
||||||
from . import ytrss
|
from . import ytrss
|
||||||
|
|
||||||
class ObjectBase(worms.Object):
|
class ObjectBase(worms.Object):
|
||||||
|
|
@ -369,6 +370,14 @@ class Video(ObjectBase):
|
||||||
except exceptions.NoSuchChannel:
|
except exceptions.NoSuchChannel:
|
||||||
return None
|
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
|
@worms.atomic
|
||||||
def delete(self):
|
def delete(self):
|
||||||
log.info('Deleting %s.', self)
|
log.info('Deleting %s.', self)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue