mirror of
https://github.com/CoolnsX/repos_scripts.git
synced 2025-12-20 07:15:20 +05:30
100 lines
4.4 KiB
Bash
Executable File
100 lines
4.4 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
down() {
|
|
[ -n "$debug" ] && printf "\033[1;32m %s\033[0m : %s\n" "$3" "$2" && return 0
|
|
info_$os "$3 links fetched.."
|
|
choice=$(printf "stream\ndownload\ncast\nnext mirror" | menu_$os "??")
|
|
[ -z "$choice" ] && exit 0
|
|
[ "$choice" = "stream" ] && player_$os "$2" "$title" && info_$os "opening $title" "mpv" && exit 0
|
|
[ "$choice" = "cast" ] && info_$os "casting $title" "podcast" && catt cast "$2" && exit 0
|
|
[ "$choice" = "next mirror" ] && return 0
|
|
info_$os "Downloading $title" "downloader"
|
|
case $2 in
|
|
*m3u*) $terminal hls -n 300 -ro "$download_dir/$title" "$2" || (error_$os "Downloading failed $title" && exit 0) ;;
|
|
*) $terminal aria2c -U "$agent" --check-certificate=false -d "$download_dir" --summary-interval=0 -x 16 -s 16 --referer="$1" "$2" -o "$title.mp4" --download-result=hide || (error_$os "Downloading failed $title" && exit 0) ;;
|
|
esac
|
|
info_$os "Episode Downloaded $title"
|
|
exit 0
|
|
}
|
|
|
|
decrypt_allanime() {
|
|
printf "%s" "$-" | grep -q 'x' && set +x
|
|
for hex in $(printf '%s' "$1" | sed 's/../&\n/g'); do
|
|
dec=$(printf '%d' "0x$hex")
|
|
xor=$((dec ^ 56))
|
|
oct=$(printf "%03o" "$xor")
|
|
#shellcheck disable=SC2059
|
|
printf "\\$oct"
|
|
done
|
|
printf "%s" "$-" | grep -q 'x' || set -x
|
|
}
|
|
|
|
provider_run() {
|
|
info_$os "Fetching $1 links"
|
|
provider_id="$(decrypt_allanime "$(printf "%s" "$data" | sed -n "$2" | head -1 | cut -d':' -f2)" | sed "s/\/clock/\/clock\.json/")"
|
|
[ -z "$provider_id" ] && return 0
|
|
provider_video=$(curl -s "https://embed.ssbcontent.site$provider_id" | sed 's|},{|\n|g' | sed -nE 's|.*link":"([^"]*)".*"resolutionStr":"([^"]*)".*|\1|p;s|.*hls","url":"([^"]*)".*"hardsub_lang":"en-US".*|\1|p')
|
|
[ -z "$provider_video" ] && return 0
|
|
case $provider_video in
|
|
*repackager.wixmp.com*) down "$base_url" "$(printf %s "$provider_video" | head -1 | cut -d',' -f1,2 | tr -d ',' | sed 's|repackager.wixmp.com/||g')/mp4/file.mp4" "$1" ;;
|
|
*rmbl.ws*) down "$base_url" "$(printf %s "$provider_video" | tail -1)" "$1" ;;
|
|
*) down "$base_url" "$(printf %s "$provider_video" | head -1)" "$1" ;;
|
|
esac
|
|
}
|
|
|
|
allanime_curl() {
|
|
curl -e 'https://allanime.to' -sL --cipher AES256-SHA256 -G "${base_url}/api" -A "$agent" --data-urlencode "$1" --data-urlencode "$2"
|
|
}
|
|
|
|
base_url="https://api.allanime.day"
|
|
agent="Mozilla/5.0"
|
|
[ -n "$2" ] && debug=1
|
|
|
|
case $(uname -o) in
|
|
*ndroid*)
|
|
os="droid"
|
|
download_dir="/sdcard"
|
|
script_dir=""
|
|
;;
|
|
*)
|
|
os="linux"
|
|
download_dir="$HOME/Downloads"
|
|
terminal="$TERMINAL -e"
|
|
script_dir="$HOME/repos_scripts"
|
|
;;
|
|
esac
|
|
|
|
# shellcheck source=./.functions
|
|
. "$script_dir/.functions"
|
|
trap "exit 0" INT HUP
|
|
info_$os "Parsing $base_url.. Please wait..."
|
|
|
|
#shellcheck disable=SC2016
|
|
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}}}'
|
|
[ -z "$1" ] && url=$(allanime_curl "query=$query" 'variables={"search":{"sortBy":"Recent","allowAdult":true,"allowUnknown":true},"limit":40,"page":1,"translationType":"sub","countryOrigin":"JP"}' | sed 's|Show|\n|g' | sed -nE 's|.*_id":"([^"]*)","name":"([^"]*)".*sub":\{"episodeString":"([^"]*)".*|\1\t\2 Episode \3|p' | menu_$os "Select Anime: " '--with-nth 2..' | tr ':' ' ' | tr -s ' ') || url=$(printf "%s" "$1" | sed -nE 's|.*/watch/(.*)-sub|\1|p')
|
|
|
|
[ -z "$url" ] && error_$os "No anime selected" && exit 0
|
|
title=$(printf "%s" "$url" | cut -f2-)
|
|
id=$(printf "%s" "$url" | cut -f1)
|
|
ep_no=$(printf "%s" "$url" | sed 's/.*Episode //g')
|
|
|
|
info_$os "Loading Episode $title.."
|
|
#shellcheck disable=SC2016
|
|
episode_embed_gql='query ($showId: String!, $translationType: VaildTranslationTypeEnumType!, $episodeString: String!) { episode( showId: $showId translationType: $translationType episodeString: $episodeString ) { episodeString sourceUrls }}'
|
|
data=$(allanime_curl "variables={\"showId\":\"$id\",\"translationType\":\"sub\",\"countryOrigin\":\"ALL\",\"episodeString\":\"$ep_no\"}" "query=$episode_embed_gql" | tr '{}' '\n' | sed 's|\\u002F|\/|g;s|\\||g' | sed -nE 's|.*sourceUrl":"--([^"]*)".*sourceName":"([^"]*)".*|\2 :\1|p')
|
|
info_$os "Fetching Embed links"
|
|
|
|
#dropbox links
|
|
provider_run "dropbox" "/Sak :/p" "$2"
|
|
|
|
#wetransfer links
|
|
provider_run "wetransfer" "/Kir :/p" "$2"
|
|
|
|
#sharepoint links
|
|
provider_run "sharepoint" "/S-mp4 :/p" "$2"
|
|
|
|
#gogoplay links
|
|
provider_run "gogoplay" "/Luf-mp4 :/p" "$2"
|
|
|
|
[ -z "$2" ] && error_$os "no more mirror links..sorry" && exit 0
|