fix half episodes in watch history

This commit is contained in:
ksyasuda 2022-01-02 14:07:00 -08:00
parent 2076a5241f
commit bf1a35f869

13
ani-cli
View File

@ -21,7 +21,6 @@ HISTORY_DB="$XDG_CONFIG_HOME/aniwrapper/history.sqlite3"
player_fn="mpv"
prog="ani-cli"
logfile="${XDG_CACHE_HOME:-$HOME/.cache}/ani-hsts"
c_red="\033[1;31m"
c_green="\033[1;32m"
@ -213,7 +212,7 @@ check_db() {
stmt="SELECT DISTINCT COUNT(*) \
FROM watch_history \
WHERE anime_name = '$1' \
AND episode_number = $2;"
AND episode_number = '$2';"
res=$(run_stmt "$stmt")
return "$res"
fi
@ -249,7 +248,7 @@ insert_history() {
if [[ "$2" == "search" ]]; then
log "Already in search db... Updating search_date"
else
log "Already in search db... Updating watch_date"
log "Already in watch db... Updating watch_date"
fi
update_date "$@"
else
@ -349,9 +348,6 @@ get_search_query() {
fi
}
# create history file
[ -f "$logfile" ] || : > "$logfile"
#####################
## Anime selection ##
#####################
@ -569,7 +565,6 @@ open_episode() {
fi
get_video_quality
# status_code=$(curl -s -I get_video_quality "$play_link" | head -n 1 | cut -d ' ' -f2)
status_code=$(curl -s -I "$play_link" | head -n 1 | cut -d ' ' -f2)
log "Status code: $status_code"
@ -587,7 +582,6 @@ open_episode() {
fi
nohup $player_fn "$play_link" > /dev/null 2>&1 &
PID="$!"
# setsid -f $player_fn get_video_quality "$play_link" > /dev/null 2>&1
printf "${c_green}\nVideo playing"
fi
else
@ -599,7 +593,6 @@ open_episode() {
cd "${ddir/ //}" || die "Could not enter directory $ddir"
mkdir -p "$anime_id" || die "Could not create directory"
cd "$anime_id" || die "Could not enter subdirectory $ddir/$anime_id"
# ffmpeg -i "$play_link" -c copy "${anime_id}-${episode}.mkv" >/dev/null 2>&1 &&
if command -v "notify-send" > /dev/null; then
# ffmpeg -i "$play_link" -c copy "${episode}.mkv" > /dev/null 2>&1 &&
curl -L -# -C - "$play_link" -o "${anime_id}-${episode}.mp4" &&
@ -611,8 +604,6 @@ open_episode() {
printf "${c_green}Downloaded complete for %s - Episode: %s${c_reset}\n" "${anime_id//-/ }" "$episode" ||
printf "${c_red}Download failed for %s - Episode: %s, please retry or check your internet connection${c_reset}\n" "${anime_id//-/ }" "$episode"
fi
# 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"
}
fi
}