Skip to content

Commit

Permalink
fix: allanime scraping (#1139)
Browse files Browse the repository at this point in the history
Co-authored-by: zen <[email protected]>

Unusually early x.x bump due to major outage
  • Loading branch information
justchokingaround authored Jun 5, 2023
1 parent a4c6117 commit 26b98b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 5 additions & 3 deletions ani-cli
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

version_number="4.3.1"
version_number="4.4.0"

# UI

Expand Down Expand Up @@ -106,7 +106,7 @@ dep_ch() {

# extract the video links from reponse of embed urls, extract mp4 links form m3u8 lists
get_links() {
episode_link="$(curl -e "https://${allanime_base}" -s --cipher "AES256-SHA256" "https://allanimenews.com/apivtwo/clock.json?id=$*" -A "$agent" | sed 's|},{|\n|g' | sed -nE 's|.*link":"([^"]*)".*"resolutionStr":"([^"]*)".*|\2 >\1|p;s|.*hls","url":"([^"]*)".*"hardsub_lang":"en-US".*|\1|p')"
episode_link="$(curl -e "https://${allanime_base}" -s --cipher "AES256-SHA256" "https://allanimenews.com$*" -A "$agent" | sed 's|},{|\n|g' | sed -nE 's|.*link":"([^"]*)".*"resolutionStr":"([^"]*)".*|\2 >\1|p;s|.*hls","url":"([^"]*)".*"hardsub_lang":"en-US".*|\1|p')"
case "$episode_link" in
*crunchyroll*)
curl -e "https://${allanime_base}" -s --cipher "AES256-SHA256" "$episode_link" -A "$agent" | sed 's|^#.*x||g; s|,.*|p|g; /^#/d; $!N; s|\n| >|' | sort -nr
Expand Down Expand Up @@ -147,6 +147,8 @@ generate_link() {
5) provider_init 'usercloud' '/Uv-mp4 :/p' ;; # usercloud(mp4)(single)
*) provider_init 'gogoanime' '/Luf-mp4 :/p' ;; # gogoanime(m3u8)(multi)
esac
hexadecimal_provider_id="$(printf "%s" "$provider_id" | sed 's/\(..\)/\\x\1/g')"
provider_id=$(printf "%b" "$hexadecimal_provider_id" | sed "s/\/clock/\/clock\.json/")
[ -n "$provider_id" ] && get_links "$provider_id"
}

Expand All @@ -165,7 +167,7 @@ get_episode_url() {
# get the embed urls of the selected episode
episode_embed_gql="query (\$showId: String!, \$translationType: VaildTranslationTypeEnumType!, \$episodeString: String!) { episode( showId: \$showId translationType: \$translationType episodeString: \$episodeString ) { episodeString sourceUrls }}"

resp=$(curl -e "https://${allanime_base}" -s --cipher "AES256-SHA256" -G "https://api.${allanime_base}/allanimeapi" --data-urlencode "variables={\"showId\":\"$id\",\"translationType\":\"$mode\",\"episodeString\":\"$ep_no\"}" --data-urlencode "query=$episode_embed_gql" -A "$agent" | tr '{}' '\n' | sed 's|\\u002F|\/|g;s|\\||g' | sed -nE 's|.*sourceUrl":".*clock\?id=([^"]*)".*sourceName":"([^"]*)".*|\2 :\1|p')
resp=$(curl -e "https://${allanime_base}" -s --cipher "AES256-SHA256" -G "https://api.${allanime_base}/allanimeapi" --data-urlencode "variables={\"showId\":\"$id\",\"translationType\":\"$mode\",\"episodeString\":\"$ep_no\"}" --data-urlencode "query=$episode_embed_gql" -A "$agent" | tr '{}' '\n' | sed 's|\\u002F|\/|g;s|\\||g' | sed -nE 's|.*sourceUrl":"#([^"]*)".*sourceName":"([^"]*)".*|\2 :\1|p')
# generate links into sequential files
provider=1
i=0
Expand Down
9 changes: 6 additions & 3 deletions ani-cli.1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This tool scrapes the site allanime.
.PD 0
.P
.PD
\f[B]ani-cli\f[R] without options defaults to iina on macOS, flatpak mpv on Steamdeck, mpv apk on android and mpv media player everywhere else.
\f[B]ani-cli\f[R] without options defaults to iina on macOS, flatpak mpv on Steamdeck, mpv apk on android, vlc on iOS and mpv media player everywhere else.
.SH OPTIONS
.TP
\fB\-e | --episode | -r | --range\fR \fI\,<episode>\/\fR
Expand Down Expand Up @@ -46,8 +46,11 @@ Fetch update from github.
\fB\-v | --vlc\fR
Use VLC as the media player.
.TP
\fB\-V | --version\fR
Print version number and exit.
\fB\-N | --non-interactive\fR
Disable the interactive menu.
.TP
\fB\-S | --select-nth\fR \fI\,<index>\/\fR
Selects nth entry.
.TP
\fB\--dub\fR
Play the dubbed version. Without this flag, it'll always play the subbed version.
Expand Down

0 comments on commit 26b98b4

Please sign in to comment.