mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-11-22 03:19:53 -08:00
Merge branch 'master' of github.com:ksyasuda/aniwrapper
This commit is contained in:
commit
9322d028f8
71
ani-cli
71
ani-cli
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
BASE_URL="https://goload.pro"
|
BASE_URL="https://goload.pro"
|
||||||
CFG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/aniwrapper"
|
CFG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/aniwrapper"
|
||||||
|
URLFILE="${XDG_CONFIG_HOME:-$HOME/.config}/aniwrapper/ani-url"
|
||||||
HISTORY_DB="$CFG_DIR/history.sqlite3"
|
HISTORY_DB="$CFG_DIR/history.sqlite3"
|
||||||
ROFI_CFG="$CFG_DIR/themes/aniwrapper.rasi"
|
ROFI_CFG="$CFG_DIR/themes/aniwrapper.rasi"
|
||||||
ROFI_THEME="aniwrapper.rasi"
|
ROFI_THEME="aniwrapper.rasi"
|
||||||
@ -97,7 +98,7 @@ download() {
|
|||||||
aria2c --summary-interval=0 -x 16 -s 16 --referer="$1" "$2" --dir="$5" -o "${4}" --download-result=hide
|
aria2c --summary-interval=0 -x 16 -s 16 --referer="$1" "$2" --dir="$5" -o "${4}" --download-result=hide
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
ffmpeg -loglevel error -stats -referer "$1" -i "$2" -c copy "$5/${4}"
|
ffmpeg -loglevel error -stats -referer "$1" -i "$2" -map "0:p:$((idx - 1))?" -c copy "$5/${4}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
@ -118,28 +119,64 @@ decrypt_link() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# chooses the link for the set quality
|
# chooses the link for the set quality
|
||||||
get_video_quality() {
|
get_video_link() {
|
||||||
dpage_url=$1
|
dpage_url=$1
|
||||||
video_links=$(decrypt_link "$dpage_url")
|
video_links=$(decrypt_link "$dpage_url")
|
||||||
|
lg "Quality: $quality" > /dev/stderr
|
||||||
|
if printf '%s' "$video_links" | grep -q "mp4"; then
|
||||||
|
video_url=$(get_video_quality_mp4 "$video_links")
|
||||||
|
idx=1
|
||||||
|
else
|
||||||
|
video_url="$video_links"
|
||||||
|
get_video_quality_m3u8
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
get_video_quality_mp4() {
|
||||||
|
lg "BEGIN: get_video_quality_mp4()" > /dev/stderr
|
||||||
case $quality in
|
case $quality in
|
||||||
best)
|
best)
|
||||||
video_link=$(printf '%s' "$video_links" | head -n 4 | tail -n 1)
|
video_url=$(printf '%s' "$1" | head -n 4 | tail -n 1)
|
||||||
;;
|
;;
|
||||||
|
|
||||||
worst)
|
worst)
|
||||||
video_link=$(printf '%s' "$video_links" | head -n 1)
|
video_url=$(printf '%s' "$1" | head -n 1)
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
video_link=$(printf '%s' "$video_links" | grep -i "${quality}" | head -n 1)
|
video_url=$(printf '%s' "$1" | grep -i "${quality}" | head -n 1)
|
||||||
if [ -z "$video_link" ]; then
|
if [ -z "$video_url" ]; then
|
||||||
err "Current video quality is not available (defaulting to best quality)"
|
err "Current video quality is not available (defaulting to best quality)"
|
||||||
quality=best
|
quality=best
|
||||||
video_link=$(printf '%s' "$video_links" | head -n 4 | tail -n 1)
|
video_url=$(printf '%s' "$1" | head -n 4 | tail -n 1)
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
printf '%s' "$video_link"
|
lg "END: get_video_quality_mp4()" > /dev/stderr
|
||||||
|
printf '%s' "$video_url"
|
||||||
|
}
|
||||||
|
|
||||||
|
get_video_quality_m3u8() {
|
||||||
|
lg "BEGIN: get_video_quality_m3u8()" > /dev/stderr
|
||||||
|
case $quality in
|
||||||
|
worst | 360p)
|
||||||
|
idx=2
|
||||||
|
;;
|
||||||
|
480p)
|
||||||
|
idx=3
|
||||||
|
;;
|
||||||
|
720p)
|
||||||
|
idx=4
|
||||||
|
;;
|
||||||
|
1080p | best)
|
||||||
|
idx=5
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
idx=5
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
lg "END: get_video_quality_m3u8() -> idx = $idx" > /dev/stderr
|
||||||
|
printf '%s' "$video_url" | grep -qE "gogocdn.*m3u.*" && idx=$((idx - 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
# sets the video quality
|
# sets the video quality
|
||||||
@ -544,12 +581,17 @@ extended_search() {
|
|||||||
sed -n -E 's_^[[:space:]]*<a href="/category/([^"]*)" title="([^"]*)".*_\1_p'
|
sed -n -E 's_^[[:space:]]*<a href="/category/([^"]*)" title="([^"]*)".*_\1_p'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#update main url to latest one
|
||||||
|
updateurl() {
|
||||||
|
prev_url=$(printf "%s" "$BASE_URL" | cut -d"/" -f3)
|
||||||
|
new_url=$(printf "%s" "$dpage_link" | cut -d"/" -f3)
|
||||||
|
[ "$prev_url" != "$new_url" ] && printf "%s" "$new_url" > "$URLFILE"
|
||||||
|
}
|
||||||
|
|
||||||
check_episode() {
|
check_episode() {
|
||||||
data=$(curl -s "$BASE_URL/videos/$1")
|
data=$(curl -s "$BASE_URL/videos/$1")
|
||||||
if [ "$data" != "404" ]; then
|
del=$(printf "%s" "$data" | grep -n "Latest Episodes" | cut -d ":" -f1)
|
||||||
del=$(printf "%s" "$data" | grep -n "Latest Episodes" | cut -d ":" -f1)
|
[ -n "$del" ] && printf "%s" "$data" | sed "$del,$ d" | sed -nE "s_^[[:space:]]*<a href.*videos/${2}(.*)\">_\1_p"
|
||||||
printf "%s" "$data" | sed "$del,$ d" | sed -nE "s_^[[:space:]]*<a href.*videos/${2}(.*)\">_\1_p"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
search_eps() {
|
search_eps() {
|
||||||
@ -681,7 +723,7 @@ open_episode() {
|
|||||||
if [[ -z "$dpage_link" ]]; then
|
if [[ -z "$dpage_link" ]]; then
|
||||||
die "Could not get download page link"
|
die "Could not get download page link"
|
||||||
else
|
else
|
||||||
video_url=$(get_video_quality "$dpage_link")
|
get_video_link "$dpage_link"
|
||||||
fi
|
fi
|
||||||
lg "Download link: $dpage_link"
|
lg "Download link: $dpage_link"
|
||||||
lg "Video url: $video_url"
|
lg "Video url: $video_url"
|
||||||
@ -690,7 +732,7 @@ open_episode() {
|
|||||||
kill "$PID" > /dev/null 2>&1
|
kill "$PID" > /dev/null 2>&1
|
||||||
case "$PLAYER_FN" in
|
case "$PLAYER_FN" in
|
||||||
mpv)
|
mpv)
|
||||||
nohup "$PLAYER_FN" --referrer="$dpage_link" "$video_url" --force-media-title="aniwrapper: $anime_id E$(printf "%03d" "$episode")" > /dev/null 2>&1 &
|
nohup "$PLAYER_FN" --vid="$idx" --referrer="$dpage_link" "$video_url" --force-media-title="aniwrapper: $anime_id E$(printf "%03d" "$episode")" > /dev/null 2>&1 &
|
||||||
;;
|
;;
|
||||||
vlc)
|
vlc)
|
||||||
nohup "$PLAYER_FN" --play-and-exit --http-referrer="$dpage_link" "$video_url" > /dev/null 2>&1 &
|
nohup "$PLAYER_FN" --play-and-exit --http-referrer="$dpage_link" "$video_url" > /dev/null 2>&1 &
|
||||||
@ -998,3 +1040,4 @@ dep_ch "$PLAYER_FN" "curl" "sed" "grep" "sqlite3" "rofi" "git" "aria2c" "openssl
|
|||||||
parse_args "$@"
|
parse_args "$@"
|
||||||
shift $((OPTIND - 1))
|
shift $((OPTIND - 1))
|
||||||
main "$@"
|
main "$@"
|
||||||
|
updateurl &
|
||||||
|
Loading…
Reference in New Issue
Block a user