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