mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-11-22 03:19:53 -08:00
clean up code a bit and update downloads logic
fix script inserting into watch_history when downloading modify logic so script quits immediately once done downloading episode(s)
This commit is contained in:
parent
a1b930f28a
commit
072680d637
24
ani-cli
24
ani-cli
@ -315,19 +315,10 @@ get_search_query() {
|
|||||||
anime_selection() {
|
anime_selection() {
|
||||||
# Select anime from query results
|
# Select anime from query results
|
||||||
search_results=$*
|
search_results=$*
|
||||||
# menu_format_string='[%d] %s\n'
|
|
||||||
# menu_format_string_c1="$c_blue[$c_cyan%d$c_blue] $c_reset%s\n"
|
|
||||||
# menu_format_string_c2="$c_blue[$c_cyan%d$c_blue] $c_yellow%s$c_reset\n"
|
|
||||||
|
|
||||||
count=1
|
count=1
|
||||||
menu=()
|
menu=()
|
||||||
res=()
|
res=()
|
||||||
while read -r anime_id; do
|
while read -r anime_id; do
|
||||||
# alternating colors for menu
|
|
||||||
# [ $((count % 2)) -eq 0 ] &&
|
|
||||||
# menu_format_string=$menu_format_string_c1 ||
|
|
||||||
# menu_format_string=$menu_format_string_c2
|
|
||||||
|
|
||||||
menu+="$count. $anime_id\n"
|
menu+="$count. $anime_id\n"
|
||||||
idx=$((count - 1))
|
idx=$((count - 1))
|
||||||
res["$idx"]="$anime_id"
|
res["$idx"]="$anime_id"
|
||||||
@ -475,10 +466,11 @@ open_episode() {
|
|||||||
|
|
||||||
log "Getting data for episode $episode"
|
log "Getting data for episode $episode"
|
||||||
|
|
||||||
insert_history "$anime_id" "$episode"
|
# Don't update watch history if downloading episode
|
||||||
|
if [ "$is_download" -eq 0 ]; then
|
||||||
|
insert_history "$anime_id" "$episode"
|
||||||
|
fi
|
||||||
|
|
||||||
# embedded_video_url=$(get_embedded_video_link "$anime_id" "$episode")
|
|
||||||
# video_url=$(get_links "$embedded_video_url")
|
|
||||||
get_video_quality
|
get_video_quality
|
||||||
status_code=$(curl -s -I get_video_quality "$play_link" | head -n 1|cut -d ' ' -f2)
|
status_code=$(curl -s -I get_video_quality "$play_link" | head -n 1|cut -d ' ' -f2)
|
||||||
log "Status code: $status_code"
|
log "Status code: $status_code"
|
||||||
@ -503,8 +495,8 @@ open_episode() {
|
|||||||
ffmpeg -i "$play_link" -c copy "${episode}.mkv" >/dev/null 2>&1 &&
|
ffmpeg -i "$play_link" -c copy "${episode}.mkv" >/dev/null 2>&1 &&
|
||||||
notify-send -i "$ANIWRAPPER_ICON_PATH" "Download complete for ${anime_id//-/ } - Episode: $episode" ||
|
notify-send -i "$ANIWRAPPER_ICON_PATH" "Download complete for ${anime_id//-/ } - Episode: $episode" ||
|
||||||
notify-send -i "$ANIWRAPPER_ICON_PATH" "Download failed for ${anime_id//-/ } - Episode: $episode. Please retry or check your internet connection"
|
notify-send -i "$ANIWRAPPER_ICON_PATH" "Download failed for ${anime_id//-/ } - Episode: $episode. Please retry or check your internet connection"
|
||||||
# printf "${c_green}Downloaded episode: %s${c_reset}\n" "$episode" ||
|
# printf "${c_green}Downloaded episode: %s${c_reset}\n" "$episode" ||
|
||||||
# printf "${c_red}Download failed episode: %s , please retry or check your internet connection${c_reset}\n" "$episode"
|
# printf "${c_red}Download failed episode: %s , please retry or check your internet connection${c_reset}\n" "$episode"
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -535,7 +527,6 @@ while getopts 'hd:Hpa:P:svq:' OPT; do
|
|||||||
d)
|
d)
|
||||||
is_download=1
|
is_download=1
|
||||||
download_dir="$OPTARG"
|
download_dir="$OPTARG"
|
||||||
|
|
||||||
log "DOWNLOAD DIR: $download_dir"
|
log "DOWNLOAD DIR: $download_dir"
|
||||||
;;
|
;;
|
||||||
H)
|
H)
|
||||||
@ -706,6 +697,9 @@ done
|
|||||||
if [[ "$is_add" -eq 1 ]]; then
|
if [[ "$is_add" -eq 1 ]]; then
|
||||||
log "Finished adding to playlist file... exiting"
|
log "Finished adding to playlist file... exiting"
|
||||||
exit 0
|
exit 0
|
||||||
|
elif [[ "$is_download" -eq 1 ]]; then
|
||||||
|
log "Finished downloading episodes: $episodes for $selection_id... exiting"
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
episode=${ep_choice_end:-$ep_choice_start}
|
episode=${ep_choice_end:-$ep_choice_start}
|
||||||
|
Loading…
Reference in New Issue
Block a user