aboutsummaryrefslogtreecommitdiffstats
path: root/hm/soispha/pkgs/scripts/wrappers
diff options
context:
space:
mode:
Diffstat (limited to 'hm/soispha/pkgs/scripts/wrappers')
-rwxr-xr-xhm/soispha/pkgs/scripts/wrappers/ytc100
-rwxr-xr-xhm/soispha/pkgs/scripts/wrappers/yts65
2 files changed, 0 insertions, 165 deletions
diff --git a/hm/soispha/pkgs/scripts/wrappers/ytc b/hm/soispha/pkgs/scripts/wrappers/ytc
deleted file mode 100755
index c607ea81..00000000
--- a/hm/soispha/pkgs/scripts/wrappers/ytc
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/env dash
-
-# shellcheck source=/dev/null
-SHELL_LIBRARY_VERSION="1.10.2" . %SHELL_LIBRARY_PATH
-CONCURRENT=4
-OUTPUT_PATH="/tmp/ytcc";
-
-col() {
- echo "$1" | csvtool -t ';' -u ';' col "$2" -
-}
-
-play() {
- msg2 "Playing: '$1'"
- mpv "$1" --speed=2.7 --volume=75
- output="$?";
-
- if [ "$output" -eq 0 ]; then
- msg2 "Removing: $1"
- rm "$1"
- msg2 "Marking: " "$2"
- ytcc mark "$2"
- fi
- return "$output"
-}
-
-escape() {
- echo "$1" | awk '{gsub(/;/, ","); print}'
-}
-
-bases="$(ytcc --output json list --attributes url --ids "$@" | jq --raw-output 'map("\(.url);\(.id)") | join("\n")')";
-
-yt_flags="$(mktmp)"
-cat << EOF > "$yt_flags"
---format bestvideo[height<=?1080]+bestaudio/best
---embed-chapters
---progress
---write-comments
---extractor-args youtube:max_comments=150,all,100;comment_sort=top
---write-info-json
---sponsorblock-mark default
---sponsorblock-remove sponsor
-EOF
-
-[ -d "$OUTPUT_PATH" ] || mkdir "$OUTPUT_PATH";
-cd "$OUTPUT_PATH" || die "(Bug): Was created"
-
-filename_file="$(mktmp)";
-files_to_play="$(mktmp)";
-while read -r base; do
- url="$(col "$base" 1)";
- id="$(col "$base" 2)"
-
- if [ "$old_filename" ]; then
- echo "$(escape "$old_filename");$old_id" >> "$files_to_play"
-
- # Check if the process (pid) exists
- dbg "PID is '$pid'"
- if ! kill -0 "$pid"; then
- saved_base="$(head -n 1 "$files_to_play")";
- sed -i '1d' "$files_to_play";
- saved_name="$(col "$saved_base" 1)";
- saved_id="$(col "$saved_base" 2)"
-
- dbg "Started play for '$saved_name'"
- play "$saved_name" "$saved_id" &
- pid=$!
- else
- dbg "Storing for later '$old_filename'"
- fi
- fi
-
- # The sub shell needs to be unquoted, as the arguments may not be treated as one.
- # shellcheck disable=2046
- yt-dlp $(cat "$yt_flags") --output "%(channel)s/%(title)s.%(ext)s" "$url" --print-to-file after_move:filepath "$filename_file"
-
- filename="$(cat "$filename_file")"
- printf "" > "$filename_file"
-
- if [ "$old_filename" ]; then
- if [ "$(wc -l < "$files_to_play")" -gt "$CONCURRENT" ]; then
- msg2 "Waiting for '$pid' to finish as we already have '$(wc -l < "$files_to_play")' files cached"
- wait "$pid"
- fi
- fi
-
- old_filename="$filename";
- old_id="$id";
-done < "$(tmp echo "$bases")"
-
-wait "$pid"
-echo "$(escape "$old_filename");$old_id" >> "$files_to_play"
-
-while read -r base; do
- name="$(col "$base" 1)";
- id="$(col "$base" 2)"
-
- dbg "Started play for '$name'"
- play "$name" "$id"
-done < "$files_to_play"
-# vim: ft=sh
diff --git a/hm/soispha/pkgs/scripts/wrappers/yts b/hm/soispha/pkgs/scripts/wrappers/yts
deleted file mode 100755
index b5edf52c..00000000
--- a/hm/soispha/pkgs/scripts/wrappers/yts
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/env dash
-
-# shellcheck source=/dev/null
-SHELL_LIBRARY_VERSION="1.10.2" . %SHELL_LIBRARY_PATH
-
-TASK_UUID=ce4f9e07-8324-4570-8be6-967955e9271e
-
-cleanup() {
- task stop "$TASK_UUID"
-}
-trap cleanup EXIT
-
-help_text="
-#
-# Commands:
-# w, watch <id> = watch id
-# d, drop <id> = mark id as watched
-# p, pick <id> = leave id as is; This is a noop
-#
-# These lines can be re-ordered; they are executed from top to bottom.
-# vim: ft=gitrebase"
-
-table="$(ytcc --output json list | jq --raw-output 'map("pick \(.id) \(.title) (\(.playlists | map(.name) | join(", "))) [\(.duration | gsub("^\\s+|\\s+$";""))]") | join("\n")')"
-
-selection_file="$(mktmp)";
-
-task start "$TASK_UUID"
-
-echo "$table" > "$selection_file";
-echo "$help_text" >> "$selection_file";
-
-$EDITOR "$selection_file"
-
-ids=""
-is_first=true;
-while read -r line; do
- cmd="$(echo "$line" | awk '{print $1}')";
- case "$cmd" in
- "#" )
- # This is a comment, do nothing here
- ;;
- "pick" | "p")
- # noop do nothing here
- ;;
- "drop" | "d")
- id="$(echo "$line" | awk '{print $2}')";
- ytcc mark "$id";
- dbg "Marked as watched: $id"
- ;;
- "watch" | "w")
- id="$(echo "$line" | awk '{print $2}')";
- if [ "$is_first" = "true" ]; then
- ids="$id";
- else
- ids="$ids,$id";
- fi
- dbg "Added to be watched: $id"
- is_first=false
- ;;
- esac
-done < "$selection_file"
-
-[ "$ids" != "" ] && ytc "$ids";
-
-# vim: ft=sh