I don't know why. Just move on.

This commit is contained in:
coolnsx
2024-05-14 16:45:28 +05:30
parent 19a2f9f1e7
commit 95b3b0b284
7 changed files with 43 additions and 51 deletions

28
ani-new
View File

@@ -1,28 +1,19 @@
#!/bin/sh
allanime_curl() {
curl -e "https://allanime.to" -sL -G "https://api.${domain}/api" -A "$agent" --data-urlencode "$1" --data-urlencode "$2"
}
domain="allanime.day"
run_file="${TMPDIR:-/tmp}/${0##*/}_run"
agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/12$(head /dev/urandom | tr -dc '0-3' | 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":"ALL"}' | 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"
\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":"ALL"}' | 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 source=/tmp/ani-new_run
. "$run_file"
case $(uname -o) in
*ndroid*)
os="droid"
@@ -39,12 +30,13 @@ esac
# shellcheck source=./.functions
. "$script_dir/.functions"
. "$run_file"
trap "exit 0" INT HUP
info_$os "Parsing $domain.. Please wait..."
#shellcheck disable=SC2016
[ -z "$1" ] && url=$(search | fzf --bind="change:reload:$run_file {q} 1" --prompt="Select Anime: " --with-nth 2.. -m | tr ':' ' ' | tr -s ' ') || url=$(printf "%s" "$1" | sed -nE 's|.*/bangumi/([^/]*)/([^/]*)/p-([^-]*)-sub|\1\t\2 Episode \3|p')
[ -z "$1" ] && url=$(search | (
[ "$os" != "linux" ] && fzf --bind="change:reload:$run_file {q} 1" --prompt="Select Anime: " --with-nth 2.. -m || menu_$os "Select Anime: "
) | tr ':' ' ' | tr -s ' ') || url=$(printf "%s" "$1" | sed -nE 's|.*/bangumi/([^/]*)/([^/]*)/p-([^-]*)-sub|\1\t\2 Episode \3|p')
[ -z "$url" ] && error_$os "No anime selected" && exit 0
@@ -55,7 +47,7 @@ printf "%s\n" "$url" | while read -r id title; do
[ -n "$debug" ] && printf "\n\033[1;36m title\033[0m : %s\n" "$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')
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