mirror of
https://github.com/CoolnsX/repos_scripts.git
synced 2025-12-20 07:15:20 +05:30
90 lines
4.5 KiB
Bash
Executable File
90 lines
4.5 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
domain="allanime.day"
|
|
run_file="${TMPDIR:-/tmp}/${0##*/}_run"
|
|
agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/13$(head /dev/urandom | tr -dc '0-5' | cut -c1).0.0.0 Safari/537.36"
|
|
debug=$2
|
|
|
|
\cat <<EOF >"$run_file"
|
|
search() { curl -e "https://allanime.to" -sL -G "https://api.${domain}/api" -A "$agent" --data-urlencode 'query=query(\$search: SearchInput \$limit: Int \$page: Int \$translationType: VaildTranslationTypeEnumType \$countryOrigin: VaildCountryOriginEnumType) { shows( search: \$search limit: \$limit page: \$page translationType: \$translationType countryOrigin: \$countryOrigin ) {edges { _id name lastEpisodeInfo __typename}}}' --data-urlencode 'variables={"search":{"sortBy":"Recent","allowAdult":true,"allowUnknown":true,"query":"'"\$1"'"},"limit":40,"page":1,"translationType":"sub","countryOrigin":"JP"}' | sed 's|Show|\n|g' | sed 's|__typename|\n|g' | sed -nE 's|.*_id":"([^"]*)","name":"([^"]*)".*sub":\{"episodeString":"([^"]*)".*|\1\t\2 Episode \3|p'; }; [ -n "\$2" ] && search "\$1"
|
|
EOF
|
|
|
|
chmod +x "$run_file"
|
|
|
|
# shellcheck disable=SC1091,SC1090
|
|
. "$run_file"
|
|
|
|
case $(uname -o) in
|
|
*ndroid*)
|
|
os="droid"
|
|
download_dir="/sdcard"
|
|
;;
|
|
*)
|
|
os="linux"
|
|
download_dir="$HOME/Downloads"
|
|
terminal="setsid -f ${TERMINAL:-foot} -e"
|
|
;;
|
|
esac
|
|
|
|
# shellcheck disable=SC1091,SC1090
|
|
. "$(dirname "$0")"/.functions
|
|
|
|
trap "exit 0" INT HUP
|
|
info_$os "Parsing $domain.. Please wait..."
|
|
|
|
url=$(search | (
|
|
case "$os" in
|
|
linux) menu_$os "Select Anime: " ;;
|
|
*) fzf --bind="change:reload:$run_file {q} 1" --prompt="Select Anime: " --with-nth 2.. -m ;;
|
|
esac
|
|
) | tr ':' ' ' | tr -s ' ') || true
|
|
|
|
[ -z "$url" ] && error_$os "No anime selected" && exit 0
|
|
|
|
printf "%s\n" "$url" | while read -r id title; do
|
|
ep_no=$(printf "%s" "$title" | sed 's/.*Episode //g')
|
|
|
|
info_$os "Loading Episode $title.."
|
|
[ -n "$debug" ] && printf "\n\033[1;36m title\033[0m : %s\n" "$title"
|
|
|
|
#shellcheck disable=SC2016
|
|
data=$(curl -e "https://allanime.to" -sL -G "https://api.${domain}/api" -A "$agent" --data-urlencode "variables={\"showId\":\"$id\",\"translationType\":\"sub\",\"countryOrigin\":\"ALL\",\"episodeString\":\"$ep_no\"}" --data-urlencode 'query=query ($showId: String!, $translationType: VaildTranslationTypeEnumType!, $episodeString: String!) { episode( showId: $showId translationType: $translationType episodeString: $episodeString ) { episodeString sourceUrls }}' | tr '{}' '\n' | sed 's|\\u002F|\/|g;s|\\||g' | sed -nE 's|.*sourceUrl":"--([^"]*)".*sourceName":"([^"]*)".*|\2 :\1|p')
|
|
info_$os "Fetching Embed links"
|
|
|
|
printf 'dropbox\tSak\nwetransfer\tKir\nsharepoint\tS-mp4\ngogoplay\tLuf-mp4\n' | while read -r provider_name provider_regex; do
|
|
info_$os "Fetching $provider_name links"
|
|
provider_id="$(printf "%s" "$data" | sed -n "/$provider_regex :/p" | cut -d':' -f2 | sed 's/../&\n/g' | sed "s/^01$/9/g;s/^08$/0/g;s/^05$/=/g;s/^0a$/2/g;s/^0b$/3/g;s/^0c$/4/g;s/^07$/?/g;s/^00$/8/g;s/^5c$/d/g;s/^0f$/7/g;s/^5e$/f/g;s/^17$/\//g;s/^54$/l/g;s/^09$/1/g;s/^48$/p/g;s/^4f$/w/g;s/^0e$/6/g;s/^5b$/c/g;s/^5d$/e/g;s/^0d$/5/g;s/^53$/k/g;s/^1e$/\&/g;s/^5a$/b/g;s/^59$/a/g;s/^4a$/r/g;s/^4c$/t/g;s/^4e$/v/g;s/^57$/o/g;s/^51$/i/g;" | tr -d '\n' | sed "s/\/clock/\/clock\.json/")"
|
|
[ -z "$provider_id" ] && continue
|
|
provider_video=$(curl -s "https://${domain}${provider_id}" | sed 's|},{|\n|g' | sed -nE 's|.*link":"([^"]*)".*"resolutionStr":"([^"]*)".*|\1|p;s|.*hls","url":"([^"]*)".*"hardsub_lang":"en-US".*|\1|p' | head -1)
|
|
[ -z "$provider_video" ] && continue
|
|
[ -n "$debug" ] && printf "\033[1;32m %s\033[0m : %s\n" "$provider_name" "$provider_video" && continue
|
|
info_$os "$provider_name links fetched.."
|
|
choice=$(printf "stream\ndownload\ncast\nnext_mirror\nnext_anime" | menu_$os "??" '' "2")
|
|
[ -z "$choice" ] && break
|
|
case $choice in
|
|
stream)
|
|
info_$os "opening $title" "mpv"
|
|
player_$os "$provider_video" "$title"
|
|
break
|
|
;;
|
|
cast)
|
|
info_$os "casting $title" "podcast"
|
|
catt cast "$provider_video"
|
|
break
|
|
;;
|
|
*mirror)
|
|
continue
|
|
;;
|
|
download)
|
|
info_$os "Downloading $title" "downloader"
|
|
case $provider_video in
|
|
*m3u*) $terminal hls -ro "$download_dir/$title" "$provider_video" || error_$os "Downloading failed $title" ;;
|
|
*) $terminal aria2c -U "$agent" --check-certificate=false -d "$download_dir" --summary-interval=0 -x 16 -s 16 --referer="https://$domain" "$provider_video" -o "$title.mp4" --download-result=hide || error_$os "Downloading failed $title" ;;
|
|
esac
|
|
info_$os "Episode Downloaded $title"
|
|
;;
|
|
esac
|
|
break
|
|
done
|
|
done
|