Compare commits

..

4 Commits

Author SHA1 Message Date
coolnsx
e431d829ac wrapping should work properly. Probably. 2025-08-16 18:58:37 +05:30
coolnsx
5272006282 I would rather be playing SC2. 2025-08-16 18:52:49 +05:30
coolnsx
672adfdd12 I was told to leave it alone, but I have this thing called OCD, you see 2025-08-16 18:49:53 +05:30
coolnsx
f71f117880 Make that it works in 90% of the cases. 3:30. 2025-08-16 18:48:50 +05:30
3 changed files with 42 additions and 12 deletions

View File

@@ -73,7 +73,10 @@ printf "%s\n" "$url" | while read -r id title; do
case $choice in
stream)
info_$os "opening $title" "mpv"
player_$os "$provider_video" "$title" --referrer="https://$domain" --sub-file="$subtitle"
subs_flag=
[ -n "$subtitle" ] && subs_flag="--sub-file=$subtitle"
# shellcheck disable=SC2086
player_$os "$provider_video" "$title" --referrer="https://$domain" $subs_flag
break
;;
cast)

View File

@@ -93,25 +93,53 @@ mpv_jellyfin() {
[ -z "$1" ] && return 0
[ -z "$2" ] && return 0
ITEM_ID=$(printf '%s' "$1" | sed -E 's/(.{8})(.{4})(.{4})(.{4})(.{12})/\1-\2-\3-\4-\5/')
success "Playing $2 on mpv"
url="$JF_URL/Items/$1/Download?api_key=$JF_TOKEN"
sub="$JF_URL/Videos/$(printf '%s' "$1" | sed -E 's/(.{8})(.{4})(.{4})(.{4})(.{12})/\1-\2-\3-\4-\5/')/$1/Subtitles/0/0/Stream.ass?api_key=$JF_TOKEN"
sub="$JF_URL/Videos/$ITEM_ID/$1/Subtitles/0/0/Stream.ass?api_key=$JF_TOKEN"
! curl -s "$sub" | grep -q "Error processing request" && sub_arg="--sub-file=$sub"
if uname -o | grep -q 'ndroid'; then
text="Title: $2\nURL: $url"
[ -n "$sub_arg" ] && text="$text\nSub URL: $sub"
#shellcheck disable=SC2059
printf "\n$text"
#shellcheck disable=SC2059
printf "$text" | termux-clipboard-set
return 0
fi
#shellcheck disable=SC2086
nohup mpv --input-ipc-server="$socket" --start="$((playbackPositionTicks / 10000000))" --force-media-title="$2" "$url" $sub_arg >/dev/null 2>&1 &
track_progress "$(printf '%s' "$1" | sed -E 's/(.{8})(.{4})(.{4})(.{4})(.{12})/\1-\2-\3-\4-\5/')"
skipPositions=$(curl -s "$JF_URL/Episode/$ITEM_ID/IntroSkipperSegments" -H 'Authorization: MediaBrowser Token="'"$JF_TOKEN"'"' -H "Accept: application/json" | sed -nE 's|.*"Introduction".*"IntroStart":([^\.]*).*,"IntroEnd":([^\.]*).*"Credits".*"IntroStart":([^\.]*).*"IntroEnd":([^\.]*).*|op_start=\1;op_end=\2;ed_start=\3;ed_end=\4|p')
track_progress
}
track_progress() {
ITEM_ID=$1
\cat <<EOF >"$progress_track_file"
#!/bin/sh
skipPos(){
[ -z "\$3" ] && printf 1 && return 0
[ -z "\$4" ] && printf 1 && return 0
if [ "\$2" -ge "\$3" ] && [ "\$2" -lt "\$4" ]; then
echo '{"command" :["seek" ,"'"\$4"'","absolute"]}' | socat - "$socket" >/dev/null
echo '{"command": ["show-text", "'"\$5"'", 3000]}' | socat - "$socket" >/dev/null
printf 1
return 0
fi
printf 0
}
positionTicks=$playbackPositionTicks
$skipPositions
introSkipped=0
outroSkipped=0
while sleep 5;do
position=\$(echo '{"command" :["get_property","playback-time"]}' | socat - "$socket" 2>/dev/null | sed -nE 's_.*data":([^,]*).*_\1_p' | tr -d '.' | sed 's|$|0|g')
[ -z "\$position" ] && break
positionTicks=\$position
positionSec=\$((position / 10000000))
[ "\$introSkipped" -eq 0 ] && introSkipped=\$(skipPos "\$introSkipped" "\$positionSec" "\$op_start" "\$op_end" "Intro Skipped")
[ "\$outroSkipped" -eq 0 ] && outroSkipped=\$(skipPos "\$outroSkipped" "\$positionSec" "\$ed_start" "\$ed_end" "Outro Skipped")
done
[ -n "\$positionTicks" ] && curl -s "$JF_URL/Users/$JF_USER_ID/PlayingItems/$ITEM_ID?positionTicks=\$positionTicks" -X DELETE -H 'Authorization: MediaBrowser Token="'"$JF_TOKEN"'"' -H 'Content-Type: application/json'
rm "$socket"
@@ -147,7 +175,10 @@ collection() {
collection_id=$(printf '%s' "$collection" | cut -f1)
collection_title=$(printf '%s' "$collection" | cut -f3 | sed 's|.$||g')
data=$(get_data "Items?IncludeItemTypes=$collection_title&Recursive=false&ParentId=$collection_id" "Select $collection_title >")
recursive="false"
[ "$collection_title" = "Movie" ] && recursive="true"
data=$(get_data "Items?IncludeItemTypes=$collection_title&Recursive=$recursive&ParentId=$collection_id" "Select $collection_title >")
[ -z "$data" ] && exit 1
id=$(printf "%s" "$data" | cut -f1)
title=$(printf "%s" "$data" | cut -f3)

8
screen
View File

@@ -31,11 +31,7 @@ compress() {
record() {
rm -f "$tmp_file" "$process_file"
#shellcheck disable=SC2034
mic="alsa_input.pci-0000_04_00.6.analog-stereo" #It is called in eval on line 9
#shellcheck disable=SC2034
speaker="alsa_output.pci-0000_04_00.6.analog-stereo.monitor" #It is called in eval on line 9
source=$(printf "screen only\n%s" "$(pactl -f json list sources | sed 's|"index":|\n|g' | sed -nE 's|.*,"name":"([^"]*)","description":"([^"]*)".*|\2\t\1|p')" | menu "Audio Source:" "3")
source=$(printf "screen only\n%s" "$(pactl -f json list sources | sed 's|"index":|\n|g' | sed -nE 's|.*,"name":"([^"]*)","description":"([^"]*)".*|\2\t\1|p')" | menu "Audio Source:" "3" | cut -f2)
[ -z "$source" ] && info "" "2000" "No option Selected" && return 0
@@ -43,7 +39,7 @@ record() {
[ -z "$monitor" ] && info "" "2000" "No option Selected" && return 0
[ "$source" != "screen only" ] && pactl set-default-source "$(eval "printf \$$source")" && arg=-a
[ "$source" != "screen only" ] && pactl set-default-source "$source" && arg=-a
#shellcheck disable=SC2086
info "simplescreenrecorder" "1000" "Select Region" "Tap/Click to select full" && setsid -f wf-recorder -x yuv420p -f /tmp/screenrecord.mp4 --output "$monitor" $arg -g "$(slurp)" >/dev/null 2>&1
info "simplescreenrecorder" "700" "Recording Started" "Capturing $monitor($source)"