aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEuro20179 <f>2021-03-01 12:33:37 -0800
committerEuro20179 <f>2021-03-01 12:33:37 -0800
commit970654afa380e90e2ed5451b35c8f61fc015fd11 (patch)
treedeacf3ae1a23ad16183d935fd0efc8b25081de78
parentc02131b17ab69b49be5a6c7e8d737c961f761c56 (diff)
downloadytfzf-970654afa380e90e2ed5451b35c8f61fc015fd11.tar.gz
-n flag
-rwxr-xr-xytfzf38
1 files changed, 25 insertions, 13 deletions
diff --git a/ytfzf b/ytfzf
index 9e00fff..e1dbc03 100755
--- a/ytfzf
+++ b/ytfzf
@@ -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
Un proyecto texto-plano.xyz