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