Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, videos: List[Video]):
self.videos = videos
self.previous_action = Action.PLAY_AUDIO if NO_VIDEO else Action.from_config()
self.action = self.previous_action
def makef(arg):
return lambda: self.set_action(arg)
self.hooks = {action.hotkey: makef(action) for action in list(Action)}
tag, hook_triggered = self.command_line(remaining_tags, alphabet)
video = index.get(tag)
if video is None and not hook_triggered:
break
if video is not None:
if self.action is Action.MARK_WATCHED:
video.watched = True
del index[tag]
elif self.action is Action.DOWNLOAD_AUDIO:
print()
download_video(video, True)
del index[tag]
elif self.action is Action.DOWNLOAD_VIDEO:
print()
download_video(video, False)
del index[tag]
elif self.action is Action.PLAY_AUDIO:
print()
play(video, True)
del index[tag]
elif self.action is Action.PLAY_VIDEO:
print()
play(video, False)
del index[tag]
elif self.action is Action.SHOW_HELP:
self.action = self.previous_action
terminal.clear_screen()
print(_(
" Display this help text.\n"
if self.action is Action.MARK_WATCHED:
video.watched = True
del index[tag]
elif self.action is Action.DOWNLOAD_AUDIO:
print()
download_video(video, True)
del index[tag]
elif self.action is Action.DOWNLOAD_VIDEO:
print()
download_video(video, False)
del index[tag]
elif self.action is Action.PLAY_AUDIO:
print()
play(video, True)
del index[tag]
elif self.action is Action.PLAY_VIDEO:
print()
play(video, False)
del index[tag]
elif self.action is Action.SHOW_HELP:
self.action = self.previous_action
terminal.clear_screen()
print(_(
" Display this help text.\n"
" Set action: Play video.\n"
" Set action: Play audio.\n"
" Set action: Mark as watched.\n"
" Refresh video list.\n"
" Set action: Download video.\n"
" Set action: Download audio.\n"
" Accept first video.\n"
" Exit.\n"
def set_action(self, action: Action) -> bool:
self.previous_action = self.action
self.action = action
return action in (Action.SHOW_HELP, Action.REFRESH)
# Clear display and set cursor to (1,1). Allows scrolling back in some terminals
terminal.clear_screen()
print_videos(remaining_videos, quickselect_column=remaining_tags)
tag, hook_triggered = self.command_line(remaining_tags, alphabet)
video = index.get(tag)
if video is None and not hook_triggered:
break
if video is not None:
if self.action is Action.MARK_WATCHED:
video.watched = True
del index[tag]
elif self.action is Action.DOWNLOAD_AUDIO:
print()
download_video(video, True)
del index[tag]
elif self.action is Action.DOWNLOAD_VIDEO:
print()
download_video(video, False)
del index[tag]
elif self.action is Action.PLAY_AUDIO:
print()
play(video, True)
del index[tag]
elif self.action is Action.PLAY_VIDEO:
print()
play(video, False)
del index[tag]
elif self.action is Action.SHOW_HELP:
def from_config():
return Action.__dict__.get(ytcc_core.config.default_action, Action.PLAY_VIDEO)
def __init__(self, videos: List[Video]):
self.videos = videos
self.previous_action = Action.PLAY_AUDIO if NO_VIDEO else Action.from_config()
self.action = self.previous_action
def makef(arg):
return lambda: self.set_action(arg)
self.hooks = {action.hotkey: makef(action) for action in list(Action)}
while index:
remaining_tags = list(index.keys())
remaining_videos = index.values()
# Clear display and set cursor to (1,1). Allows scrolling back in some terminals
terminal.clear_screen()
print_videos(remaining_videos, quickselect_column=remaining_tags)
tag, hook_triggered = self.command_line(remaining_tags, alphabet)
video = index.get(tag)
if video is None and not hook_triggered:
break
if video is not None:
if self.action is Action.MARK_WATCHED:
video.watched = True
del index[tag]
elif self.action is Action.DOWNLOAD_AUDIO:
print()
download_video(video, True)
del index[tag]
elif self.action is Action.DOWNLOAD_VIDEO:
print()
download_video(video, False)
del index[tag]
elif self.action is Action.PLAY_AUDIO:
print()
play(video, True)
del index[tag]
elif self.action is Action.PLAY_VIDEO:
print()