mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-11-22 03:19:53 -08:00
fix queries in other db functions
This commit is contained in:
parent
53a6557d08
commit
9da0043ea5
37
ani-cli
37
ani-cli
@ -157,9 +157,12 @@ insert_history() {
|
|||||||
get_search_query() {
|
get_search_query() {
|
||||||
stmt="SELECT DISTINCT name FROM search_history"
|
stmt="SELECT DISTINCT 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" | awk '{ if ( NR > 2 ) { print } }')
|
||||||
cnt=$(printf "%s\n" "$cnt_stmt" | sqlite3 "$history_db")
|
cnt=$(printf "%s\n" "$cnt_stmt" | sqlite3 "$history_db" | tail -1)
|
||||||
|
echo "HISTORY: $hist"
|
||||||
|
echo "COUNT: $cnt"
|
||||||
if [ -z "$*" ]; then
|
if [ -z "$*" ]; then
|
||||||
|
echo "QUERYING"
|
||||||
query=$(printf "%s\n" "${hist[@]}" \
|
query=$(printf "%s\n" "${hist[@]}" \
|
||||||
| rofi -dmenu -l "$cnt" -p "Search Anime:" \
|
| rofi -dmenu -l "$cnt" -p "Search Anime:" \
|
||||||
-config ${XDG_CONFIG_HOME:-$HOME/.ani-cli}/meh.rasi)
|
-config ${XDG_CONFIG_HOME:-$HOME/.ani-cli}/meh.rasi)
|
||||||
@ -246,14 +249,19 @@ episode_selection() {
|
|||||||
[ $is_download -eq 1 ] &&
|
[ $is_download -eq 1 ] &&
|
||||||
printf "Range of episodes can be specified: start_number end_number\n"
|
printf "Range of episodes can be specified: start_number end_number\n"
|
||||||
|
|
||||||
stmt="SELECT DISTINCT episode_number \
|
# stmt="SELECT DISTINCT episode_number \
|
||||||
FROM watch_history WHERE anime_name = '$anime_id'"
|
# FROM watch_history WHERE anime_name = '$anime_id'"
|
||||||
cnt_stmt="SELECT DISTINCT COUNT(*) \
|
# cnt_stmt="SELECT DISTINCT COUNT(*) \
|
||||||
FROM watch_history WHERE anime_name = '$anime_id'"
|
# FROM watch_history WHERE anime_name = '$anime_id'"
|
||||||
hist=$(echo "$stmt" | sqlite3 "$history_db")
|
# hist=$(echo "$stmt" | \
|
||||||
cnt=$(printf "%s\n" "$cnt_stmt" | sqlite3 "$history_db")
|
# sqlite3 "$history_db"| awk '{ if ( NR > 2 ) { print } }')
|
||||||
choice=$(printf "%s\n" "${hist[@]}" | \
|
# cnt=$(printf "%s\n" "$cnt_stmt" | sqlite3 "$history_db" | tail -1)
|
||||||
rofi -dmenu -l "$cnt" -p "Search Anime:" \
|
eplist=""
|
||||||
|
echo "NUM EPISODES: $last_ep_number"
|
||||||
|
echo "${eplist[@]}"
|
||||||
|
choice=$(seq 1 10 | \
|
||||||
|
rofi -dmenu -l "$last_ep_number" \
|
||||||
|
-p "Select Episode (1, $last_ep_number):" \
|
||||||
-config ${XDG_CONFIG_HOME:-$HOME/.ani-cli}/meh.rasi)
|
-config ${XDG_CONFIG_HOME:-$HOME/.ani-cli}/meh.rasi)
|
||||||
ep_choice_start=$(printf '%s\n' "$choice" | awk '{print $1}')
|
ep_choice_start=$(printf '%s\n' "$choice" | awk '{print $1}')
|
||||||
ep_choice_end=$(printf '%s\n' "$choice" | awk '{print $2}')
|
ep_choice_end=$(printf '%s\n' "$choice" | awk '{print $2}')
|
||||||
@ -275,12 +283,11 @@ open_episode() {
|
|||||||
FROM watch_history WHERE anime_name = '$anime_id'"
|
FROM watch_history WHERE anime_name = '$anime_id'"
|
||||||
cnt_stmt="SELECT DISTINCT COUNT(*) \
|
cnt_stmt="SELECT DISTINCT COUNT(*) \
|
||||||
FROM watch_history WHERE anime_name = '$anime_id'"
|
FROM watch_history WHERE anime_name = '$anime_id'"
|
||||||
hist=$(echo "$stmt" | sqlite3 "$history_db")
|
hist=$(echo "$stmt" | sqlite3 "$history_db" | awk '{ if ( NR > 2 ) { print } }')
|
||||||
cnt=$(printf "%s\n" "$cnt_stmt" | sqlite3 "$history_db")
|
cnt=$(printf "%s\n" "$cnt_stmt" | sqlite3 "$history_db" | tail -1)
|
||||||
episode=$(printf "%s\n" "${hist[@]}" \
|
episode=$(printf "%s\n" "${hist[@]}" | \
|
||||||
| rofi -dmenu -l "$cnt" -p "Choose Episode:" \
|
rofi -dmenu -l "$cnt" -p "Choose Episode:" \
|
||||||
-config ${XDG_CONFIG_HOME:-$HOME/.ani-cli}/meh.rasi)
|
-config ${XDG_CONFIG_HOME:-$HOME/.ani-cli}/meh.rasi)
|
||||||
# episode=$(rofi -dmenu -l 1 -p "Choose episode:")
|
|
||||||
printf "$c_reset"
|
printf "$c_reset"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
7
db.sh
7
db.sh
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
DIR="$HOME"/'ani-cli'
|
DIR=$HOME/.ani-cli
|
||||||
DB='history.sqlite3'
|
DB='history.sqlite3'
|
||||||
|
|
||||||
log() {
|
log() {
|
||||||
@ -17,7 +17,8 @@ while getopts 'cdrq' OPT; do
|
|||||||
;;
|
;;
|
||||||
d)
|
d)
|
||||||
log "Deleting database..."
|
log "Deleting database..."
|
||||||
rm -rf "$DIR"/"$DB"
|
echo "$DIR/$DB"
|
||||||
|
rm "$DIR/$DB"
|
||||||
log "Database deleted..."
|
log "Database deleted..."
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ while getopts 'cdrq' OPT; do
|
|||||||
;;
|
;;
|
||||||
q)
|
q)
|
||||||
log "Connecting to database..."
|
log "Connecting to database..."
|
||||||
sqlite3 "$DIR"/"$DB"
|
sqlite3 "$DIR/$DB"
|
||||||
log "Ending connection to databse..."
|
log "Ending connection to databse..."
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
Loading…
Reference in New Issue
Block a user