mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-11-22 03:19:53 -08:00
update logging in search_history function
This commit is contained in:
parent
7ee540601e
commit
8a531d1818
29
ani-cli
29
ani-cli
@ -197,7 +197,7 @@ sync_search_history() {
|
||||
res=$(sqlite3 -noheader "$HISTORY_DB" <<<"SELECT anime_name FROM search_history WHERE anime_name = '$anime_name'")
|
||||
if [[ "${res/ //}" == "" ]]; then
|
||||
search_date=$(awk -F '|' '{print $3}' <<<"$line")
|
||||
printf "%s\n" "Adding ($anime_name|$search_date) to watch history..."
|
||||
log "Adding ($anime_name|$search_date) to search history..."
|
||||
sqlite3 "$HISTORY_DB" <<<"INSERT INTO search_history(anime_name, search_date) VALUES('$anime_name', '$search_date')"
|
||||
if [[ "$?" -ne 0 ]]; then
|
||||
err "Error inserting row $line"
|
||||
@ -205,7 +205,7 @@ sync_search_history() {
|
||||
((++cnt))
|
||||
fi
|
||||
done <<<"$(sqlite3 -noheader "$temp_db" <<<"SELECT DISTINCT * FROM search_history")"
|
||||
printf "%s\n" "Inserted $cnt rows into search_history table"
|
||||
log "Inserted $cnt rows into search_history table"
|
||||
}
|
||||
|
||||
sync_watch_history() {
|
||||
@ -235,21 +235,6 @@ sync_watch_history() {
|
||||
log "Episode: $episode_num found in the db... skipping"
|
||||
fi
|
||||
done <<<"${episodes[@]}"
|
||||
# for episode in "${eps[@]}"; do
|
||||
# printf "\t%s\n" "ep: $episode"
|
||||
# done
|
||||
# echo "EPISODES: ${episodes[*]}"
|
||||
# res=$(sqlite3 -noheader "$HISTORY_DB" <<<"SELECT anime_name FROM watch_history WHERE anime_name = '$anime_name'")
|
||||
# if [[ "${res/ //}" == "" ]]; then
|
||||
# episode_num=$(awk -F '|' '{print $3}' <<<"$line")
|
||||
# watch_date=$(awk -F '|' '{print $NF}' <<<"$line")
|
||||
# printf "%s\n" "Adding ($anime_name|$episode_num|$watch_date) to watch history..."
|
||||
# sqlite3 "$HISTORY_DB" <<<"INSERT INTO watch_history(anime_name, episode_number, watch_date) VALUES('$anime_name', '$episode_num', '$watch_date')"
|
||||
# if [[ "$?" -ne 0 ]]; then
|
||||
# err "Error inserting row $line"
|
||||
# fi
|
||||
# ((++cnt))
|
||||
# fi
|
||||
done <<<"$(sqlite3 -noheader "$temp_db" <<<"SELECT DISTINCT anime_name FROM watch_history")"
|
||||
log "Inserted $cnt rows into watch_history table"
|
||||
}
|
||||
@ -595,7 +580,7 @@ if [[ "$list_history" -eq 1 ]]; then
|
||||
fi
|
||||
|
||||
case $scrape in
|
||||
query)
|
||||
query)
|
||||
|
||||
get_search_query "$*"
|
||||
search_results=$(search_anime "$query")
|
||||
@ -604,7 +589,7 @@ query)
|
||||
[ $? -ne 0 ] && die "No anime selection found"
|
||||
episode_selection
|
||||
;;
|
||||
history)
|
||||
history)
|
||||
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"
|
||||
@ -622,7 +607,7 @@ history)
|
||||
# search_results=$(sed -n -E 's/\t[0-9]*//p' "$logfile")
|
||||
# ep_choice_start=$(sed -n -E "s/${selection_id}\t//p" "$logfile")
|
||||
;;
|
||||
playlist)
|
||||
playlist)
|
||||
lines=$(cat "$playlist_file" | wc -l)
|
||||
[ "$VERBOSE" -eq 1 ] && printf "%s%d\n" "Num lines in playlist: " "$lines"
|
||||
if [[ "$lines" -eq 0 ]]; then
|
||||
@ -648,7 +633,7 @@ playlist)
|
||||
[ "$VERBOSE" -eq 1 ] && printf "Episodes: %s\n" "${episodes[@]}"
|
||||
fi
|
||||
;;
|
||||
add)
|
||||
add)
|
||||
get_search_query "$*"
|
||||
search_results=$(search_anime "$query")
|
||||
[ -z "$search_results" ] && die "No search results found"
|
||||
@ -656,7 +641,7 @@ add)
|
||||
[ $? -ne 0 ] && die "No anime selection found"
|
||||
episode_selection
|
||||
;;
|
||||
sync)
|
||||
sync)
|
||||
printf "%s" "Enter username for remote user: "
|
||||
read -r username
|
||||
printf "%s" "Enter host for remote user: "
|
||||
|
Loading…
Reference in New Issue
Block a user