Skip to content

Commit

Permalink
Merge branch 'master' into Add-Carapace,-multi-shell-autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
port19x authored Oct 17, 2024
2 parents 60f0b04 + d82b787 commit 94c0039
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -581,3 +581,5 @@ Ani-skip uses the external lua script function of mpv and as such – for now
* [redqu](https://github.com/port19x/redqu): A media centric reddit client (Clojure)
* [doccli](https://github.com/TowarzyszFatCat/doccli): A cli to watch anime with POLISH subtitles (Python)
* [GoAnime](https://github.com/alvarorichard/GoAnime): A CLI tool to browse, play, and download anime in Portuguese(Go)
* [Curd](https://github.com/Wraient/curd): A CLI tool to watch anime with Anilist, Discord RPC, Skip Intro Outro (Python)
- [FastAnime](https://github.com/Benex254/FastAnime): browser anime experience from the terminal (Python)
34 changes: 23 additions & 11 deletions ani-cli
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

version_number="4.9.3"
version_number="4.9.5"

# UI

Expand Down Expand Up @@ -133,6 +133,13 @@ get_links() {
|g' | sed -nE 's|.*link":"([^"]*)".*"resolutionStr":"([^"]*)".*|\2 >\1|p;s|.*hls","url":"([^"]*)".*"hardsub_lang":"en-US".*|\1|p')"

case "$episode_link" in
*repackager.wixmp.com*)
extract_link=$(printf "%s" "$episode_link" | cut -d'>' -f2 | sed 's|repackager.wixmp.com/||g;s|\.urlset.*||g')
for j in $(printf "%s" "$episode_link" | sed -nE 's|.*/,([^/]*),/mp4.*|\1|p' | sed 's|,|\
|g'); do
printf "%s >%s\n" "$j" "$extract_link" | sed "s|,[^/]*|${j}|g"
done | sort -nr
;;
*vipanicdn* | *anifastcdn*)
if printf "%s" "$episode_link" | head -1 | grep -q "original.m3u"; then
printf "%s" "$episode_link"
Expand All @@ -158,9 +165,10 @@ provider_init() {
# generates links based on given provider
generate_link() {
case $1 in
1) provider_init "dropbox" "/Sak :/p" ;; # dropbox(mp4)(single)
2) provider_init "wetransfer" "/Kir :/p" ;; # wetransfer(mp4)(single)
3) provider_init "sharepoint" "/S-mp4 :/p" ;; # sharepoint(mp4)(single)
1) provider_init "wixmp" "/Default :/p" ;; # wixmp(default)(m3u8)(multi) -> (mp4)(multi)
2) provider_init "dropbox" "/Sak :/p" ;; # dropbox(mp4)(single)
3) provider_init "wetransfer" "/Kir :/p" ;; # wetransfer(mp4)(single)
4) provider_init "sharepoint" "/S-mp4 :/p" ;; # sharepoint(mp4)(single)
*) provider_init "gogoanime" "/Luf-mp4 :/p" ;; # gogoanime(m3u8)(multi)
esac
[ -n "$provider_id" ] && get_links "$provider_id"
Expand All @@ -184,7 +192,7 @@ get_episode_url() {
resp=$(curl -e "$allanime_refr" -s -G "${allanime_api}/api" --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
cache_dir="$(mktemp -d)"
providers="1 2 3 4"
providers="1 2 3 4 5"
for provider in $providers; do
generate_link "$provider" >"$cache_dir"/"$provider" &
done
Expand All @@ -193,15 +201,19 @@ get_episode_url() {
links=$(cat "$cache_dir"/* | sed 's|^Mp4-||g;/http/!d;/Alt/d' | sort -g -r -s)
rm -r "$cache_dir"
episode=$(select_quality "$quality")
[ -z "$episode" ] && die "Episode not released!"
if printf "%s" "$ep_list" | grep -q "^$ep_no$"; then
[ -z "$episode" ] && die "Episode is released, but no valid sources!"
else
[ -z "$episode" ] && die "Episode not released!"
fi
}

# search the query and give results
search_anime() {
search_gql="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 availableEpisodes __typename } }}"

curl -e "$allanime_refr" -s -G "${allanime_api}/api" --data-urlencode "variables={\"search\":{\"allowAdult\":false,\"allowUnknown\":false,\"query\":\"$1\"},\"limit\":40,\"page\":1,\"translationType\":\"$mode\",\"countryOrigin\":\"ALL\"}" --data-urlencode "query=$search_gql" -A "$agent" | sed 's|Show|\
|g' | sed -nE "s|.*_id\":\"([^\"]*)\",\"name\":\"([^\"]*)\".*${mode}\":([1-9][^,]*).*|\1 \2 (\3 episodes)|p"
| g' | sed -nE "s|.*_id\":\"([^\"]*)\",\"name\":\"(.+)\",.*${mode}\":([1-9][^,]*).*|\1 \2 (\3 episodes)|p" | sed 's/\\"//g'
}

time_until_next_ep() {
Expand Down Expand Up @@ -237,7 +249,7 @@ process_hist_entry() {

update_history() {
if grep -q -- "$id" "$histfile"; then
sed -E "s|^[^\t]+\t${id}\t[^\t]+$|${ep_no}\t${id}\t${title}|" "$histfile" >"${histfile}.new"
sed -E "s|^[^ ]+ ${id} [^ ]+$|${ep_no} ${id} ${title}|" "$histfile" >"${histfile}.new"
else
cp "$histfile" "${histfile}.new"
printf "%s\t%s\t%s\n" "$ep_no" "$id" "$title" >>"${histfile}.new"
Expand Down Expand Up @@ -328,14 +340,14 @@ play() {

# setup
agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0"
allanime_refr="https://allanime.to"
allanime_refr="https://allmanga.to"
allanime_base="allanime.day"
allanime_api="https://api.${allanime_base}"
mode="${ANI_CLI_MODE:-sub}"
download_dir="${ANI_CLI_DOWNLOAD_DIR:-.}"
log_episode="${ANI_CLI_LOG:-1}"
quality="${ANI_CLI_QUALITY:-best}"
case "$(uname -a)" in
case "$(uname -a | cut -d " " -f 1,3-)" in
*Darwin*) player_function="${ANI_CLI_PLAYER:-$(where_iina)}" ;; # mac OS
*ndroid*) player_function="${ANI_CLI_PLAYER:-android_mpv}" ;; # Android OS (termux)
*MINGW* | *WSL2*) player_function="${ANI_CLI_PLAYER:-mpv.exe}" ;; # Windows OS
Expand All @@ -359,7 +371,7 @@ search="${ANI_CLI_DEFAULT_SOURCE:-scrape}"
while [ $# -gt 0 ]; do
case "$1" in
-v | --vlc)
case "$(uname -a)" in
case "$(uname -a | cut -d " " -f 1,3-)" in
*ndroid*) player_function="android_vlc" ;;
MINGW* | *WSL2*) player_function="vlc.exe" ;;
*ish*) player_function="iSH" ;;
Expand Down

0 comments on commit 94c0039

Please sign in to comment.