diff --git a/bin/ani-cli b/bin/ani-cli
index ed93de6d2..574767b98 100755
--- a/bin/ani-cli
+++ b/bin/ani-cli
@@ -122,11 +122,11 @@ al_episode_list() {
process_hist_entry () {
temp_anime_id=$(printf "%s" "$anime_id" | sed 's/\t[0-9]*.$//')
- latest_ep=$(printf "%s" "$anime_id" | sed "s/$temp_anime_id\t//g")
+ current_ep=$(printf "%s" "$anime_id" | sed "s/$temp_anime_id\t//g")
episode_list "$temp_anime_id"
- current_ep=$last_ep_number
- if [ -n "$current_ep" ] && [ "$current_ep" -ge "$latest_ep" ]; then
- printf "%s\n" "$temp_anime_id"
+ latest_ep=$last_ep_number
+ if [ -n "$latest_ep" ] && [ "$latest_ep" -ge "$current_ep" ]; then
+ printf "%s : %s / %s\n" "$temp_anime_id" "$current_ep" "$latest_ep"
fi
}
@@ -346,7 +346,7 @@ anime_selection () {
done
fi
# Select respective anime_id
- selection_id="$(printf "%s" "$search_results" | sed -n "${choice}p")"
+ selection_id="$(printf "%s" "$search_results" | sed -n "${choice}p" | cut -d':' -f1 | tr -d ' ')"
progress "(Gogoanime) Searching Episodes.."
episode_list "$selection_id"
al_episode_list
diff --git a/hist_transition.sh b/hist_transition.sh
index 6baf0f321..58efe3c46 100755
--- a/hist_transition.sh
+++ b/hist_transition.sh
@@ -1,7 +1,7 @@
#!/bin/sh
histfile="${XDG_CACHE_HOME:-$HOME/.cache}/ani-hsts"
-base_url="https://gogoplay4.com"
+base_url="https://animixplay.to"
die () {
err "$*"
@@ -14,47 +14,36 @@ err () {
}
inf () {
- # display an informational message (first argument in green, second in magenta)
- printf "\033[1;32m%s \033[1;35m%s\033[0m\n" "$1" "$2"
+ # display an informational message
+ printf "\033[1;35m%s\033[0m\n" "$*"
}
search_anime () {
- search=$(printf '%s' "$1" | tr ' ' '-' )
- curl -s "$base_url/search.html" -G -d "keyword=$search" |
- sed -nE 's_^[[:space:]]*_\1_p'
-}
-
-extended_search () {
- indexing_url=$(curl -s -L -o /dev/null -w "%{url_effective}\n" https://gogoanime.cm)
- search=$(printf '%s' "$1" | tr ' ' '-' )
- curl -s "$indexing_url//search.html" -G -d "keyword=$search" |
- sed -n -E 's_^[[:space:]]*_\n_g' -e 's/\\//g' | sed -nE 's_.*a href="/v1/([^"]*)".*_\1_p' | head -1
}
update_entry () {
- query=$(printf "%s" "$anime_id" | sed 's/[0-9]*.$//' | sed 's/\t//')
- history_ep_number=$(printf "%s" "$anime_id" | sed "s/${query}\t//g")
- search_results=$(search_anime "$query")
- if [ -z "$search_results" ]; then
- extended_search_results=$(extended_search "$query")
- if [ -n "$extended_search_results" ]; then
- extended_search_results=$(printf '%s' "$extended_search_results" | head -n 1)
- search_results=$(search_anime "$extended_search_results")
- else
- err "Can't find ${query}, you'll have to add this to your history manually (by playing it). You have episode ${history_ep_number} coming up."
- return
- fi
+ query=$(printf "%s" "$anime_id" | sed 's/-episode.*//')
+ history_ep_number=$(printf "%s" "$anime_id" | sed "s/${query}-episode-//g")
+ search_result=$(search_anime "$query")
+ if [ -z "$search_result" ]; then
+ err "Can't find ${query}, you'll have to add this to your history manually (by playing it). You have episode ${history_ep_number} coming up."
+ return 0
fi
- printf "%s\n" "$search_results" | head -n 1 | sed "s/[0-9]*.$/${history_ep_number}/" | sed 's/\t//' >> "${histfile}.new"
+ printf "\033[1;32mFound Match for %s >> %s\n" "$query" "$search_result"
+ printf "%s\t%s\n" "$search_result" "$history_ep_number" >> "${histfile}.new"
}
inf "Transferring history..."
- search_results=$(cat "$histfile")
- [ -z "$search_results" ] && die "History is empty"
+ history_results=$(cat "$histfile")
+ [ -z "$history_results" ] && die "History is empty"
while read -r anime_id; do
update_entry &
done <<-EOF
- $search_results
+ $history_results
EOF
wait
- mv "${histfile}.new" "$histfile"
\ No newline at end of file
+ inf "Done.."
+ mv "${histfile}.new" "$histfile"