mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-11-22 03:19:53 -08:00
change search/watch date from date to datetime
This commit is contained in:
parent
c69695fb75
commit
e0df1a8dbf
23
ani-cli
23
ani-cli
@ -122,7 +122,7 @@ check_db() {
|
||||
# echo "$1 $2"
|
||||
if [[ "$2" == "search" ]]; then
|
||||
stmt="SELECT DISTINCT COUNT(*) FROM search_history \
|
||||
WHERE name = '$1'"
|
||||
WHERE anime_name = '$1'"
|
||||
res="$(printf '%s\n' $stmt | sqlite3 -noheader $history_db | tail -1)"
|
||||
# echo "QUERY RESULT $res"
|
||||
return "$res"
|
||||
@ -137,14 +137,13 @@ check_db() {
|
||||
|
||||
update_date() {
|
||||
# updates search/watch date for passed in anime
|
||||
datetime=$(date +'%Y-%m-%d %H:%M:%S')
|
||||
if [[ "$2" == "search" ]]; then
|
||||
curdate=$(date +'%Y-%m-%d')
|
||||
stmt="UPDATE search_history SET search_date = '$curdate' \
|
||||
WHERE name = '$1'" &&
|
||||
stmt="UPDATE search_history SET search_date = '$datetime' \
|
||||
WHERE anime_name = '$1'" &&
|
||||
return 0 || return 1
|
||||
else
|
||||
curdate=$(date +'%Y-%m-%d')
|
||||
stmt="UPDATE watch_history SET watch_date = '$curdate' \
|
||||
stmt="UPDATE watch_history SET watch_date = '$datetime' \
|
||||
WHERE anime_name = '$1' \
|
||||
AND episode_number = $2" &&
|
||||
return 0 || return 1
|
||||
@ -158,7 +157,7 @@ insert_history() {
|
||||
printf "%s\n" "ERROR: Anime name is none... exiting"
|
||||
return 1
|
||||
fi
|
||||
curdate=$(date +'%Y-%m-%d')
|
||||
datetime=$(date +'%Y-%m-%d %H:%M:%S')
|
||||
check_db "$@"
|
||||
num=$?
|
||||
# echo "CHECKDB RETURNED: $num"
|
||||
@ -171,13 +170,13 @@ insert_history() {
|
||||
update_date "$@"
|
||||
else
|
||||
if [[ "$2" == "search" ]]; then
|
||||
stmt="INSERT INTO search_history(name, search_date) \
|
||||
VALUES('$1', '$curdate')"
|
||||
stmt="INSERT INTO search_history(anime_name, search_date) \
|
||||
VALUES('$1', '$datetime')"
|
||||
printf "%s\n" "$stmt" | sqlite3 -noheader "$history_db"
|
||||
else
|
||||
stmt="INSERT INTO \
|
||||
watch_history(anime_name, episode_number, watch_date) \
|
||||
VALUES('$1', '$2', '$curdate')"
|
||||
VALUES('$1', '$2', '$datetime')"
|
||||
printf "%s\n" "$stmt" | sqlite3 -noheader "$history_db"
|
||||
fi
|
||||
fi
|
||||
@ -188,7 +187,7 @@ get_search_query() {
|
||||
# Query the anime to stream/download
|
||||
|
||||
# Get search history
|
||||
stmt="SELECT DISTINCT name FROM search_history"
|
||||
stmt="SELECT DISTINCT anime_name FROM search_history"
|
||||
# cnt_stmt="SELECT DISTINCT COUNT(*) FROM search_history"
|
||||
hist=$(echo "$stmt" | sqlite3 -noheader "$history_db")
|
||||
# hist=$(echo "$stmt" | sqlite3 -noheader "$history_db" | awk '{ if ( NR > 2 ) { print } }')
|
||||
@ -456,7 +455,7 @@ shift $((OPTIND - 1))
|
||||
########
|
||||
|
||||
if [[ "$list_history" -eq 1 ]]; then
|
||||
stmt="SELECT DISTINCT name FROM search_history"
|
||||
stmt="SELECT DISTINCT anime_name FROM search_history"
|
||||
cnt_stmt="SELECT DISTINCT COUNT(*) FROM search_history"
|
||||
# hist=$(echo "$stmt" | sqlite3 "$history_db")
|
||||
# hist=$(echo "$stmt" | sqlite3 -noheader "$history_db" | awk '{ if ( NR > 2 ) { print } }')
|
||||
|
@ -1,6 +1,6 @@
|
||||
CREATE TABLE search_history (
|
||||
id integer PRIMARY KEY autoincrement,
|
||||
name varchar(200) NOT NULL,
|
||||
search_date date NOT NULL
|
||||
id integer PRIMARY KEY AUTOINCREMENT,
|
||||
anime_name varchar(200),
|
||||
search_date datetime NOT NULL
|
||||
);
|
||||
|
||||
|
@ -2,6 +2,6 @@ CREATE TABLE watch_history (
|
||||
id integer PRIMARY KEY AUTOINCREMENT,
|
||||
anime_name varchar(200) NOT NULL,
|
||||
episode_number integer NOT NULL,
|
||||
watch_date date
|
||||
watch_date datetime NOT NULL
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user