Compare commits

...

3 commits

4 changed files with 19 additions and 9 deletions

View file

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

View file

@ -38,7 +38,7 @@ function register_hotkey(hotkey, action, description)
} }
const key = hotkey.pop(); const key = hotkey.pop();
modifiers = hotkey.map(word => word.toLocaleLowerCase()); const modifiers = hotkey.map(word => word.toLocaleLowerCase());
const ctrlKey = modifiers.includes("control") || modifiers.includes("ctrl"); const ctrlKey = modifiers.includes("control") || modifiers.includes("ctrl");
const shiftKey = modifiers.includes("shift"); const shiftKey = modifiers.includes("shift");
const altKey = modifiers.includes("alt"); const altKey = modifiers.includes("alt");
@ -96,7 +96,7 @@ function hotkeys_listener(event)
return; return;
} }
identifier = hotkeys.hotkey_identifier(event.key, event.ctrlKey, event.shiftKey, event.altKey); const identifier = hotkeys.hotkey_identifier(event.key, event.ctrlKey, event.shiftKey, event.altKey);
//console.log(identifier); //console.log(identifier);
if (identifier in hotkeys.HOTKEYS) if (identifier in hotkeys.HOTKEYS)
{ {

View file

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

View file

@ -359,6 +359,12 @@ class YCDLDBVideoMixin:
video.id, video.id,
video.live_broadcast, video.live_broadcast,
) )
# We are not setting the video to ignored, but we'll wait for
# the next refresh to see if this livestream has ended and
# download it then.
return status
if author.ignore_shorts and video.check_is_shorts():
video.mark_state('ignored')
return status return status
# download_video contains a call to mark_state. # download_video contains a call to mark_state.
self.download_video(video.id) self.download_video(video.id)