示例#1
0
    def run(self) -> None:
        alphabet = core.config.quickselect_alphabet
        tags = self._prefix_codes(alphabet, len(self.videos))
        index = OrderedDict(zip(tags, self.videos))

        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.SHOW_HELP:
                self.action = self.previous_action
                terminal.clear_screen()
                print(
                    _("    <F1> Display this help text.\n"
                      "    <F2> Set action: Play video.\n"
                      "    <F3> Set action: Play audio.\n"
                      "    <F4> Set action: Mark as watched.\n"
                      "    <F5> Refresh video list.\n"
                      "    <F6> Set action: Download video.\n"
                      "    <F7> Set action: Download audio.\n"
                      " <Enter> Accept first video.\n"
                      "<CTRL+D> Exit.\n"))
                input(_("Press Enter to continue"))
            elif self.action is Action.REFRESH:
                self.action = self.previous_action
                terminal.clear_screen()
                update_all()
                self.videos = core.list_videos()
                self.run()
                break
示例#2
0
def mark_watched(video_ids: List[int]) -> None:
    core.set_video_id_filter(video_ids)
    videos = core.list_videos()
    if not videos:
        print(_("No videos were marked as downloaded"))
        return

    for video in videos:
        video.watched = True

    print(_("Following videos were marked as downloaded:"))
    print()
    print_videos(videos)
示例#3
0
def list_videos() -> None:
    videos = core.list_videos()
    if not videos:
        print(_("No videos to list. No videos match the given criteria."))
    else:
        print_videos(videos)
示例#4
0
def download(video_ids: List[int]) -> None:
    core.set_video_id_filter(video_ids)
    for video in core.list_videos():
        download_video(video, NO_VIDEO)