App-YTDL

 view release on metacpan or  search on metacpan

lib/App/YTDL/Options.pm  view on Meta::CPAN

    return {
        entries_with_info            => 0,
        filename_format              => 3,
        list_sort_item               => 'upload_date',
        max_info_width               => 120,
        max_processes                => 5,
        max_rows_description         => 3,
        max_size_history             => 50,
        no_height_ok                 => 1,
        no_warnings                  => 0,
        prefer_free_formats          => 1,
        quality                      => 'manually',
        retries                      => 7,
        show_video_id                => 0,
        show_view_count              => 0,
        sort_history_by_timestamp    => 1,
        timeout                      => 60,
        useragent                    => 'Mozilla/5.0',
        use_extractor_dir            => 1,
        use_uploader_dir             => 1,
        video_dir                    => File::HomeDir->my_videos() // File::HomeDir->my_home() // curdir,
        yt_dl_config_location        => undef,
        yt_dl_ignore_config          => 0,
    };
}


sub _main {
    return [
        [ 'show_help_text',          "  HELP"                   ],
        [ 'show_info',               "  INFO"                   ],
        [ 'group_directory',         "- Directories"            ],
        [ 'group_quality',           "- Video format"           ],
        [ 'group_download',          "- Download"               ],
        [ 'group_history',           "- History"                ],
        [ 'group_list_menu',         "- Uploader video list"    ],
        [ 'group_output',            "- Info output"            ],
        [ 'group_yt_dl_config_file', "- Youtube-dl config file" ],
        [ 'avail_extractors',        "  List extractors"        ],
        [ 'extractor_descriptions',  "  Extractor descriptions" ],
    ];
}


sub _groups {
    return {
        group_directory => [
            [ 'video_dir',         "- Main video directory" ],
            [ 'use_extractor_dir', "- Extractor directory"  ],
            [ 'use_uploader_dir',  "- Uploader directory"   ],
            [ 'filename_format',   "- Filename format info" ],
        ],
        group_quality => [
            [ 'quality',             "- Resolution"          ],
            [ 'no_height_ok',        "- No video height"     ],
            [ 'prefer_free_formats', "- Prefer free formats" ],
        ],
        group_download => [
            [ 'useragent',  "- UserAgent"        ],
            [ 'retries',    "- Download retries" ],
            [ 'timeout',    "- Timeout"          ],
        ],
        group_output => [
            [ 'no_warnings',          "- Disable warnings" ],
            [ 'max_info_width',       "- Max info width"   ],
            [ 'max_rows_description', "- Max rows of description" ],
        ],
        group_history => [
            [ 'max_size_history',          "- Size history" ],
            [ 'sort_history_by_timestamp', "- History sort" ],
        ],
        group_list_menu => [
            [ 'entries_with_info', "- Additional info" ],
            [ 'max_processes',     "- Max processes"   ],
            [ 'list_sort_item',    "- Sort order"      ],
            [ 'show_view_count',   "- Show view count" ],
            [ 'show_video_id',     "- Show video id"   ],
        ],
        group_yt_dl_config_file => [
            [ 'yt_dl_config_location',        "- set yt-dl config location"   ],
            [ '_reset_yt_dl_config_location', "- reset yt-dl config location" ],
            [ 'yt_dl_ignore_config',          "- Ignore yt-dl config file"    ],
        ],
    };
}


sub set_options {
    my ( $set, $opt ) = @_;
    my $main = _main();
    my $old_idx_main = 0;

    MAIN_MENU: while ( 1 ) {
        my $back_main     = '  QUIT';
        my $continue_main = '  CONTINUE';
        my @pre  = ( undef, $continue_main );
        my @choices_main = map( $_->[1], @$main );
        my $menu_main = [ @pre, @choices_main ];
        # Choose
        my $idx_main = choose(
            $menu_main,
            { prompt => 'Options:', layout => 3, index => 1, clear_screen => 1,
              undef => $back_main, default => $old_idx_main }
        );
        if ( ! defined $idx_main || ! defined $menu_main->[$idx_main] ) {
            if ( $set->{change} ) {
                _write_config_file( $opt, $set->{config_file} );
                delete $set->{change};
            }
            exit;
        }
        if ( $old_idx_main == $idx_main ) {
            $old_idx_main = 0;
            next MAIN_MENU;
        }
        $old_idx_main = $idx_main;
        my $choice = $menu_main->[$idx_main];
        if ( $choice eq $continue_main ) {
            if ( $set->{change} ) {
                _write_config_file( $opt, $set->{config_file} );
                delete $set->{change};

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.138 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )