Commit a41f6592de

a41f6592de7fa43a910c295315dc731510ab77eb

parent: a992c39690

Unsigned

Wraient <wraient.911@gmail.com> · 2024-09-24 21:39 UTC

Absolute one file
Reasons for this change:
1. One file makes it easy for the user (maybe i will create a developement branch where there would be various diffrent files for ease of development)
2. Reasons from last commit
3. Monarchy is the best
4. Look at those line of code :yum_yum:
5.Yes, i really do like pain

Layout: unified · split

curd.py +185 −1
@@ -639,7 +639,7 @@ def get_contents_of(tmp_file_name):
639639 return temp_file.read()
640640
641641def run_script(script: str):
642 os.system(f"{current_dir}/scripts/{script}.sh")
642 os.system(f"/tmp/curd/{script}.sh")
643643
644644def write_to_tmp(tmp_filename:str, content:str):
645645 try:
@@ -784,8 +784,192 @@ def load_config() -> dict:
784784
785785 return config_dict
786786
787# ----------------------------------------------- Create Bash Script ----------------------------------------
788
789def create_anime_list():
790 script_path = "/tmp/curd/anime_list.sh"
791 with open(script_path, "w") as _:
792 _.write(r"""search_anime() {
793 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 } }}"
794
795 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|\
796|g' | sed -nE "s|.*_id\":\"([^\"]*)\",\"name\":\"([^\"]*)\".*${mode}\":([1-9][^,]*).*|\1 \2 (\3 episodes)NEWLINEFROMHERE|p"
797}
798
799agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0"
800allanime_refr="https://allanime.to"
801allanime_base="allanime.day"
802allanime_api="https://api.${allanime_base}"
803mode="${ANI_CLI_MODE:-sub}"
804download_dir="${ANI_CLI_DOWNLOAD_DIR:-.}"
805quality="${ANI_CLI_QUALITY:-best}"
806case "$(uname -a)" in
807 *Darwin*) player_function="${ANI_CLI_PLAYER:-iina}" ;; # mac OS
808 *ndroid*) player_function="${ANI_CLI_PLAYER:-android_mpv}" ;; # Android OS (termux)
809 *steamdeck*) player_function="${ANI_CLI_PLAYER:-flatpak_mpv}" ;; # steamdeck OS
810 *MINGW* | *WSL2*) player_function="${ANI_CLI_PLAYER:-mpv.exe}" ;; # Windows OS
811 *ish*) player_function="${ANI_CLI_PLAYER:-iSH}" ;; # iOS (iSH)
812 *) player_function="${ANI_CLI_PLAYER:-mpv}" ;; # Linux OS
813esac
814
815# Read the entire file content into a variable
816script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
817query=$(cat /tmp/curd/curd_query) # This is a shorthand for cat "$filename"
818
819# query="one piece"
820anime_list=$(search_anime "$query")
821
822echo $anime_list > /tmp/curd/curd_anime_list
823""")
824 os.chmod(script_path, 0o755)
825
826def create_episode_list():
827 script_path = "/tmp/curd/episode_list.sh"
828 with open(script_path, "w") as _:
829 _.write(r"""episodes_list() {
830 episodes_list_gql="query (\$showId: String!) { show( _id: \$showId ) { _id availableEpisodesDetail }}"
831
832 curl -e "$allanime_refr" -s -G "${allanime_api}/api" --data-urlencode "variables={\"showId\":\"$*\"}" --data-urlencode "query=$episodes_list_gql" -A "$agent" | sed -nE "s|.*$mode\":\[([0-9.\",]*)\].*|\1|p" | sed 's|,|\
833|g; s|"||g' | sort -n -k 1
834}
835
836# setup
837agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0"
838allanime_refr="https://allanime.to"
839allanime_base="allanime.day"
840allanime_api="https://api.${allanime_base}"
841mode="${ANI_CLI_MODE:-sub}"
842download_dir="${ANI_CLI_DOWNLOAD_DIR:-.}"
843quality="${ANI_CLI_QUALITY:-best}"
844case "$(uname -a)" in
845 *Darwin*) player_function="${ANI_CLI_PLAYER:-iina}" ;; # mac OS
846 *ndroid*) player_function="${ANI_CLI_PLAYER:-android_mpv}" ;; # Android OS (termux)
847 *steamdeck*) player_function="${ANI_CLI_PLAYER:-flatpak_mpv}" ;; # steamdeck OS
848 *MINGW* | *WSL2*) player_function="${ANI_CLI_PLAYER:-mpv.exe}" ;; # Windows OS
849 *ish*) player_function="${ANI_CLI_PLAYER:-iSH}" ;; # iOS (iSH)
850 *) player_function="${ANI_CLI_PLAYER:-mpv}" ;; # Linux OS
851esac
852script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
853id=$(cat /tmp/curd/curd_id)
854echo $(episodes_list "$id") > /tmp/curd/curd_episode_list
855""")
856 os.chmod(script_path, 0o755)
857
858def create_episode_url():
859 script_path = "/tmp/curd/episode_url.sh"
860 with open(script_path, "w") as _:
861 _.write(r"""# # extract the video links from response of embed urls, extract mp4 links form m3u8 lists
862get_links() {
863 episode_link="$(curl -e "$allanime_refr" -s "https://${allanime_base}$*" -A "$agent" | sed 's|},{|\
864|g' | sed -nE 's|.*link":"([^"]*)".*"resolutionStr":"([^"]*)".*|\2 >\1|p;s|.*hls","url":"([^"]*)".*"hardsub_lang":"en-US".*|\1|p')"
865
866 case "$episode_link" in
867 *repackager.wixmp.com*)
868 extract_link=$(printf "%s" "$episode_link" | cut -d'>' -f2 | sed 's|repackager.wixmp.com/||g;s|\.urlset.*||g')
869 for j in $(printf "%s" "$episode_link" | sed -nE 's|.*/,([^/]*),/mp4.*|\1|p' | sed 's|,|\
870|g'); do
871 printf "%s >%s\n" "$j" "$extract_link" | sed "s|,[^/]*|${j}|g"
872 done | sort -nr
873 ;;
874 *vipanicdn* | *anifastcdn*)
875 if printf "%s" "$episode_link" | head -1 | grep -q "original.m3u"; then
876 printf "%s" "$episode_link"
877 else
878 extract_link=$(printf "%s" "$episode_link" | head -1 | cut -d'>' -f2)
879 relative_link=$(printf "%s" "$extract_link" | sed 's|[^/]*$||')
880 curl -e "$allanime_refr" -s "$extract_link" -A "$agent" | sed 's|^#.*x||g; s|,.*|p|g; /^#/d; $!N; s|\
881| >|' | sed "s|>|>${relative_link}|g" | sort -nr
882 fi
883 ;;
884 *) [ -n "$episode_link" ] && printf "%s\n" "$episode_link" ;;
885 esac
886 # echo $episode_link >> links
887 # [ -z "$ANI_CLI_NON_INTERACTIVE" ] && printf "\033[1;32m%s\033[0m Links Fetched\n" "$provider_name" 1>&2
888 [ -z "$ANI_CLI_NON_INTERACTIVE" ] 1>&2
889}
890
891# # innitialises provider_name and provider_id. First argument is the provider name, 2nd is the regex that matches that provider's link
892provider_init() {
893 provider_name=$1
894 provider_id=$(printf "%s" "$resp" | sed -n "$2" | head -1 | cut -d':' -f2 | sed 's/../&\
895/g' | sed 's/^01$/9/g;s/^08$/0/g;s/^05$/=/g;s/^0a$/2/g;s/^0b$/3/g;s/^0c$/4/g;s/^07$/?/g;s/^00$/8/g;s/^5c$/d/g;s/^0f$/7/g;s/^5e$/f/g;s/^17$/\//g;s/^54$/l/g;s/^09$/1/g;s/^48$/p/g;s/^4f$/w/g;s/^0e$/6/g;s/^5b$/c/g;s/^5d$/e/g;s/^0d$/5/g;s/^53$/k/g;s/^1e$/\&/g;s/^5a$/b/g;s/^59$/a/g;s/^4a$/r/g;s/^4c$/t/g;s/^4e$/v/g;s/^57$/o/g;s/^51$/i/g;' | tr -d '\n' | sed "s/\/clock/\/clock\.json/")
896}
897
898# # +s links based on given provider
899generate_link() {
900 case $1 in
901 1) provider_init "wixmp" "/Default :/p" ;; # wixmp(default)(m3u8)(multi) -> (mp4)(multi)
902 2) provider_init "dropbox" "/Sak :/p" ;; # dropbox(mp4)(single)
903 3) provider_init "wetransfer" "/Kir :/p" ;; # wetransfer(mp4)(single)
904 4) provider_init "sharepoint" "/S-mp4 :/p" ;; # sharepoint(mp4)(single)
905 *) provider_init "gogoanime" "/Luf-mp4 :/p" ;; # gogoanime(m3u8)(multi)
906 esac
907 [ -n "$provider_id" ] && get_links "$provider_id"
908 # echo $links >> links
909}
910
911select_quality() {
912 case "$1" in
913 best) result=$(printf "%s" "$links" | head -n1) ;;
914 worst) result=$(printf "%s" "$links" | grep -E '^[0-9]{3,4}' | tail -n1) ;;
915 *) result=$(printf "%s" "$links" | grep -m 1 "$1") ;;
916 esac
917 [ -z "$result" ] && printf "Specified quality not found, defaulting to best\n" 1>&2 && result=$(printf "%s" "$links" | head -n1)
918 printf "%s" "$result" | cut -d'>' -f2
919}
920
921script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
922# # gets embed urls, collects direct links into provider files, selects one with desired quality into $episode
923get_episode_url() {
924 # get the embed urls of the selected episode
925 episode_embed_gql="query (\$showId: String!, \$translationType: VaildTranslationTypeEnumType!, \$episodeString: String!) { episode( showId: \$showId translationType: \$translationType episodeString: \$episodeString ) { episodeString sourceUrls }}"
926
927 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')
928 # generate links into sequential files
929 cache_dir="$(mktemp -d)"
930 providers="1 2 3 4 5"
931 for provider in $providers; do
932 generate_link "$provider" >"$cache_dir"/"$provider" &
933 done
934 wait
935 # echo $links > links
936 # select the link with matching quality
937 links=$(cat "$cache_dir"/* | sed 's|^Mp4-||g;/http/!d' | sort -g -r -s)
938 rm -r "$cache_dir"
939 episode=$(select_quality "$quality")
940 echo $links > /tmp/curd/curd_links
941 [ -z "$episode" ] && die "Episode not released!"
942}
943
944# setup
945agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0"
946allanime_refr="https://allanime.to"
947allanime_base="allanime.day"
948allanime_api="https://api.${allanime_base}"
949sub_or_dub=$(cat /tmp/curd/curd_mode)
950mode="${ANI_CLI_MODE:-$sub_or_dub}"
951download_dir="${ANI_CLI_DOWNLOAD_DIR:-.}"
952quality="${ANI_CLI_QUALITY:-best}"
953case "$(uname -a)" in
954 *Darwin*) player_function="${ANI_CLI_PLAYER:-iina}" ;; # mac OS
955 *ndroid*) player_function="${ANI_CLI_PLAYER:-android_mpv}" ;; # Android OS (termux)
956 *steamdeck*) player_function="${ANI_CLI_PLAYER:-flatpak_mpv}" ;; # steamdeck OS
957 *MINGW* | *WSL2*) player_function="${ANI_CLI_PLAYER:-mpv.exe}" ;; # Windows OS
958 *ish*) player_function="${ANI_CLI_PLAYER:-iSH}" ;; # iOS (iSH)
959 *) player_function="${ANI_CLI_PLAYER:-mpv}" ;; # Linux OS
960esac
961id=$(cat /tmp/curd/curd_id)
962ep_no=$(cat /tmp/curd/curd_ep_no)
963get_episode_url
964""")
965 os.chmod(script_path, 0o755)
966
787967# ----------------------------------------------- Start of script ----------------------------------------
788968
969create_anime_list()
970create_episode_list()
971create_episode_url()
972
789973current_dir = Path(__file__).parent
790974# current_dir = os.path.dirname(os.path.abspath(__file__))
791975# print(current_dir)
scripts/anime_list.sh deleted −31
@@ -1,31 +0,0 @@
1search_anime() {
2 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 } }}"
3
4 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|\
5|g' | sed -nE "s|.*_id\":\"([^\"]*)\",\"name\":\"([^\"]*)\".*${mode}\":([1-9][^,]*).*|\1 \2 (\3 episodes)NEWLINEFROMHERE|p"
6}
7
8agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0"
9allanime_refr="https://allanime.to"
10allanime_base="allanime.day"
11allanime_api="https://api.${allanime_base}"
12mode="${ANI_CLI_MODE:-sub}"
13download_dir="${ANI_CLI_DOWNLOAD_DIR:-.}"
14quality="${ANI_CLI_QUALITY:-best}"
15case "$(uname -a)" in
16 *Darwin*) player_function="${ANI_CLI_PLAYER:-iina}" ;; # mac OS
17 *ndroid*) player_function="${ANI_CLI_PLAYER:-android_mpv}" ;; # Android OS (termux)
18 *steamdeck*) player_function="${ANI_CLI_PLAYER:-flatpak_mpv}" ;; # steamdeck OS
19 *MINGW* | *WSL2*) player_function="${ANI_CLI_PLAYER:-mpv.exe}" ;; # Windows OS
20 *ish*) player_function="${ANI_CLI_PLAYER:-iSH}" ;; # iOS (iSH)
21 *) player_function="${ANI_CLI_PLAYER:-mpv}" ;; # Linux OS
22esac
23
24# Read the entire file content into a variable
25script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
26query=$(cat /tmp/curd/curd_query) # This is a shorthand for cat "$filename"
27
28# query="one piece"
29anime_list=$(search_anime "$query")
30
31echo $anime_list > /tmp/curd/curd_anime_list
scripts/episode_list.sh deleted −26
@@ -1,26 +0,0 @@
1episodes_list() {
2 episodes_list_gql="query (\$showId: String!) { show( _id: \$showId ) { _id availableEpisodesDetail }}"
3
4 curl -e "$allanime_refr" -s -G "${allanime_api}/api" --data-urlencode "variables={\"showId\":\"$*\"}" --data-urlencode "query=$episodes_list_gql" -A "$agent" | sed -nE "s|.*$mode\":\[([0-9.\",]*)\].*|\1|p" | sed 's|,|\
5|g; s|"||g' | sort -n -k 1
6}
7
8# setup
9agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0"
10allanime_refr="https://allanime.to"
11allanime_base="allanime.day"
12allanime_api="https://api.${allanime_base}"
13mode="${ANI_CLI_MODE:-sub}"
14download_dir="${ANI_CLI_DOWNLOAD_DIR:-.}"
15quality="${ANI_CLI_QUALITY:-best}"
16case "$(uname -a)" in
17 *Darwin*) player_function="${ANI_CLI_PLAYER:-iina}" ;; # mac OS
18 *ndroid*) player_function="${ANI_CLI_PLAYER:-android_mpv}" ;; # Android OS (termux)
19 *steamdeck*) player_function="${ANI_CLI_PLAYER:-flatpak_mpv}" ;; # steamdeck OS
20 *MINGW* | *WSL2*) player_function="${ANI_CLI_PLAYER:-mpv.exe}" ;; # Windows OS
21 *ish*) player_function="${ANI_CLI_PLAYER:-iSH}" ;; # iOS (iSH)
22 *) player_function="${ANI_CLI_PLAYER:-mpv}" ;; # Linux OS
23esac
24script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
25id=$(cat /tmp/curd/curd_id)
26echo $(episodes_list "$id") > /tmp/curd/curd_episode_list
scripts/episode_url.sh deleted −103
@@ -1,103 +0,0 @@
1# # extract the video links from response of embed urls, extract mp4 links form m3u8 lists
2get_links() {
3 episode_link="$(curl -e "$allanime_refr" -s "https://${allanime_base}$*" -A "$agent" | sed 's|},{|\
4|g' | sed -nE 's|.*link":"([^"]*)".*"resolutionStr":"([^"]*)".*|\2 >\1|p;s|.*hls","url":"([^"]*)".*"hardsub_lang":"en-US".*|\1|p')"
5
6 case "$episode_link" in
7 *repackager.wixmp.com*)
8 extract_link=$(printf "%s" "$episode_link" | cut -d'>' -f2 | sed 's|repackager.wixmp.com/||g;s|\.urlset.*||g')
9 for j in $(printf "%s" "$episode_link" | sed -nE 's|.*/,([^/]*),/mp4.*|\1|p' | sed 's|,|\
10|g'); do
11 printf "%s >%s\n" "$j" "$extract_link" | sed "s|,[^/]*|${j}|g"
12 done | sort -nr
13 ;;
14 *vipanicdn* | *anifastcdn*)
15 if printf "%s" "$episode_link" | head -1 | grep -q "original.m3u"; then
16 printf "%s" "$episode_link"
17 else
18 extract_link=$(printf "%s" "$episode_link" | head -1 | cut -d'>' -f2)
19 relative_link=$(printf "%s" "$extract_link" | sed 's|[^/]*$||')
20 curl -e "$allanime_refr" -s "$extract_link" -A "$agent" | sed 's|^#.*x||g; s|,.*|p|g; /^#/d; $!N; s|\
21| >|' | sed "s|>|>${relative_link}|g" | sort -nr
22 fi
23 ;;
24 *) [ -n "$episode_link" ] && printf "%s\n" "$episode_link" ;;
25 esac
26 # echo $episode_link >> links
27 # [ -z "$ANI_CLI_NON_INTERACTIVE" ] && printf "\033[1;32m%s\033[0m Links Fetched\n" "$provider_name" 1>&2
28 [ -z "$ANI_CLI_NON_INTERACTIVE" ] 1>&2
29}
30
31# # innitialises provider_name and provider_id. First argument is the provider name, 2nd is the regex that matches that provider's link
32provider_init() {
33 provider_name=$1
34 provider_id=$(printf "%s" "$resp" | sed -n "$2" | head -1 | cut -d':' -f2 | sed 's/../&\
35/g' | sed 's/^01$/9/g;s/^08$/0/g;s/^05$/=/g;s/^0a$/2/g;s/^0b$/3/g;s/^0c$/4/g;s/^07$/?/g;s/^00$/8/g;s/^5c$/d/g;s/^0f$/7/g;s/^5e$/f/g;s/^17$/\//g;s/^54$/l/g;s/^09$/1/g;s/^48$/p/g;s/^4f$/w/g;s/^0e$/6/g;s/^5b$/c/g;s/^5d$/e/g;s/^0d$/5/g;s/^53$/k/g;s/^1e$/\&/g;s/^5a$/b/g;s/^59$/a/g;s/^4a$/r/g;s/^4c$/t/g;s/^4e$/v/g;s/^57$/o/g;s/^51$/i/g;' | tr -d '\n' | sed "s/\/clock/\/clock\.json/")
36}
37
38# # +s links based on given provider
39generate_link() {
40 case $1 in
41 1) provider_init "wixmp" "/Default :/p" ;; # wixmp(default)(m3u8)(multi) -> (mp4)(multi)
42 2) provider_init "dropbox" "/Sak :/p" ;; # dropbox(mp4)(single)
43 3) provider_init "wetransfer" "/Kir :/p" ;; # wetransfer(mp4)(single)
44 4) provider_init "sharepoint" "/S-mp4 :/p" ;; # sharepoint(mp4)(single)
45 *) provider_init "gogoanime" "/Luf-mp4 :/p" ;; # gogoanime(m3u8)(multi)
46 esac
47 [ -n "$provider_id" ] && get_links "$provider_id"
48 # echo $links >> links
49}
50
51select_quality() {
52 case "$1" in
53 best) result=$(printf "%s" "$links" | head -n1) ;;
54 worst) result=$(printf "%s" "$links" | grep -E '^[0-9]{3,4}' | tail -n1) ;;
55 *) result=$(printf "%s" "$links" | grep -m 1 "$1") ;;
56 esac
57 [ -z "$result" ] && printf "Specified quality not found, defaulting to best\n" 1>&2 && result=$(printf "%s" "$links" | head -n1)
58 printf "%s" "$result" | cut -d'>' -f2
59}
60
61script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
62# # gets embed urls, collects direct links into provider files, selects one with desired quality into $episode
63get_episode_url() {
64 # get the embed urls of the selected episode
65 episode_embed_gql="query (\$showId: String!, \$translationType: VaildTranslationTypeEnumType!, \$episodeString: String!) { episode( showId: \$showId translationType: \$translationType episodeString: \$episodeString ) { episodeString sourceUrls }}"
66
67 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')
68 # generate links into sequential files
69 cache_dir="$(mktemp -d)"
70 providers="1 2 3 4 5"
71 for provider in $providers; do
72 generate_link "$provider" >"$cache_dir"/"$provider" &
73 done
74 wait
75 # echo $links > links
76 # select the link with matching quality
77 links=$(cat "$cache_dir"/* | sed 's|^Mp4-||g;/http/!d' | sort -g -r -s)
78 rm -r "$cache_dir"
79 episode=$(select_quality "$quality")
80 echo $links > /tmp/curd/curd_links
81 [ -z "$episode" ] && die "Episode not released!"
82}
83
84# setup
85agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0"
86allanime_refr="https://allanime.to"
87allanime_base="allanime.day"
88allanime_api="https://api.${allanime_base}"
89sub_or_dub=$(cat /tmp/curd/curd_mode)
90mode="${ANI_CLI_MODE:-$sub_or_dub}"
91download_dir="${ANI_CLI_DOWNLOAD_DIR:-.}"
92quality="${ANI_CLI_QUALITY:-best}"
93case "$(uname -a)" in
94 *Darwin*) player_function="${ANI_CLI_PLAYER:-iina}" ;; # mac OS
95 *ndroid*) player_function="${ANI_CLI_PLAYER:-android_mpv}" ;; # Android OS (termux)
96 *steamdeck*) player_function="${ANI_CLI_PLAYER:-flatpak_mpv}" ;; # steamdeck OS
97 *MINGW* | *WSL2*) player_function="${ANI_CLI_PLAYER:-mpv.exe}" ;; # Windows OS
98 *ish*) player_function="${ANI_CLI_PLAYER:-iSH}" ;; # iOS (iSH)
99 *) player_function="${ANI_CLI_PLAYER:-mpv}" ;; # Linux OS
100esac
101id=$(cat /tmp/curd/curd_id)
102ep_no=$(cat /tmp/curd/curd_ep_no)
103get_episode_url