Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ OPTIONS:
--help, -h Show this help message
--version Show version info
--copy-url Copy or display the video link
--watch, -w Watch videos directly without any options after choosing a video

EXAMPLES:
ytsurf lo-fi study mix
Expand Down
67 changes: 39 additions & 28 deletions ytsurf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ DEFAULT_MAX_HISTORY_ENTRIES=100
DEFAULT_NOTIFY=true
DEFAULT_COPY_MODE=false
DEFAULT_CHAFA_BLOCK_MODE=false
DEFAULT_ACTION_MODE=true

# System directories
readonly CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/$SCRIPT_NAME"
Expand Down Expand Up @@ -69,6 +70,7 @@ player="mpv"
applications="$HOME/.local/share/applications/ytsurf/"
copy_mode="$DEFAULT_COPY_MODE"
chafa_block_mode="$DEFAULT_CHAFA_BLOCK_MODE"
action_mode="$DEFAULT_ACTION_MODE"

# Runtime variables
query=""
Expand Down Expand Up @@ -325,6 +327,7 @@ OPTIONS:
--copy-url Copy or display the video link
--debug Activate debug mode
--block Use chafa in block mode instead of sixel
--watch, -w Watch videos directly without any options after choosing a video

CONFIG:
$CONFIG_FILE can contain default options like:
Expand Down Expand Up @@ -538,6 +541,10 @@ parse_arguments() {
--update | -u)
update_script
;;
--watch | -w)
action_mode=false
shift
;;
*)
query="$*"
break
Expand Down Expand Up @@ -812,38 +819,42 @@ unsubscribe() {
#=============================================================================

select_action() {
local chosen_action
local prompt="Select Action:"
local header="Available Actions"
local items=("watch" "download" "watch_with_friends")
if [[ "$action_mode" == true ]]; then
local chosen_action
local prompt="Select Action:"
local header="Available Actions"
local items=("watch" "download" "watch_with_friends")

if [[ "$use_rofi" == true ]]; then
chosen_action=$(printf "%s\n" "${items[@]}" | rofi -dmenu -p "$prompt" -mesg "$header")
elif [[ "$use_sentaku" == true ]]; then
chosen_action=$(printf "%s\n" "${items[@]}" | sentaku)
elif [[ "$use_tv" == true ]]; then
chosen_action=$(tv \
--source-command="printf '%s\n' ${items[*]}" \
--no-preview \
--no-remote \
--no-help-panel \
--input-prompt="❯ " \
--input-header="$header" \
--no-status-bar)
else
chosen_action=$(printf "%s\n" "${items[@]}" | fzf --prompt="$prompt" --header="$header")
fi
if [[ "$use_rofi" == true ]]; then
chosen_action=$(printf "%s\n" "${items[@]}" | rofi -dmenu -p "$prompt" -mesg "$header")
elif [[ "$use_sentaku" == true ]]; then
chosen_action=$(printf "%s\n" "${items[@]}" | sentaku)
elif [[ "$use_tv" == true ]]; then
chosen_action=$(tv \
--source-command="printf '%s\n' ${items[*]}" \
--no-preview \
--no-remote \
--no-help-panel \
--input-prompt="❯ " \
--input-header="$header" \
--no-status-bar)
else
chosen_action=$(printf "%s\n" "${items[@]}" | fzf --prompt="$prompt" --header="$header")
fi

if [[ "$chosen_action" == "watch" ]]; then
echo false
elif [[ "$chosen_action" == "watch_with_friends" ]]; then
player="syncplay"
echo false
if [[ "$chosen_action" == "watch" ]]; then
echo false
elif [[ "$chosen_action" == "watch_with_friends" ]]; then
player="syncplay"
echo false

elif [[ -z "$chosen_action" ]]; then
return 1
elif [[ -z "$chosen_action" ]]; then
return 1
else
echo true
fi
else
echo true
echo false
fi
return 0
}
Expand Down
Loading