diff options
Diffstat (limited to 'gnu/packages/patches/ytfzf-programs.patch')
| -rw-r--r-- | gnu/packages/patches/ytfzf-programs.patch | 643 |
1 files changed, 643 insertions, 0 deletions
diff --git a/gnu/packages/patches/ytfzf-programs.patch b/gnu/packages/patches/ytfzf-programs.patch new file mode 100644 index 00000000000..005ce2cf996 --- /dev/null +++ b/gnu/packages/patches/ytfzf-programs.patch | |||
| @@ -0,0 +1,643 @@ | |||
| 1 | From 3f1eaf5a1645b28ca18cfa028417dc225b7a557f Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Raghav Gururajan <rg@raghavgururajan.name> | ||
| 3 | Date: Mon, 5 Jul 2021 06:45:49 -0400 | ||
| 4 | Subject: [PATCH] Modify the strings of referenced programs. | ||
| 5 | |||
| 6 | Pattern the strings of referenced programs, so that they can be easily | ||
| 7 | substituted with absolute paths using a custom-phase. | ||
| 8 | |||
| 9 | Co-authored-by: jgart <jgart@dismail.de> | ||
| 10 | --- | ||
| 11 | ytfzf | 198 +++++++++++++++++++++++++++++----------------------------- | ||
| 12 | 1 file changed, 99 insertions(+), 99 deletions(-) | ||
| 13 | |||
| 14 | diff --git a/ytfzf b/ytfzf | ||
| 15 | index f4d2e0d..e8bb60b 100755 | ||
| 16 | --- a/ytfzf | ||
| 17 | +++ b/ytfzf | ||
| 18 | @@ -49,17 +49,17 @@ cache_dir=${YTFZF_CACHE-${cache_dir-$HOME/.cache/ytfzf}} | ||
| 19 | #video type preference (mp4/1080p, mp4/720p, etc..) | ||
| 20 | video_pref=${YTFZF_PREF-${video_pref-}} | ||
| 21 | #the menu to use instead of fzf when -D is specified | ||
| 22 | -external_menu=${YTFZF_EXTMENU-${external_menu-dmenu -i -l 30 -p Search:}} | ||
| 23 | +external_menu=${YTFZF_EXTMENU-${external_menu-@dmenu@ -i -l 30 -p Search:}} | ||
| 24 | #number of columns (characters on a line) the external menu can have | ||
| 25 | #necessary for formatting text for external menus | ||
| 26 | external_menu_len=${YTFZF_EXTMENU_LEN-${external_menu_len-220}} | ||
| 27 | #player settings (players need to support streaming with youtube-dl) | ||
| 28 | #player to use for watching the video | ||
| 29 | -video_player=${YTFZF_PLAYER-${video_player-mpv}} | ||
| 30 | +video_player=${YTFZF_PLAYER-${video_player-@mpv@}} | ||
| 31 | #if YTFZF_PREF is specified, use this player instead | ||
| 32 | -video_player_format=${YTFZF_PLAYER_FORMAT-${video_player_format-mpv --ytdl-format=}} | ||
| 33 | +video_player_format=${YTFZF_PLAYER_FORMAT-${video_player_format-@mpv@ --ytdl-format=}} | ||
| 34 | #player to use for audio only | ||
| 35 | -audio_player=${YTFZF_AUDIO_PLAYER-${audio_player-mpv --no-video}} | ||
| 36 | +audio_player=${YTFZF_AUDIO_PLAYER-${audio_player-@mpv@ --no-video}} | ||
| 37 | #the command to use for displaying thumbnails | ||
| 38 | thumb_disp_method=${YTFZF_THUMB_DISP_METHOD-${thumb_disp_method-ueberzug}} | ||
| 39 | #Storing the argument and location for autogenerated subtitles | ||
| 40 | @@ -85,8 +85,8 @@ subscriptions_file=${subscriptions_file-$config_dir/subscriptions} | ||
| 41 | #> stores the pid of running ytfzf sessions | ||
| 42 | pid_file="$cache_dir/.pid" | ||
| 43 | #> make folders that don't exist | ||
| 44 | -[ -d "$cache_dir" ] || mkdir -p "$cache_dir" | ||
| 45 | -[ -d "$thumb_dir" ] || mkdir -p "$thumb_dir" | ||
| 46 | +[ -d "$cache_dir" ] || @mkdir@ -p "$cache_dir" | ||
| 47 | +[ -d "$thumb_dir" ] || @mkdir@ -p "$thumb_dir" | ||
| 48 | |||
| 49 | #> config settings | ||
| 50 | #list of shortcuts to use in fzf | ||
| 51 | @@ -177,12 +177,12 @@ dep_ck () { | ||
| 52 | done | ||
| 53 | unset Dep | ||
| 54 | } | ||
| 55 | -dep_ck "jq" "youtube-dl" "curl" | ||
| 56 | +dep_ck "@jq@" "@youtube-dl@" "@curl@" | ||
| 57 | |||
| 58 | |||
| 59 | #only check for mpv if $YTFZF_PLAYER is set to it | ||
| 60 | #don't check $YTFZF_PLAYER as it could be multiple commands | ||
| 61 | -[ "$video_player" = "mpv" ] && dep_ck "mpv" | ||
| 62 | +[ "$video_player" = "@mpv@" ] && dep_ck "@mpv@" | ||
| 63 | |||
| 64 | ############################ | ||
| 65 | # Help Texts # | ||
| 66 | @@ -326,8 +326,8 @@ print_info () { | ||
| 67 | } | ||
| 68 | |||
| 69 | print_error () { | ||
| 70 | - [ $ext_menu_notifs -eq 1 ] && notify-send "error" "$*" || printf "\033[31m$*\033[0m" >&2 | ||
| 71 | - [ $ext_menu_notifs -eq 1 ] && notify-send "Check for new versions and report at: https://github.com/pystardust/ytfzf\n" || printf "Check for new versions and report at: https://github.com/pystardust/ytfzf\n" >&2 | ||
| 72 | + [ $ext_menu_notifs -eq 1 ] && @notify-send@ "error" "$*" || printf "\033[31m$*\033[0m" >&2 | ||
| 73 | + [ $ext_menu_notifs -eq 1 ] && @notify-send@ "Check for new versions and report at: https://github.com/pystardust/ytfzf\n" || printf "Check for new versions and report at: https://github.com/pystardust/ytfzf\n" >&2 | ||
| 74 | } | ||
| 75 | |||
| 76 | ############################ | ||
| 77 | @@ -398,12 +398,12 @@ format_fzf () { | ||
| 78 | format_menu () { | ||
| 79 | if [ "$is_ext_menu" -eq 0 ]; then | ||
| 80 | #dep_ck fzf here because it is only necessary to use here | ||
| 81 | - dep_ck "fzf" | ||
| 82 | - menu_command='column -t -s "$tab_space" | fzf -m --bind change:top --tabstop=1 --layout=reverse --delimiter="$tab_space" --nth=1,2 --expect="$shortcuts" $FZF_DEFAULT_OPTS' | ||
| 83 | + dep_ck "@fzf@" | ||
| 84 | + menu_command='@column@ -t -s "$tab_space" | @fzf@ -m --bind change:top --tabstop=1 --layout=reverse --delimiter="$tab_space" --nth=1,2 --expect="$shortcuts" $FZF_DEFAULT_OPTS' | ||
| 85 | format_fzf | ||
| 86 | else | ||
| 87 | # Dmenu doesn't render tabs so removing it | ||
| 88 | - menu_command='tr -d "$tab_space" | '"$external_menu" | ||
| 89 | + menu_command='@tr@ -d "$tab_space" | '"$external_menu" | ||
| 90 | format_ext_menu | ||
| 91 | fi | ||
| 92 | } | ||
| 93 | @@ -461,13 +461,13 @@ ID="ytfzf-ueberzug" | ||
| 94 | WIDTH=$FZF_PREVIEW_COLUMNS | ||
| 95 | HEIGHT=$FZF_PREVIEW_LINES | ||
| 96 | start_ueberzug () { | ||
| 97 | - [ -e $FIFO ] || { mkfifo "$FIFO" || exit 1 ; } | ||
| 98 | - ueberzug layer --parser json --silent < "$FIFO" & | ||
| 99 | + [ -e $FIFO ] || { @mkfifo@ "$FIFO" || exit 1 ; } | ||
| 100 | + @ueberzug@ layer --parser json --silent < "$FIFO" & | ||
| 101 | exec 3>"$FIFO" | ||
| 102 | } | ||
| 103 | stop_ueberzug () { | ||
| 104 | exec 3>&- | ||
| 105 | - rm "$FIFO" > /dev/null 2>&1 | ||
| 106 | + @rm@ "$FIFO" > /dev/null 2>&1 | ||
| 107 | } | ||
| 108 | |||
| 109 | preview_img () { | ||
| 110 | @@ -476,12 +476,12 @@ preview_img () { | ||
| 111 | shorturl=${args##*${tab_space}|} | ||
| 112 | shorturl="${shorturl%% *}" | ||
| 113 | |||
| 114 | - json_obj=$(printf "%s" "$videos_json" | jq '.[]|select( .videoID == "'"$shorturl"'")') | ||
| 115 | + json_obj=$(printf "%s" "$videos_json" | @jq@ '.[]|select( .videoID == "'"$shorturl"'")') | ||
| 116 | |||
| 117 | |||
| 118 | IFS=$tab_space read -r title channel duration views date description <<-EOF | ||
| 119 | $( | ||
| 120 | - printf "%s" "$json_obj" | jq -r \ | ||
| 121 | + printf "%s" "$json_obj" | @jq@ -r \ | ||
| 122 | ' | ||
| 123 | [.title,.channel,.duration,.views,.date,.description]|@tsv | ||
| 124 | ' | ||
| 125 | @@ -530,31 +530,31 @@ preview_img () { | ||
| 126 | } > "$FIFO" ;; | ||
| 127 | catimg) | ||
| 128 | printf "\n" | ||
| 129 | - catimg -w "$((thumb_width * 2))" "$IMAGE" ;; | ||
| 130 | + @catimg@ -w "$((thumb_width * 2))" "$IMAGE" ;; | ||
| 131 | jp2a) | ||
| 132 | printf "\n" | ||
| 133 | - jp2a --size="${thumb_width}x$((thumb_height / 2))" --colors --color-depth=24 "$IMAGE" ;; | ||
| 134 | + @jp2a@ --size="${thumb_width}x$((thumb_height / 2))" --colors --color-depth=24 "$IMAGE" ;; | ||
| 135 | jp2a-8) | ||
| 136 | printf "\n" | ||
| 137 | - jp2a --size="${thumb_width}x$((thumb_height / 2))" --colors --color-depth=8 "$IMAGE" ;; | ||
| 138 | + @jp2a@ --size="${thumb_width}x$((thumb_height / 2))" --colors --color-depth=8 "$IMAGE" ;; | ||
| 139 | jp2a-4) | ||
| 140 | printf "\n" | ||
| 141 | - jp2a --size="${thumb_width}x$((thumb_height / 2))" --colors --color-depth=4 "$IMAGE" ;; | ||
| 142 | + @jp2a@ --size="${thumb_width}x$((thumb_height / 2))" --colors --color-depth=4 "$IMAGE" ;; | ||
| 143 | jp2a-gray|jp2a-grey) | ||
| 144 | printf "\n" | ||
| 145 | - jp2a --size="${thumb_width}x$((thumb_height / 2))" "$IMAGE" ;; | ||
| 146 | + @jp2a@ --size="${thumb_width}x$((thumb_height / 2))" "$IMAGE" ;; | ||
| 147 | chafa) | ||
| 148 | printf "\n" | ||
| 149 | - chafa --size="${thumb_width}x${thumb_height}" "$IMAGE" ;; | ||
| 150 | + @chafa@ --size="${thumb_width}x${thumb_height}" "$IMAGE" ;; | ||
| 151 | chafa-gray|chafa-grey) | ||
| 152 | printf "\n" | ||
| 153 | - chafa --size="${thumb_width}x${thumb_height}" --colors=2 "$IMAGE" ;; | ||
| 154 | + @chafa@ --size="${thumb_width}x${thumb_height}" --colors=2 "$IMAGE" ;; | ||
| 155 | chafa-4) | ||
| 156 | printf "\n" | ||
| 157 | - chafa --size="${thumb_width}x${thumb_height}" --colors=16 "$IMAGE" ;; | ||
| 158 | + @chafa@ --size="${thumb_width}x${thumb_height}" --colors=16 "$IMAGE" ;; | ||
| 159 | chafa-8) | ||
| 160 | printf "\n" | ||
| 161 | - chafa --size="${thumb_width}x${thumb_height}" --colors=256 "$IMAGE" ;; | ||
| 162 | + @chafa@ --size="${thumb_width}x${thumb_height}" --colors=256 "$IMAGE" ;; | ||
| 163 | custom) | ||
| 164 | if ! function_exists "handle_display_img"; then | ||
| 165 | printf "\033[031mERROR[#07]: \033[0m\033[1mhandle_display_img\033[0m is not defined" >&2 | ||
| 166 | @@ -585,20 +585,20 @@ download_thumbnails () { | ||
| 167 | if [ "$thumbnail_quality" -eq 1 ]; then | ||
| 168 | image_download () { | ||
| 169 | # higher quality images | ||
| 170 | - curl -s "$Url" -G --data-urlencode "sqp=" > "$thumb_dir/$Name.png" | ||
| 171 | + @curl@ -s "$Url" -G --data-urlencode "sqp=" > "$thumb_dir/$Name.png" | ||
| 172 | } | ||
| 173 | else | ||
| 174 | image_download () { | ||
| 175 | - curl -s "$Url" > "$thumb_dir/$Name.png" | ||
| 176 | + @curl@ -s "$Url" > "$thumb_dir/$Name.png" | ||
| 177 | } | ||
| 178 | fi | ||
| 179 | |||
| 180 | print_info "Downloading Thumbnails...\n" | ||
| 181 | thumb_urls=$(printf "%s" "$*" |\ | ||
| 182 | - jq -r '.[]|[.thumbs,.videoID]|@tsv' ) | ||
| 183 | + @jq@ -r '.[]|[.thumbs,.videoID]|@tsv' ) | ||
| 184 | |||
| 185 | while IFS=$tab_space read -r Url Name; do | ||
| 186 | - sleep 0.001 | ||
| 187 | + @sleep@ 0.001 | ||
| 188 | { | ||
| 189 | image_download | ||
| 190 | } & | ||
| 191 | @@ -628,7 +628,7 @@ get_sp_filter () { | ||
| 192 | #another example is sort by filter + upload date filter only changes one character as well | ||
| 193 | if [ -n "$filter_id" ]; then | ||
| 194 | #gets the character in the filter_id that needs to be replaced if upload_date_filter is also given | ||
| 195 | - upload_date_character=$(printf "%s" "$filter_id" | awk '{print substr($1, 8, 1)}') | ||
| 196 | + upload_date_character=$(printf "%s" "$filter_id" | @awk@ '{print substr($1, 8, 1)}') | ||
| 197 | fi | ||
| 198 | |||
| 199 | #For each of these, if upload_date_character is unset, the filter_id should be the normal filter | ||
| 200 | @@ -650,7 +650,7 @@ get_sp_filter () { | ||
| 201 | if [ -n "$upload_date_character" ]; then | ||
| 202 | #replaces the 8th character in the filter_id with the appropriate character | ||
| 203 | #the 8th character specifies the upload_date_filter | ||
| 204 | - sp=$(printf "%s" "$filter_id" | sed 's/\(.\{7\}\)./\1'"$upload_date_character"'/') | ||
| 205 | + sp=$(printf "%s" "$filter_id" | @sed@ 's/\(.\{7\}\)./\1'"$upload_date_character"'/') | ||
| 206 | #otherwise set it to the filter_id | ||
| 207 | else | ||
| 208 | sp=$filter_id | ||
| 209 | @@ -660,15 +660,15 @@ get_sp_filter () { | ||
| 210 | |||
| 211 | get_yt_json () { | ||
| 212 | # scrapes the json embedded in the youtube html page | ||
| 213 | - printf "%s" "$*" | sed -n '/var *ytInitialData/,$p' | tr -d '\n' |\ | ||
| 214 | - sed -E ' s_^.*var ytInitialData ?=__ ; s_;</script>.*__ ;' | ||
| 215 | + printf "%s" "$*" | @sed@ -n '/var *ytInitialData/,$p' | @tr@ -d '\n' |\ | ||
| 216 | + @sed@ -E ' s_^.*var ytInitialData ?=__ ; s_;</script>.*__ ;' | ||
| 217 | } | ||
| 218 | |||
| 219 | get_yt_html () { | ||
| 220 | link=$1 | ||
| 221 | query=$2 | ||
| 222 | printf "%s" "$( | ||
| 223 | - curl "$link" -s \ | ||
| 224 | + @curl@ "$link" -s \ | ||
| 225 | -G --data-urlencode "search_query=$query" \ | ||
| 226 | -G --data-urlencode "sp=$sp" \ | ||
| 227 | -H 'Authority: www.youtube.com' \ | ||
| 228 | @@ -684,7 +684,7 @@ get_video_data () { | ||
| 229 | # outputs tab and pipe separated fields: title, channel, view count, video length, video upload date, and the video id/url | ||
| 230 | # from the videos_json | ||
| 231 | printf "%s" "$*" |\ | ||
| 232 | - jq -r '.[]| "\(.title)'"$tab_space"'|\(.channel)'"$tab_space"'|\(.views)'"$tab_space"'|\(.duration)'"$tab_space"'|\(.date)'"$tab_space"'|\(.videoID)"' | ||
| 233 | + @jq@ -r '.[]| "\(.title)'"$tab_space"'|\(.channel)'"$tab_space"'|\(.views)'"$tab_space"'|\(.duration)'"$tab_space"'|\(.date)'"$tab_space"'|\(.videoID)"' | ||
| 234 | } | ||
| 235 | |||
| 236 | scrape_channel () { | ||
| 237 | @@ -694,7 +694,7 @@ scrape_channel () { | ||
| 238 | channel_url=$* | ||
| 239 | |||
| 240 | # Converting channel title page url to channel video url | ||
| 241 | - if ! printf "%s" "$channel_url" | grep -q '/videos *$'; then | ||
| 242 | + if ! printf "%s" "$channel_url" | @grep@ -q '/videos *$'; then | ||
| 243 | channel_url=${channel_url%/featured}/videos | ||
| 244 | fi | ||
| 245 | |||
| 246 | @@ -706,8 +706,8 @@ scrape_channel () { | ||
| 247 | fi | ||
| 248 | |||
| 249 | #gets the channel name from title of page | ||
| 250 | - channel_name=$(printf "%s" "$yt_html" | grep -o '<title>.*</title>' | | ||
| 251 | - sed \ | ||
| 252 | + channel_name=$(printf "%s" "$yt_html" | @grep@ -o '<title>.*</title>' | | ||
| 253 | + @sed@ \ | ||
| 254 | -e 's/ - YouTube//' \ | ||
| 255 | -e 's/<\/\?title>//g' \ | ||
| 256 | -e "s/'/'/g" \ | ||
| 257 | @@ -723,7 +723,7 @@ scrape_channel () { | ||
| 258 | |||
| 259 | #gets a list of videos | ||
| 260 | videos_json=$(printf "%s" "$yt_json" |\ | ||
| 261 | - jq '[ .contents | ..|.gridVideoRenderer? | | ||
| 262 | + @jq@ '[ .contents | ..|.gridVideoRenderer? | | ||
| 263 | select(. !=null) | | ||
| 264 | { | ||
| 265 | title: .title.runs[0].text, | ||
| 266 | @@ -736,7 +736,7 @@ scrape_channel () { | ||
| 267 | } | ||
| 268 | ]') | ||
| 269 | |||
| 270 | - videos_json=$(printf "%s" "$videos_json" | jq '.[0:'$sub_link_count']') | ||
| 271 | + videos_json=$(printf "%s" "$videos_json" | @jq@ '.[0:'$sub_link_count']') | ||
| 272 | printf "%s\n" "$videos_json" >> "$tmp_video_json_file" | ||
| 273 | #checks if it's empty in case it was defined in a config function eg: on_get_search | ||
| 274 | [ -z "$videos_data" ] && videos_data=$(get_video_data "$videos_json") | ||
| 275 | @@ -768,11 +768,11 @@ get_trending_url_data () { | ||
| 276 | scrape_pt () { | ||
| 277 | #gets a list of videos | ||
| 278 | pt_json=$( | ||
| 279 | - curl \ | ||
| 280 | + @curl@ \ | ||
| 281 | -s "https://sepiasearch.org/api/v1/search/videos" \ | ||
| 282 | -G --data-urlencode "search=$*") | ||
| 283 | videos_json=$(printf "%s" "$pt_json" |\ | ||
| 284 | - jq '[ .data | .[] | | ||
| 285 | + @jq@ '[ .data | .[] | | ||
| 286 | { | ||
| 287 | title: .name, | ||
| 288 | channel: .channel.displayName, | ||
| 289 | @@ -829,7 +829,7 @@ scrape_yt () { | ||
| 290 | fi | ||
| 291 | |||
| 292 | #gets a list of videos | ||
| 293 | - videos_json=$(printf "%s" "$yt_json" | jq '[ .contents| | ||
| 294 | + videos_json=$(printf "%s" "$yt_json" | @jq@ '[ .contents| | ||
| 295 | ..|.videoRenderer? | | ||
| 296 | select(. !=null) | | ||
| 297 | { | ||
| 298 | @@ -844,7 +844,7 @@ scrape_yt () { | ||
| 299 | } | ||
| 300 | ]') | ||
| 301 | |||
| 302 | - playlist_json=$(printf "%s" "$yt_json" | jq '[ .contents| | ||
| 303 | + playlist_json=$(printf "%s" "$yt_json" | @jq@ '[ .contents| | ||
| 304 | ..|.playlistRenderer? | | ||
| 305 | select(. !=null) | | ||
| 306 | { | ||
| 307 | @@ -904,28 +904,28 @@ get_search_query () { | ||
| 308 | #> To select videos from videos_data | ||
| 309 | user_selection () { | ||
| 310 | #remove subscription separators | ||
| 311 | - videos_data_clean=$(printf "%s" "$videos_data" | sed "/.*$tab_space$/d") | ||
| 312 | + videos_data_clean=$(printf "%s" "$videos_data" | @sed@ "/.*$tab_space$/d") | ||
| 313 | |||
| 314 | #$selected_data is the video the user picked | ||
| 315 | #picks the first n videos | ||
| 316 | if [ "$select_all" -eq 1 ] ; then | ||
| 317 | selected_data=$videos_data_clean | ||
| 318 | elif [ "$auto_select" -eq 1 ] ; then | ||
| 319 | - selected_data=$(printf "%s\n" "$videos_data_clean" | sed "${link_count}"q ) | ||
| 320 | + selected_data=$(printf "%s\n" "$videos_data_clean" | @sed@ "${link_count}"q ) | ||
| 321 | #picks n random videos | ||
| 322 | elif [ "$random_select" -eq 1 ] ; then | ||
| 323 | - selected_data=$(printf "%s\n" "$videos_data_clean" | posix_shuf | head -n${link_count}) | ||
| 324 | + selected_data=$(printf "%s\n" "$videos_data_clean" | posix_shuf | @head@ -n${link_count}) | ||
| 325 | #posix_shuf, pick the first $link_count videos | ||
| 326 | |||
| 327 | #show thumbnail menu | ||
| 328 | elif [ "$show_thumbnails" -eq 1 ] ; then | ||
| 329 | - dep_ck "ueberzug" "fzf" | ||
| 330 | + dep_ck "@ueberzug@" "@fzf@" | ||
| 331 | export YTFZF_THUMB_DISP_METHOD="$thumb_disp_method" | ||
| 332 | [ "$thumb_disp_method" = "ueberzug" ] && start_ueberzug | ||
| 333 | #thumbnails only work in fzf, use fzf | ||
| 334 | - menu_command="fzf -m --tabstop=1 --bind change:top --delimiter=\"$tab_space\" \ | ||
| 335 | + menu_command="@fzf@ -m --tabstop=1 --bind change:top --delimiter=\"$tab_space\" \ | ||
| 336 | --nth=1,2 --expect='$shortcuts' $FZF_DEFAULT_OPTS \ | ||
| 337 | - --layout=reverse --preview \"sh $0 -U {}\" \ | ||
| 338 | + --layout=reverse --preview \"@sh@ $0 -U {}\" \ | ||
| 339 | --preview-window \"$PREVIEW_SIDE:50%:noborder:wrap\"" | ||
| 340 | selected_data=$( title_len=200 video_menu "$videos_data" ) | ||
| 341 | [ "$thumb_disp_method" = "ueberzug" ] && stop_ueberzug | ||
| 342 | @@ -951,10 +951,10 @@ handle_shortcuts () { | ||
| 343 | case $selected_key in | ||
| 344 | "$urls_shortcut") printf "%s\n" $selected_urls; return 1 ;; | ||
| 345 | "$title_shortcut") | ||
| 346 | - printf "%s\n" "$selected_data" | awk -F " " '{print $1}'; return 1 ;; | ||
| 347 | + printf "%s\n" "$selected_data" | @awk@ -F " " '{print $1}'; return 1 ;; | ||
| 348 | "$open_browser_shortcut") | ||
| 349 | for url in $selected_urls; do | ||
| 350 | - nohup $BROWSER "$url" >/dev/null 2>&1 | ||
| 351 | + @nohup@ $BROWSER "$url" >/dev/null 2>&1 | ||
| 352 | done | ||
| 353 | return 1 ;; | ||
| 354 | "$watch_shortcut") is_download=0; is_audio_only=0; return 0;; | ||
| 355 | @@ -988,10 +988,10 @@ format_user_selection () { | ||
| 356 | 11) selected_urls=$selected_urls$new_line'https://www.youtube.com/watch?v='$surl ;; | ||
| 357 | 34) selected_urls=$selected_urls$new_line'https://www.youtube.com/playlist?list='$surl ;; | ||
| 358 | 36) | ||
| 359 | - selected_urls=$selected_urls$new_line"$(printf "%s" "$videos_json" | jq '.[].url' | grep -F "$surl" | tr -d '"')" ;; | ||
| 360 | + selected_urls=$selected_urls$new_line"$(printf "%s" "$videos_json" | @jq@ '.[].url' | @grep@ -F "$surl" | @tr@ -d '"')" ;; | ||
| 361 | *) continue ;; | ||
| 362 | esac | ||
| 363 | - refined_selected_data=$refined_selected_data$new_line$(printf '%s' "$videos_data" | grep "|$surl" ) | ||
| 364 | + refined_selected_data=$refined_selected_data$new_line$(printf '%s' "$videos_data" | @grep@ "|$surl" ) | ||
| 365 | done<<-EOF | ||
| 366 | $selected_data | ||
| 367 | EOF | ||
| 368 | @@ -1014,9 +1014,9 @@ print_data () { | ||
| 369 | get_video_format () { | ||
| 370 | # select format if flag given | ||
| 371 | [ $show_format -eq 0 ] && return | ||
| 372 | - formats=$(youtube-dl -F "$(printf "$selected_urls")") | ||
| 373 | - line_number=$(printf "$formats" | grep -n '.*extension resolution.*' | cut -d: -f1) | ||
| 374 | - quality=$(printf "$formats \n1 2 xAudio" | awk -v lineno=$line_number 'FNR > lineno {print $3}' | sort -n | awk -F"x" '{print $2 "p"}' | uniq | sed -e "s/Audiop/Audio/" -e "/^p$/d" | eval "$menu_command" | sed "s/p//g") | ||
| 375 | + formats=$(@youtube-dl@ -F "$(printf "$selected_urls")") | ||
| 376 | + line_number=$(printf "$formats" | @grep@ -n '.*extension resolution.*' | @cut@ -d: -f1) | ||
| 377 | + quality=$(printf "$formats \n1 2 xAudio" | @awk@ -v lineno=$line_number 'FNR > lineno {print $3}' | @sort@ -n | @awk@ -F"x" '{print $2 "p"}' | @uniq@ | @sed@ -e "s/Audiop/Audio/" -e "/^p$/d" | eval "$menu_command" | @sed@ "s/p//g") | ||
| 378 | [ -z "$quality" ] && exit; | ||
| 379 | [ $quality = "Audio" ] && video_pref= && video_player="$audio_player" || video_pref="bestvideo[height=?$quality][vcodec!=?vp9]+bestaudio/best" | ||
| 380 | |||
| 381 | @@ -1026,9 +1026,9 @@ get_video_format () { | ||
| 382 | get_sub_lang () { | ||
| 383 | if [ $auto_caption -eq 1 ]; then | ||
| 384 | #Gets the auto generated subs and stores them in a file | ||
| 385 | - sub_list=$(youtube-dl --list-subs --write-auto-sub "$selected_urls" | sed '/Available subtitles/,$d' | awk '{print $1}' | sed '1d;2d;3d') | ||
| 386 | + sub_list=$(@youtube-dl@ --list-subs --write-auto-sub "$selected_urls" | @sed@ '/Available subtitles/,$d' | @awk@ '{print $1}' | @sed@ '1d;2d;3d') | ||
| 387 | if [ -n "$sub_list" ]; then | ||
| 388 | - [ -n "$selected_sub" ] || selected_sub=$(printf "$sub_list" | eval "$menu_command") && youtube-dl --sub-lang $selected_sub --write-auto-sub --skip-download "$selected_urls" -o /tmp/ytfzf && YTFZF_SUBT_NAME="--sub-file=/tmp/ytfzf.$selected_sub.vtt" || printf "Auto generated subs not available." | ||
| 389 | + [ -n "$selected_sub" ] || selected_sub=$(printf "$sub_list" | eval "$menu_command") && @youtube-dl@ --sub-lang $selected_sub --write-auto-sub --skip-download "$selected_urls" -o /tmp/ytfzf && YTFZF_SUBT_NAME="--sub-file=/tmp/ytfzf.$selected_sub.vtt" || printf "Auto generated subs not available." | ||
| 390 | fi | ||
| 391 | unset sub_list | ||
| 392 | fi | ||
| 393 | @@ -1046,10 +1046,10 @@ open_player () { | ||
| 394 | if [ $detach_player -eq 1 ]; then | ||
| 395 | if [ -z "$video_pref" ] || [ $is_audio_only -eq 1 ]; then | ||
| 396 | printf "Opening Player: %s\n" "$video_player $*" | ||
| 397 | - setsid -f $video_player "$@" $YTFZF_SUBT_NAME >/dev/null 2>&1 | ||
| 398 | + @setsid@ -f $video_player "$@" $YTFZF_SUBT_NAME >/dev/null 2>&1 | ||
| 399 | else | ||
| 400 | printf "Opening Player: %s\n" "$video_player_format$video_pref $*" | ||
| 401 | - setsid -f $video_player_format"$video_pref" "$@" $YTFZF_SUBT_NAME >/dev/null 2>&1 | ||
| 402 | + @setsid@ -f $video_player_format"$video_pref" "$@" $YTFZF_SUBT_NAME >/dev/null 2>&1 | ||
| 403 | fi | ||
| 404 | return | ||
| 405 | fi | ||
| 406 | @@ -1064,9 +1064,9 @@ open_player () { | ||
| 407 | fi | ||
| 408 | elif [ $is_download -eq 1 ]; then | ||
| 409 | if [ -z "$video_pref" ]; then | ||
| 410 | - youtube-dl "$@" "$YTFZF_SUBT_NAME" | ||
| 411 | + @youtube-dl@ "$@" "$YTFZF_SUBT_NAME" | ||
| 412 | else | ||
| 413 | - youtube-dl -f "$video_pref" "$@" $YTFZF_SUBT_NAME || video_pref= open_player "$@" | ||
| 414 | + @youtube-dl@ -f "$video_pref" "$@" $YTFZF_SUBT_NAME || video_pref= open_player "$@" | ||
| 415 | fi | ||
| 416 | fi | ||
| 417 | } | ||
| 418 | @@ -1087,7 +1087,7 @@ play_url () { | ||
| 419 | fi | ||
| 420 | |||
| 421 | #Delete the temp auto-gen subtitle file | ||
| 422 | - [ $auto_caption -eq 1 ] && rm -f "${YTFZF_SUBT_NAME#*=}" | ||
| 423 | + [ $auto_caption -eq 1 ] && @rm@ -f "${YTFZF_SUBT_NAME#*=}" | ||
| 424 | |||
| 425 | unset player_urls | ||
| 426 | } | ||
| 427 | @@ -1102,7 +1102,7 @@ session_is_running () { | ||
| 428 | #> removes tmp files and clutter | ||
| 429 | clean_up () { | ||
| 430 | if ! session_is_running ; then | ||
| 431 | - [ -d "$thumb_dir" ] && rm -r "$thumb_dir" | ||
| 432 | + [ -d "$thumb_dir" ] && @rm@ -r "$thumb_dir" | ||
| 433 | : > "$pid_file" | ||
| 434 | function_exists "on_exit" && on_exit | ||
| 435 | fi | ||
| 436 | @@ -1124,9 +1124,9 @@ save_before_exit () { | ||
| 437 | check_if_url () { | ||
| 438 | # to check if given input is a url | ||
| 439 | url_regex='^https\?://.*' | ||
| 440 | - if printf "%s" "$1" | grep -q "$url_regex"; then | ||
| 441 | + if printf "%s" "$1" | @grep@ -q "$url_regex"; then | ||
| 442 | is_url=1 | ||
| 443 | - selected_urls=$(printf "%s" "$1" | tr ' ' '\n') | ||
| 444 | + selected_urls=$(printf "%s" "$1" | @tr@ ' ' '\n') | ||
| 445 | scrape="url" | ||
| 446 | else | ||
| 447 | is_url=0 | ||
| 448 | @@ -1139,10 +1139,10 @@ get_history () { | ||
| 449 | if [ "$enable_hist" -eq 1 ]; then | ||
| 450 | [ -e "$history_file" ] || : > "$history_file" | ||
| 451 | #gets history data in reverse order (makes it most recent to least recent) | ||
| 452 | - hist_data=$( sed '1!G; h; $!d' "$history_file" ) | ||
| 453 | + hist_data=$( @sed@ '1!G; h; $!d' "$history_file" ) | ||
| 454 | [ -z "$hist_data" ] && printf "History is empty!\n" >&2 && return 1; | ||
| 455 | #removes duplicate values from $history_data | ||
| 456 | - videos_data=$(printf "%s" "$hist_data" | uniq ) | ||
| 457 | + videos_data=$(printf "%s" "$hist_data" | @uniq@ ) | ||
| 458 | [ "$sort_videos_data" -eq 1 ] && videos_data="$(printf "%s" "$videos_data" | sort_video_data_fn)" | ||
| 459 | else | ||
| 460 | printf "History is not enabled. Please enable it to use this option (-H).\n" >&2; | ||
| 461 | @@ -1177,10 +1177,10 @@ get_search_history () { | ||
| 462 | if [ "$enable_search_hist" -eq 1 ]; then | ||
| 463 | [ -e "$search_history_file" ] || : > "$search_history_file" | ||
| 464 | #gets history data in reverse order (makes it most recent to least recent) | ||
| 465 | - hist_data=$( sed '1!G; h; $!d' "$search_history_file" ) | ||
| 466 | + hist_data=$( @sed@ '1!G; h; $!d' "$search_history_file" ) | ||
| 467 | [ -z "$hist_data" ] && printf "Search history is empty!\n" >&2 && return 1; | ||
| 468 | #removes duplicate values from $history_data | ||
| 469 | - search_history=$(printf "%s" "$hist_data" | uniq ) | ||
| 470 | + search_history=$(printf "%s" "$hist_data" | @uniq@ ) | ||
| 471 | else | ||
| 472 | printf "Search history is not enabled. Please enable it to use this option (-q).\n" >&2; | ||
| 473 | exit 1; | ||
| 474 | @@ -1190,7 +1190,7 @@ get_search_history () { | ||
| 475 | |||
| 476 | set_search_history () { | ||
| 477 | [ -z "$search_query" ] && return | ||
| 478 | - [ $enable_search_hist -eq 1 ] && printf "%s\t%s\n" "$(date '+%Y-%m-%d %H:%M:%S')" "$search_query" >> "$search_history_file" ; | ||
| 479 | + [ $enable_search_hist -eq 1 ] && printf "%s\t%s\n" "$(@date@ '+%Y-%m-%d %H:%M:%S')" "$search_query" >> "$search_history_file" ; | ||
| 480 | } | ||
| 481 | |||
| 482 | search_history_menu () { | ||
| 483 | @@ -1200,15 +1200,15 @@ search_history_menu () { | ||
| 484 | #when using an external menu, the search history will be done there | ||
| 485 | choice=$( printf "%s\n" "$search_history" | eval "$external_menu" ) | ||
| 486 | else | ||
| 487 | - choice="$( printf "%s\n" "$search_history" | fzf --prompt="$search_history_prompt" --print-query --no-multi -d '\t' --with-nth=2.. --expect='alt-enter' --bind='tab:replace-query' )" | ||
| 488 | + choice="$( printf "%s\n" "$search_history" | @fzf@ --prompt="$search_history_prompt" --print-query --no-multi -d '\t' --with-nth=2.. --expect='alt-enter' --bind='tab:replace-query' )" | ||
| 489 | fi | ||
| 490 | |||
| 491 | # first line is the fzf query (what the user types in fzf) | ||
| 492 | # second line is the fzf --expect key pressed | ||
| 493 | # third line is the search_history selection made | ||
| 494 | - query="$( printf "%s" "$choice" | sed -n '1p' )" | ||
| 495 | - key="$( printf "%s" "$choice" | sed -n '2p' )" | ||
| 496 | - selection="$( printf "%s" "$choice" | sed -n '3p' )" | ||
| 497 | + query="$( printf "%s" "$choice" | @sed@ -n '1p' )" | ||
| 498 | + key="$( printf "%s" "$choice" | @sed@ -n '2p' )" | ||
| 499 | + selection="$( printf "%s" "$choice" | @sed@ -n '3p' )" | ||
| 500 | |||
| 501 | # if no search history selection has been made | ||
| 502 | # and the user typed a query, use that instead | ||
| 503 | @@ -1225,7 +1225,7 @@ search_history_menu () { | ||
| 504 | search_query="$query" | ||
| 505 | return;; | ||
| 506 | esac | ||
| 507 | - search_query="$( printf "%s" "$selection" | awk -F'\t' '{printf "%s", $NF}' )" | ||
| 508 | + search_query="$( printf "%s" "$selection" | @awk@ -F'\t' '{printf "%s", $NF}' )" | ||
| 509 | } | ||
| 510 | |||
| 511 | ! function_exists "send_select_video_notif" && send_select_video_notif () { | ||
| 512 | @@ -1244,13 +1244,13 @@ search_history_menu () { | ||
| 513 | |||
| 514 | #if downloading, say Downloading not currently playing | ||
| 515 | [ $is_download -eq 1 ] && title="Downloading" || title="Currently playing" | ||
| 516 | - notify-send "$title" "$message" -i "$video_thumb" | ||
| 517 | + @notify-send@ "$title" "$message" -i "$video_thumb" | ||
| 518 | |||
| 519 | unset message video_thumb title | ||
| 520 | } | ||
| 521 | |||
| 522 | send_notify () { | ||
| 523 | - videos_selected_count=$(printf "%s\n" "$*" | wc -l) | ||
| 524 | + videos_selected_count=$(printf "%s\n" "$*" | @wc@ -l) | ||
| 525 | while IFS=$tab_space read -r video_title video_channel video_views video_duration video_date video_shorturl; do | ||
| 526 | send_select_video_notif | ||
| 527 | done << EOF | ||
| 528 | @@ -1284,14 +1284,14 @@ if ! function_exists "data_sort_key"; then | ||
| 529 | sort_by="${5#|}" | ||
| 530 | sort_by="${sort_by#Streamed}" | ||
| 531 | #print the data that should be sorted by | ||
| 532 | - printf "%d" "$(date -d "${sort_by}" '+%s')" | ||
| 533 | + printf "%d" "$(@date@ -d "${sort_by}" '+%s')" | ||
| 534 | unset sort_by | ||
| 535 | } | ||
| 536 | fi | ||
| 537 | #the function to use for sorting | ||
| 538 | if ! function_exists "data_sort_fn"; then | ||
| 539 | data_sort_fn () { | ||
| 540 | - sort -nr | ||
| 541 | + @sort@ -nr | ||
| 542 | } | ||
| 543 | fi | ||
| 544 | sort_video_data_fn () { | ||
| 545 | @@ -1300,7 +1300,7 @@ sort_video_data_fn () { | ||
| 546 | IFS="$tab_space" | ||
| 547 | #run the key function to get the value to sort by | ||
| 548 | printf "%s\t%s\n" "$(data_sort_key $line)" "$line" | ||
| 549 | - done | data_sort_fn | cut -f2- | ||
| 550 | + done | data_sort_fn | @cut@ -f2- | ||
| 551 | unset IFS line | ||
| 552 | } | ||
| 553 | |||
| 554 | @@ -1314,19 +1314,19 @@ scrape_subscriptions () { | ||
| 555 | while IFS= read -r url; do | ||
| 556 | scrape_channel "$url" & | ||
| 557 | done <<-EOF | ||
| 558 | - $( sed \ | ||
| 559 | + $( @sed@ \ | ||
| 560 | -e "s/#.*//" \ | ||
| 561 | -e "/^[[:space:]]*$/d" \ | ||
| 562 | -e "s/[[:space:]]*//g" \ | ||
| 563 | "$subscriptions_file") | ||
| 564 | EOF | ||
| 565 | wait | ||
| 566 | - videos_json="$(cat "$tmp_video_json_file")" | ||
| 567 | + videos_json="$(@cat@ "$tmp_video_json_file")" | ||
| 568 | export videos_json | ||
| 569 | if [ $sort_videos_data -eq 1 ]; then | ||
| 570 | videos_data=$(sort_video_data_fn < "$tmp_video_data_file") | ||
| 571 | else | ||
| 572 | - videos_data=$(cat "$tmp_video_data_file") | ||
| 573 | + videos_data=$(@cat@ "$tmp_video_data_file") | ||
| 574 | fi | ||
| 575 | } | ||
| 576 | |||
| 577 | @@ -1346,11 +1346,11 @@ create_subs () { | ||
| 578 | : > "$config_dir/subscriptions" | ||
| 579 | |||
| 580 | # check how many subscriptions there are in the file | ||
| 581 | - sublength=$( jq '. | length' < "$yt_sub_import_file" ) | ||
| 582 | + sublength=$( @jq@ '. | length' < "$yt_sub_import_file" ) | ||
| 583 | |||
| 584 | - for i in $(seq $((sublength - 1))); do | ||
| 585 | - channelInfo=$(jq --argjson index ${i} '[ "https://www.youtube.com/channel/" + .[$index].snippet.resourceId.channelId + "/videos", "#" + .[$index].snippet.title ]' < "$yt_sub_import_file") | ||
| 586 | - printf "%s\n" "$(printf "%s" "$channelInfo" | tr -d '[]"\n,')" >> "$subscriptions_file" | ||
| 587 | + for i in $(@seq@ $((sublength - 1))); do | ||
| 588 | + channelInfo=$(@jq@ --argjson index ${i} '[ "https://www.youtube.com/channel/" + .[$index].snippet.resourceId.channelId + "/videos", "#" + .[$index].snippet.title ]' < "$yt_sub_import_file") | ||
| 589 | + printf "%s\n" "$(printf "%s" "$channelInfo" | @tr@ -d '[]"\n,')" >> "$subscriptions_file" | ||
| 590 | done | ||
| 591 | exit | ||
| 592 | } | ||
| 593 | @@ -1367,10 +1367,10 @@ verify_thumb_disp_method () { | ||
| 594 | |||
| 595 | #sort -R is not posix | ||
| 596 | posix_shuf () { | ||
| 597 | - awk -F '\n' ' | ||
| 598 | + @awk@ -F '\n' ' | ||
| 599 | BEGIN {srand()} #set the random seed at the start | ||
| 600 | {print rand() " " $0} #prepend a random number for each line' |\ | ||
| 601 | - sort | sed -E 's/[^ ]* //' | ||
| 602 | + @sort@ | @sed@ -E 's/[^ ]* //' | ||
| 603 | #sort by the random numbers, remove the random number | ||
| 604 | } | ||
| 605 | |||
| 606 | @@ -1486,8 +1486,8 @@ parse_opt () { | ||
| 607 | exit ;; | ||
| 608 | version) | ||
| 609 | printf "\033[1mytfzf:\033[0m %s\n" "$YTFZF_VERSION" | ||
| 610 | - printf "\033[1myoutube-dl:\033[0m %s\n" "$(youtube-dl --version)" | ||
| 611 | - command -v "fzf" 1>/dev/null && printf "\033[1mfzf:\033[0m %s\n" "$(fzf --version)" | ||
| 612 | + printf "\033[1myoutube-dl:\033[0m %s\n" "$(@youtube-dl@ --version)" | ||
| 613 | + command -v "@fzf@" 1>/dev/null && printf "\033[1mfzf:\033[0m %s\n" "$(@fzf@ --version)" | ||
| 614 | exit ;; | ||
| 615 | |||
| 616 | subt) | ||
| 617 | @@ -1559,19 +1559,19 @@ done | ||
| 618 | shift $((OPTIND-1)) | ||
| 619 | |||
| 620 | #only apply to ext_menu since they dont have a terminal to print to | ||
| 621 | -[ $is_ext_menu -eq 1 ] && command -v notify-send 1>/dev/null 2>&1 && ext_menu_notifs=1 || ext_menu_notifs=0 | ||
| 622 | +[ $is_ext_menu -eq 1 ] && command -v @notify-send@ 1>/dev/null 2>&1 && ext_menu_notifs=1 || ext_menu_notifs=0 | ||
| 623 | |||
| 624 | #used for thumbnail previews in ueberzug | ||
| 625 | if [ $is_ext_menu -eq 0 ]; then | ||
| 626 | - export TTY_LINES=$(tput lines) | ||
| 627 | - export TTY_COLS=$(tput cols) | ||
| 628 | + export TTY_LINES=$(@tput@ lines) | ||
| 629 | + export TTY_COLS=$(@tput@ cols) | ||
| 630 | fi | ||
| 631 | |||
| 632 | #if both are true, it defaults to using fzf, and if fzf isnt installed it will throw an error | ||
| 633 | #so print this error instead and set $show_thumbnails to 0 | ||
| 634 | if [ $is_ext_menu -eq 1 ] && [ $show_thumbnails -eq 1 ]; then | ||
| 635 | [ $ext_menu_notifs -eq 1 ] &&\ | ||
| 636 | - notify-send "warning" "Currently thumbnails do not work in external menus" ||\ | ||
| 637 | + @notify-send@ "warning" "Currently thumbnails do not work in external menus" ||\ | ||
| 638 | printf "\033[33mWARNING: Currently thumbnails do not work in external menus\033[0m\n" >&2 | ||
| 639 | show_thumbnails=0 | ||
| 640 | fi | ||
| 641 | -- | ||
| 642 | 2.32.0 | ||
| 643 | |||
