aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpystardust <notpiestardust@gmail.com>2021-03-02 13:52:25 +0530
committerpystardust <notpiestardust@gmail.com>2021-03-02 13:52:25 +0530
commit2afa21e07d481bd32dae75f858a406a5f368268e (patch)
tree18652772ac3a97ee3515565cde3e520c9d7013c1
parent4711323b822758c7c0617b3068348ddffa580104 (diff)
parent43cfb912a0a8c06c86e07382918ef86b0e16647d (diff)
downloadytfzf-2afa21e07d481bd32dae75f858a406a5f368268e.tar.gz
Merge branch 'westofer-master'
-rw-r--r--README.md9
-rwxr-xr-xytfzf15
2 files changed, 16 insertions, 8 deletions
diff --git a/README.md b/README.md
index a3a1cd3..047e6c4 100644
--- a/README.md
+++ b/README.md
@@ -243,6 +243,15 @@ export YTFZF_CUR=0
It will be stored in the ytfzf cache directory as `ytfzf_cur`
+## Custom Player
+By default, ytfzf uses `mpv`. custom player should have the ability to launch youtube links.
+
+``` sh
+# example: using devour
+export FZF_PLAYER="devour mpv"
+export YTFZF_PLAYER_FORMAT="devour mpv --ytdl-format="
+```
+
# Todo
* [ ] Playlists
diff --git a/ytfzf b/ytfzf
index 06c2cf8..9dd8cdb 100755
--- a/ytfzf
+++ b/ytfzf
@@ -15,6 +15,9 @@
[ -z "$YTFZF_EXTMENU" ] && YTFZF_EXTMENU='dmenu -i -l 30 -p Search:'
[ -z "$YTFZF_EXTMENU_LEN" ] && YTFZF_EXTMENU_LEN=220
+## player settings
+[ -z "$YTFZF_PLAYER" ] && YTFZF_PLAYER="mpv"
+[ -z "$YTFZF_PLAYER_FORMAT" ] && YTFZF_PLAYER_FORMAT="mpv --ytdl-format="
#> Clearing/Enabling fzf_defaults
[ -z "$YTFZF_ENABLE_FZF_DEFAULT_OPTS" ] && YTFZF_ENABLE_FZF_DEFAULT_OPTS=0
[ $YTFZF_ENABLE_FZF_DEFAULT_OPTS -eq 0 ] && FZF_DEFAULT_OPTS=""
@@ -26,10 +29,6 @@ thumb_dir="$YTFZF_CACHE"/thumb
[ -d $YTFZF_CACHE ] || mkdir -p $YTFZF_CACHE
[ -d $thumb_dir ] || mkdir -p $thumb_dir
-#> player
-player="mpv"
-player_format="mpv --ytdl-format="
-
############################
# Help Texts #
@@ -346,9 +345,9 @@ play_url () {
#> Play url with $player or $player_format based on options
#> if player format fails, then use normal player
[ -n "$YTFZF_PREF" ] && {
- eval "$player_format"\'$YTFZF_PREF\' "\"$(printf "$urls" | tr '\n' '\t' | sed 's_\t_" "_g' )\""
+ eval "$YTFZF_PLAYER_FORMAT"\'$YTFZF_PREF\' "\"$(printf "$urls" | tr '\n' '\t' | sed 's_\t_" "_g' )\""
} || {
- [ 4 -eq $? ] || eval "$player" "\"$(printf "$urls" | tr '\n' '\t' | sed 's_\t_" "_g' )\""
+ [ 4 -eq $? ] || eval "$YTFZF_PLAYER" "\"$(printf "$urls" | tr '\n' '\t' | sed 's_\t_" "_g' )\""
# Ctr-C in MPV results in a return code of 4
} || {
printf "\033[31mERROR[#03]: Couldn't play the video/audio using the current player.\n\tTry updating youtube-dl\033[000m\n"; errinfo ; save_before_exit ; exit 2;
@@ -420,8 +419,8 @@ while getopts "LhDmdfxHarltsn:U:" opt; do
;;
m) YTFZF_PREF="bestaudio"
;;
- d) player="youtube-dl"
- player_format="youtube-dl -f "
+ d) YTFZF_PLAYER="youtube-dl"
+ YTFZF_PLAYER_FORMAT="youtube-dl -f "
;;
f) show_format=1
;;
Un proyecto texto-plano.xyz