mirror of
https://github.com/CoolnsX/repos_scripts.git
synced 2025-12-20 07:15:20 +05:30
Fix edge, single client, error case
This commit is contained in:
11
jellyfin
11
jellyfin
@@ -93,10 +93,9 @@ 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/$ITEM_ID/$1/Subtitles/0/0/Stream.ass?api_key=$JF_TOKEN"
|
||||
sub="$JF_URL/Videos/$1/$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"
|
||||
@@ -109,8 +108,8 @@ mpv_jellyfin() {
|
||||
fi
|
||||
#shellcheck disable=SC2086
|
||||
nohup mpv --input-ipc-server="$socket" --start="$((playbackPositionTicks / 10000000))" --force-media-title="$2" "$url" $sub_arg >/dev/null 2>&1 &
|
||||
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
|
||||
skipPositions=$(curl -s "$JF_URL/Episode/$1/IntroSkipperSegments" -H 'Authorization: MediaBrowser Token="'"$JF_TOKEN"'"' -H "Accept: application/json" | sed 's|}|\n|g' | sed -nE 's|.*"Introduction".*"IntroStart":([^\.,]*).*,"IntroEnd":([^\.,]*).*|op_start=\1\nop_end=\2|p;s|.*"Credits".*"IntroStart":([^\.,]*).*"IntroEnd":([^\.,]*).*|ed_start=\1\ned_end=\2|p')
|
||||
track_progress "$1"
|
||||
}
|
||||
|
||||
track_progress() {
|
||||
@@ -137,11 +136,11 @@ 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))
|
||||
positionSec=\${position::-7}
|
||||
[ "\$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'
|
||||
[ -n "\$positionTicks" ] && curl -s "$JF_URL/Users/$JF_USER_ID/PlayingItems/${1}?positionTicks=\$positionTicks" -X DELETE -H 'Authorization: MediaBrowser Token="$JF_TOKEN"' -H 'Content-Type: application/json'
|
||||
rm "$socket"
|
||||
rm "\$0"
|
||||
EOF
|
||||
|
||||
Reference in New Issue
Block a user