mirror of
https://github.com/CoolnsX/repos_scripts.git
synced 2025-12-19 23:05:19 +05:30
Fix edge, single client, error case
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
#shellcheck disable=SC2086
|
||||
#shellcheck disable=SC2086,SC2068
|
||||
|
||||
menu_droid() {
|
||||
fzf --prompt="$1" $2
|
||||
@@ -20,11 +20,11 @@ search_linux() {
|
||||
}
|
||||
|
||||
torrent_linux() {
|
||||
setsid -f "$TERMINAL" -e "$(dirname "$0")/torrent" "$1"
|
||||
setsid -f "$TERMINAL" -e "${0%/*}/torrent" $@
|
||||
}
|
||||
|
||||
torrent_droid() {
|
||||
"$(dirname "$0")/torrent" "$1"
|
||||
"${0%/*}/torrent" $@
|
||||
}
|
||||
|
||||
info_droid() {
|
||||
|
||||
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
|
||||
|
||||
2
rss
2
rss
@@ -15,4 +15,4 @@ name=$(printf "%s" "$data" | sed -nE 's_^.*Please\] (.*)</title>.*size>(.*)</sub
|
||||
[ -z "$name" ] && exit 0
|
||||
id=$(printf "%s" "$name" | sed -nE 's/.*\[(.*)\].*/\1/p')
|
||||
magnet=$(printf "%s" "$data" | sed -nE "s_.*<link>(.*$id.*)</link>.*_\1_p" | sed 's/amp;//g')
|
||||
torrent_$os "$magnet"
|
||||
torrent_$os "$magnet" "f"
|
||||
|
||||
4
torrent
4
torrent
@@ -15,7 +15,7 @@ down() {
|
||||
error_$os "Torrent: Error!!"
|
||||
}
|
||||
|
||||
magnet="$*"
|
||||
magnet="$1"
|
||||
if [ "$(uname -o)" = "Android" ]; then
|
||||
os="droid"
|
||||
script_dir="$HOME/.shortcuts"
|
||||
@@ -49,7 +49,7 @@ fi
|
||||
echo "$magnet"
|
||||
printf "${c_yellow}Download>>\n${c_green}[f]ull torrent\n${c_cyan}[p]artial torrent \n${c_red}[q]uit"
|
||||
printf "${c_reset}\n\tenter choice:"
|
||||
read -r ch
|
||||
[ -z "$2" ] && read -r ch || ch=$2
|
||||
case $ch in
|
||||
f)
|
||||
down "$magnet"
|
||||
|
||||
Reference in New Issue
Block a user