mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-10-28 04:44:11 -07:00
fix ordering of episode numbers
This commit is contained in:
parent
2912950366
commit
f363d2fca5
121
ani-cli
121
ani-cli
@ -363,7 +363,8 @@ open_episode() {
|
||||
err "Episode out of range"
|
||||
stmt="SELECT DISTINCT episode_number \
|
||||
FROM watch_history \
|
||||
WHERE anime_name = '$anime_id';"
|
||||
WHERE anime_name = '$anime_id' \
|
||||
ORDER BY episode_number ASC;"
|
||||
# hist=$(echo "$stmt" | sqlite3 "$history_db" | awk '{ if ( NR > 2 ) { print } }')
|
||||
hist=$(run_stmt "$stmt")
|
||||
if [[ "$VERBOSE" -eq 1 ]]; then
|
||||
@ -383,17 +384,17 @@ open_episode() {
|
||||
video_url=$(get_links "$dpage_url")
|
||||
|
||||
case $video_url in
|
||||
*streamtape*)
|
||||
# If direct download not available then scrape streamtape.com
|
||||
BROWSER=${BROWSER:-firefox}
|
||||
printf "scraping streamtape.com\n"
|
||||
video_url=$(curl -s "$video_url" | sed -n -E '
|
||||
*streamtape*)
|
||||
# If direct download not available then scrape streamtape.com
|
||||
BROWSER=${BROWSER:-firefox}
|
||||
printf "scraping streamtape.com\n"
|
||||
video_url=$(curl -s "$video_url" | sed -n -E '
|
||||
/^<script>document/{
|
||||
s/^[^"]*"([^"]*)" \+ '\''([^'\'']*).*/https:\1\2\&dl=1/p
|
||||
q
|
||||
}
|
||||
')
|
||||
;;
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $is_download -eq 0 ]; then
|
||||
@ -439,24 +440,24 @@ scrape=query
|
||||
download_dir="."
|
||||
while getopts 'hd:Hl' OPT; do
|
||||
case $OPT in
|
||||
h)
|
||||
help_text
|
||||
exit 0
|
||||
;;
|
||||
d)
|
||||
is_download=1
|
||||
download_dir="$OPTARG"
|
||||
h)
|
||||
help_text
|
||||
exit 0
|
||||
;;
|
||||
d)
|
||||
is_download=1
|
||||
download_dir="$OPTARG"
|
||||
|
||||
if [ "$VERBOSE" -eq 1 ]; then
|
||||
echo "DOWNLOAD DIR: $download_dir"
|
||||
fi
|
||||
;;
|
||||
H)
|
||||
scrape=history
|
||||
;;
|
||||
l)
|
||||
list_history=1
|
||||
;;
|
||||
if [ "$VERBOSE" -eq 1 ]; then
|
||||
echo "DOWNLOAD DIR: $download_dir"
|
||||
fi
|
||||
;;
|
||||
H)
|
||||
scrape=history
|
||||
;;
|
||||
l)
|
||||
list_history=1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
@ -477,22 +478,26 @@ if [[ "$list_history" -eq 1 ]]; then
|
||||
fi
|
||||
|
||||
case $scrape in
|
||||
query)
|
||||
query)
|
||||
|
||||
get_search_query "$*"
|
||||
search_results=$(search_anime "$query")
|
||||
[ -z "$search_results" ] && die "No search results found"
|
||||
anime_selection "$search_results"
|
||||
episode_selection
|
||||
;;
|
||||
history)
|
||||
# search_results=$(sed -n -E 's/\t[0-9]*//p' "$logfile")
|
||||
stmt="SELECT DISTINCT anime_name FROM watch_history ORDER BY watch_date DESC"
|
||||
search_results=$(printf "%s\n" "$stmt" | sqlite3 -noheader "$history_db")
|
||||
[ -z "$search_results" ] && die "History is empty"
|
||||
anime_selection "${search_results[@]}"
|
||||
ep_choice_start=$(sed -n -E "s/${selection_id}\t//p" "$logfile")
|
||||
;;
|
||||
get_search_query "$*"
|
||||
search_results=$(search_anime "$query")
|
||||
[ -z "$search_results" ] && die "No search results found"
|
||||
anime_selection "$search_results"
|
||||
episode_selection
|
||||
;;
|
||||
history)
|
||||
# search_results=$(sed -n -E 's/\t[0-9]*//p' "$logfile")
|
||||
stmt="SELECT DISTINCT anime_name FROM watch_history ORDER BY watch_date DESC"
|
||||
search_results=$(printf "%s\n" "$stmt" | sqlite3 -noheader "$history_db")
|
||||
[ -z "$search_results" ] && die "History is empty"
|
||||
anime_selection "${search_results[@]}"
|
||||
stmt="SELECT episode_number FROM watch_history ORDER BY watch_date DESC LIMIT 1"
|
||||
run_stmt "$stmt"
|
||||
ep_choice_start=$?
|
||||
echo "EPISODE: $ep_choice_start"
|
||||
# ep_choice_start=$(sed -n -E "s/${selection_id}\t//p" "$logfile")
|
||||
;;
|
||||
esac
|
||||
|
||||
{ # checking input
|
||||
@ -531,29 +536,29 @@ while :; do
|
||||
# choice=$(printf '%s\n' "$choice" | awk '{print $1}')
|
||||
printf "$c_reset"
|
||||
case $choice in
|
||||
n)
|
||||
episode=$((episode + 1))
|
||||
;;
|
||||
p)
|
||||
episode=$((episode - 1))
|
||||
;;
|
||||
n)
|
||||
episode=$((episode + 1))
|
||||
;;
|
||||
p)
|
||||
episode=$((episode - 1))
|
||||
;;
|
||||
|
||||
s)
|
||||
printf "${c_blue}Choose episode $c_cyan[1-%d]$c_reset:$c_green " $last_ep_number
|
||||
read episode
|
||||
printf "$c_reset"
|
||||
[ "$episode" -eq "$episode" ] 2>/dev/null || die "Invalid number entered"
|
||||
;;
|
||||
s)
|
||||
printf "${c_blue}Choose episode $c_cyan[1-%d]$c_reset:$c_green " $last_ep_number
|
||||
read episode
|
||||
printf "$c_reset"
|
||||
[ "$episode" -eq "$episode" ] 2>/dev/null || die "Invalid number entered"
|
||||
;;
|
||||
|
||||
r) ;;
|
||||
r) ;;
|
||||
|
||||
q)
|
||||
break
|
||||
;;
|
||||
q)
|
||||
break
|
||||
;;
|
||||
|
||||
*)
|
||||
die "invalid choice"
|
||||
;;
|
||||
*)
|
||||
die "invalid choice"
|
||||
;;
|
||||
esac
|
||||
open_episode "$selection_id" "$episode" "$download_dir"
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user