diff options
author | Euro20179 <f> | 2021-03-01 12:33:37 -0800 |
---|---|---|
committer | Euro20179 <f> | 2021-03-01 12:33:37 -0800 |
commit | 970654afa380e90e2ed5451b35c8f61fc015fd11 (patch) | |
tree | deacf3ae1a23ad16183d935fd0efc8b25081de78 | |
parent | c02131b17ab69b49be5a6c7e8d737c961f761c56 (diff) | |
download | ytfzf-970654afa380e90e2ed5451b35c8f61fc015fd11.tar.gz |
-n flag
-rwxr-xr-x | ytfzf | 38 |
1 files changed, 25 insertions, 13 deletions
@@ -275,24 +275,32 @@ scrape_fn () { user_selection () { [ $is_url -eq 1 ] && return format_menu - if [ $auto_select -eq 1 ] ; then - selected_data="$(echo "$videos_data" | sed 1q )" ; - elif [ $random_select -eq 1 ] ; then - selected_data="$(echo "$videos_data" | shuf -n 1)" - elif [ $show_thumbnails -eq 1 ] ; then - dep_ck "ueberzug" - start_ueberzug - selected_data="$(echo "$videos_data" | video_menu_img )" - stop_ueberzug - else - selected_data="$(echo "$videos_data" | video_menu )" - fi + #starts at 1 because when doing -an it selects the first n results (0 is not a result) + i=1 + while [ $i -le $link_count ] + do + if [ $auto_select -eq 1 ] ; then + selected_data="$selected_data\n$(echo "$videos_data" | sed ${i}q | tail -n1)" ; + elif [ $random_select -eq 1 ] ; then + selected_data="$selected_data\n$(echo "$videos_data" | shuf -n 1)" + elif [ $show_thumbnails -eq 1 ] ; then + dep_ck "ueberzug" + start_ueberzug + selected_data="$(echo "$videos_data" | video_menu_img )" + stop_ueberzug + else + selected_data="$selected_data\n$(echo "$videos_data" | video_menu )" + fi + i=$(($i+1)) + done + shorturls="$(echo "$selected_data" | sed -E -e 's_.*\|([^|]+) *$_\1_')" [ -z "$shorturls" ] && exit; urls="" selected_data="" while read surl; do + [ -z "$surl" ] && continue urls="$urls\nhttps://www.youtube.com/watch?v=$surl" # to get back untrucated titles from formatting selected_data="$selected_data\n$(echo "$videos_data" | grep -m1 -e "$surl" )" @@ -354,8 +362,9 @@ auto_select=0 random_select=0 search_again=0 show_format=0 +link_count=1 # OPT -while getopts "LhDmdfxHarltsU:" opt; do +while getopts "LhDmdfxHarltsn:U:" opt; do case ${opt} in h) helpinfo exit; @@ -388,6 +397,9 @@ while getopts "LhDmdfxHarltsU:" opt; do ;; L) show_link_only=1 ;; + n) link_count="$OPTARG" + show_link_only=1 + ;; U) [ -p "$FIFO" ] && preview_img "$OPTARG"; exit; # This option is reserved for the script, to show image previews # Not to be used by explicitly |