How to use the ytcc.cli.Action function in ytcc

To help you get started, we’ve selected a few ytcc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github woefe / ytcc / ytcc / cli.py View on Github external
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)}
github woefe / ytcc / ytcc / cli.py View on Github external
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"
github woefe / ytcc / ytcc / cli.py View on Github external
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"
github woefe / ytcc / ytcc / cli.py View on Github external
def set_action(self, action: Action) -> bool:
        self.previous_action = self.action
        self.action = action
        return action in (Action.SHOW_HELP, Action.REFRESH)
github woefe / ytcc / ytcc / cli.py View on Github external
# 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:
github woefe / ytcc / ytcc / cli.py View on Github external
def from_config():
        return Action.__dict__.get(ytcc_core.config.default_action, Action.PLAY_VIDEO)
github woefe / ytcc / ytcc / cli.py View on Github external
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)}
github woefe / ytcc / ytcc / cli.py View on Github external
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()