From 409b37256031226f8b2409e65c951c12b7a98c3b Mon Sep 17 00:00:00 2001 From: coolnsx Date: Wed, 27 Sep 2023 22:15:31 +0530 Subject: [PATCH] speling is difikult --- .functions | 4 +- ani-new | 108 +++++++++++++++++++++++++---------------------------- 2 files changed, 53 insertions(+), 59 deletions(-) diff --git a/.functions b/.functions index 61b560f..f3fa0c3 100644 --- a/.functions +++ b/.functions @@ -5,7 +5,7 @@ menu_droid() { } menu_linux() { - bemenu --fn 'Cascadia Mono 15' -i -c -W "0.${3:-6}" -B 3 -l 25 -p "$1" --fixed-height 25 + bemenu --fn 'Cascadia Mono 15' -i -c -W "0.${3:-6}" -B 3 -l 25 -p "$1" } search_droid() { @@ -45,5 +45,5 @@ player_droid() { } player_linux() { - setsid -f mpv "$1" --force-media-title="$2" + mpv "$1" --force-media-title="$2" } diff --git a/ani-new b/ani-new index ef905a2..b39384e 100755 --- a/ani-new +++ b/ani-new @@ -1,22 +1,5 @@ #!/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 "??" '' "2") - [ -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 -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 @@ -29,26 +12,14 @@ decrypt_allanime() { 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" + curl -e "https://allanime.to" -sL --cipher AES256-SHA256 -G "https://api.${domain}/api" -A "$agent" --data-urlencode "$1" --data-urlencode "$2" } -base_url="https://api.allanime.day" -agent="Mozilla/5.0" -[ -n "$2" ] && debug=1 +domain="allanime.day" +random_no=$(head /dev/urandom | tr -dc '3-7' | cut -c1) +agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/11${random_no}.0.0.0 Safari/537.36" +debug=$2 case $(uname -o) in *ndroid*) @@ -59,7 +30,7 @@ case $(uname -o) in *) os="linux" download_dir="$HOME/Downloads" - terminal="$TERMINAL -e" + terminal="${TERMINAL:-foot} -e" script_dir="$HOME/repos_scripts" ;; esac @@ -67,33 +38,56 @@ esac # shellcheck source=./.functions . "$script_dir/.functions" trap "exit 0" INT HUP -info_$os "Parsing $base_url.. Please wait..." +info_$os "Parsing $domain.. 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 "$1" ] && url=$(allanime_curl '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}}}' '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.. -m' | tr ':' ' ' | tr -s ' ') || url=$(printf "%s" "$1" | sed -nE 's|.*/bangumi/([^/]*)/([^/]*)/.*episode-([^-]*)-sub|\1\t\2 Episode \3|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" +printf "%s\n" "$url" | while read -r id title; do + ep_no=$(printf "%s" "$title" | sed 's/.*Episode //g') -#dropbox links -provider_run "dropbox" "/Sak :/p" "$2" + info_$os "Loading Episode $title.." + #shellcheck disable=SC2016 + data=$(allanime_curl "variables={\"showId\":\"$id\",\"translationType\":\"sub\",\"countryOrigin\":\"ALL\",\"episodeString\":\"$ep_no\"}" '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" -#wetransfer links -provider_run "wetransfer" "/Kir :/p" "$2" + 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="$(decrypt_allanime "$(printf "%s" "$data" | sed -n "/$provider_regex :/p" | head -1 | cut -d':' -f2)" | sed "s/\/clock/\/clock\.json/")" + [ -z "$provider_id" ] && return 0 + 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" ] && return 0 + [ -n "$debug" ] && printf "\033[1;32m %s\033[0m : %s\n" "$provider_name" "$provider_video" && return 0 + info_$os "$provider_name links fetched.." + choice=$(printf "stream\ndownload\ncast\nnext_mirror\nnext_anime" | menu_$os "??" '' "2") + [ -z "$choice" ] && exit 0 + case $choice in + stream) + info_$os "opening $title" "mpv" + player_$os "$provider_video" "$title" + ;; + cast) + info_$os "casting $title" "podcast" + catt cast "$provider_video" + ;; + *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" && break ;; + *) $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" && break ;; + esac + info_$os "Episode Downloaded $title" + ;; + *) + break + ;; + esac + done -#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 + [ -z "$debug" ] && error_$os "no more mirror links..sorry" +done