mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-11-22 03:19:53 -08:00
fix checkdb function and add needed .rasi conf
fixed checkdb function always returning 2 instead of the count also add arc_dark_transparent_colors.rasi config file for use in meh.rasi
This commit is contained in:
parent
ec2e46df66
commit
a11d55b726
69
ani-cli
69
ani-cli
@ -16,7 +16,6 @@ c_magenta="\033[1;35m"
|
||||
c_cyan="\033[1;36m"
|
||||
c_reset="\033[0m"
|
||||
|
||||
rofi_cmd="rofi -config ${XDG_CONFIG_HOME:-$HOME/.ani-cli}/meh.rasi -dmenu -l 10 -i -p 'Enter Choice:'"
|
||||
|
||||
help_text() {
|
||||
while IFS= read line; do
|
||||
@ -99,14 +98,16 @@ dep_ch() {
|
||||
check_db() {
|
||||
echo "$1 $2"
|
||||
if [[ "$2" == "search" ]]; then
|
||||
stmt="SELECT DISTINCT COUNT(*) FROM search_history WHERE name = '$1'"
|
||||
res=$(printf "%s\n" "$stmt" | sqlite3 "$history_db")
|
||||
echo "$res"
|
||||
stmt="SELECT DISTINCT COUNT(*) FROM search_history \
|
||||
WHERE name = '$1'"
|
||||
res="$(printf '%s\n' $stmt | sqlite3 $history_db | tail -1)"
|
||||
# echo "QUERY RESULT $res"
|
||||
return "$res"
|
||||
else
|
||||
stmt="SELECT DISTINCT COUNT(*) FROM watch_history WHERE anime_name = '$1' AND episode_number = $2"
|
||||
res=$(printf "%s\n" "$stmt" | sqlite3 "$history_db")
|
||||
echo "$res"
|
||||
stmt="SELECT DISTINCT COUNT(*) FROM watch_history \
|
||||
WHERE anime_name = '$1' AND episode_number = $2"
|
||||
res="$(printf '%s\n' $stmt | sqlite3 $history_db | tail -1)"
|
||||
# echo "QUERY RESULT $res"
|
||||
return "$res"
|
||||
fi
|
||||
}
|
||||
@ -114,10 +115,15 @@ check_db() {
|
||||
update_date() {
|
||||
if [[ "$2" == "search" ]]; then
|
||||
curdate=$(date +'%Y-%m-%d')
|
||||
stmt="UPDATE search_history SET search_date = '$curdate' WHERE name = '$1'" && return 0 || return 1
|
||||
stmt="UPDATE search_history SET search_date = '$curdate' \
|
||||
WHERE name = '$1'" \
|
||||
&& return 0 || return 1
|
||||
else
|
||||
curdate=$(date +'%Y-%m-%d')
|
||||
stmt="UPDATE watch_history SET watch_date = '$curdate' WHERE anime_name = '$1' AND episode_number = $2" && return 0 || return 1
|
||||
stmt="UPDATE watch_history SET watch_date = '$curdate' \
|
||||
WHERE anime_name = '$1' \
|
||||
AND episode_number = $2" \
|
||||
&& return 0 || return 1
|
||||
fi
|
||||
}
|
||||
|
||||
@ -125,7 +131,7 @@ insert_history() {
|
||||
curdate=$(date +'%Y-%m-%d')
|
||||
check_db "$@"
|
||||
num=$?
|
||||
# echo "$num"
|
||||
echo "CHECKDB RETURNED: $num"
|
||||
if [[ "$num" -gt 0 ]]; then
|
||||
if [[ "$2" == "search" ]]; then
|
||||
printf "%s\n" "Already in search db... Updating search_date"
|
||||
@ -135,10 +141,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(name, search_date) \
|
||||
VALUES('$1', '$curdate')"
|
||||
printf "%s\n" "$stmt" | sqlite3 "$history_db"
|
||||
else
|
||||
stmt="INSERT INTO watch_history(anime_name, episode_number, watch_date) VALUES('$1', '$2', '$curdate')"
|
||||
stmt="INSERT INTO \
|
||||
watch_history(anime_name, episode_number, watch_date) \
|
||||
VALUES('$1', '$2', '$curdate')"
|
||||
printf "%s\n" "$stmt" | sqlite3 "$history_db"
|
||||
fi
|
||||
fi
|
||||
@ -151,7 +160,9 @@ get_search_query() {
|
||||
hist=$(echo "$stmt" | sqlite3 "$history_db")
|
||||
cnt=$(printf "%s\n" "$cnt_stmt" | sqlite3 "$history_db")
|
||||
if [ -z "$*" ]; then
|
||||
query=$(printf "%s\n" "${hist[@]}" | rofi -dmenu -l "$cnt" -p "Search Anime:" -config ${XDG_CONFIG_HOME:-$HOME/.ani-cli}/meh.rasi)
|
||||
query=$(printf "%s\n" "${hist[@]}" \
|
||||
| rofi -dmenu -l "$cnt" -p "Search Anime:" \
|
||||
-config ${XDG_CONFIG_HOME:-$HOME/.ani-cli}/meh.rasi)
|
||||
# if [[ "$query" != "" ]]; then
|
||||
# insert_history "$query" "search"
|
||||
# else
|
||||
@ -192,7 +203,9 @@ anime_selection() {
|
||||
$search_results
|
||||
EOF
|
||||
|
||||
user_input=$(printf "${menu[@]}" | rofi -dmenu -config ${XDG_CONFIG_HOME:-$HOME/.ani-cli}/meh.rasi -l 10 -i -p "Enter number:")
|
||||
user_input=$(printf "${menu[@]}" | \
|
||||
rofi -dmenu -config ${XDG_CONFIG_HOME:-$HOME/.ani-cli}/meh.rasi \
|
||||
-l 10 -i -p "Enter number:")
|
||||
|
||||
choice=$(printf '%s\n' "$user_input" | awk '{print $1}')
|
||||
name=$(printf '%s\n' "$user_input" | awk '{print $NF}')
|
||||
@ -233,13 +246,15 @@ episode_selection() {
|
||||
[ $is_download -eq 1 ] &&
|
||||
printf "Range of episodes can be specified: start_number end_number\n"
|
||||
|
||||
# printf "${c_blue}Choose episode $c_cyan[1-%d]$c_reset:$c_green " $last_ep_number
|
||||
# choice=$(rofi -config ${XDG_CONFIG_HOME:-$HOME/.ani-cli}/meh.rasi -dmenu -l 1 -i -p "Choose episode:")
|
||||
stmt="SELECT DISTINCT episode_number FROM watch_history WHERE anime_name = '$anime_id'"
|
||||
cnt_stmt="SELECT DISTINCT COUNT(*) FROM watch_history WHERE anime_name = '$anime_id'"
|
||||
stmt="SELECT DISTINCT episode_number \
|
||||
FROM watch_history WHERE anime_name = '$anime_id'"
|
||||
cnt_stmt="SELECT DISTINCT COUNT(*) \
|
||||
FROM watch_history WHERE anime_name = '$anime_id'"
|
||||
hist=$(echo "$stmt" | sqlite3 "$history_db")
|
||||
cnt=$(printf "%s\n" "$cnt_stmt" | sqlite3 "$history_db")
|
||||
choice=$(printf "%s\n" "${hist[@]}" | rofi -dmenu -l "$cnt" -p "Search Anime:" -config ${XDG_CONFIG_HOME:-$HOME/.ani-cli}/meh.rasi)
|
||||
choice=$(printf "%s\n" "${hist[@]}" | \
|
||||
rofi -dmenu -l "$cnt" -p "Search Anime:" \
|
||||
-config ${XDG_CONFIG_HOME:-$HOME/.ani-cli}/meh.rasi)
|
||||
ep_choice_start=$(printf '%s\n' "$choice" | awk '{print $1}')
|
||||
ep_choice_end=$(printf '%s\n' "$choice" | awk '{print $2}')
|
||||
# echo "$ep_choice_start $ep_choice_end"
|
||||
@ -256,13 +271,15 @@ open_episode() {
|
||||
printf '\x1B[2J\x1B[1;1H'
|
||||
if [ $episode -lt 1 ] || [ $episode -gt $last_ep_number ]; then
|
||||
err "Episode out of range"
|
||||
# printf "${c_blue}Choose episode $c_cyan[1-%d]$c_reset:$c_green " $last_ep_number
|
||||
# read episode
|
||||
stmt="SELECT DISTINCT episode_number FROM watch_history WHERE anime_name = '$anime_id'"
|
||||
cnt_stmt="SELECT DISTINCT COUNT(*) FROM watch_history WHERE anime_name = '$anime_id'"
|
||||
stmt="SELECT DISTINCT episode_number \
|
||||
FROM watch_history WHERE anime_name = '$anime_id'"
|
||||
cnt_stmt="SELECT DISTINCT COUNT(*) \
|
||||
FROM watch_history WHERE anime_name = '$anime_id'"
|
||||
hist=$(echo "$stmt" | sqlite3 "$history_db")
|
||||
cnt=$(printf "%s\n" "$cnt_stmt" | sqlite3 "$history_db")
|
||||
episode=$(printf "%s\n" "${hist[@]}" | rofi -dmenu -l "$cnt" -p "Choose Episode:" -config ${XDG_CONFIG_HOME:-$HOME/.ani-cli}/meh.rasi)
|
||||
episode=$(printf "%s\n" "${hist[@]}" \
|
||||
| rofi -dmenu -l "$cnt" -p "Choose Episode:" \
|
||||
-config ${XDG_CONFIG_HOME:-$HOME/.ani-cli}/meh.rasi)
|
||||
# episode=$(rofi -dmenu -l 1 -p "Choose episode:")
|
||||
printf "$c_reset"
|
||||
fi
|
||||
@ -350,7 +367,9 @@ if [[ "$list_history" -eq 1 ]]; then
|
||||
cnt_stmt="SELECT DISTINCT COUNT(*) FROM search_history"
|
||||
hist=$(echo "$stmt" | sqlite3 "$history_db")
|
||||
cnt=$(printf "%s\n" "$cnt_stmt" | sqlite3 "$history_db")
|
||||
printf "%s\n" "${hist[@]}" | rofi -config ${XDG_CONFIG_HOME:-$HOME/.ani-cli}/meh.rasi -dmenu -l "$cnt" -i -p "Search History"
|
||||
printf "%s\n" "${hist[@]}" | \
|
||||
rofi -config ${XDG_CONFIG_HOME:-$HOME/.ani-cli}/meh.rasi \
|
||||
-dmenu -l "$cnt" -i -p "Search History"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
11
db.sh
11
db.sh
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
DIR="$HOME"/'ani-cli/'
|
||||
DIR="$HOME"/'ani-cli'
|
||||
DB='history.sqlite3'
|
||||
|
||||
log() {
|
||||
@ -11,8 +11,8 @@ while getopts 'cdrq' OPT; do
|
||||
case "$OPT" in
|
||||
c)
|
||||
log "Creating database..."
|
||||
sqlite3 "$DIR"/"$DB" <sql/anime_search_history.sql
|
||||
sqlite3 "$DIR"/"$DB" <sql/watch_history.sql
|
||||
sqlite3 "$DIR"/"$DB" <sql/search_history_tbl.sql
|
||||
sqlite3 "$DIR"/"$DB" <sql/watch_history_tbl.sql
|
||||
log "Created database..."
|
||||
;;
|
||||
d)
|
||||
@ -24,10 +24,11 @@ while getopts 'cdrq' OPT; do
|
||||
r)
|
||||
log "Deleting database..."
|
||||
rm -rf "$DIR"/"$DB"
|
||||
mkdir -p "$DIR"
|
||||
log "Database deleted..."
|
||||
log "Creating database..."
|
||||
sqlite3 "$DIR"/"$DB" <sql/anime_search_history.sql
|
||||
sqlite3 "$DIR"/"$DB" <sql/watch_history.sql
|
||||
sqlite3 "$DIR"/"$DB" <sql/search_history_tbl.sql
|
||||
sqlite3 "$DIR"/"$DB" <sql/watch_history_tbl.sql
|
||||
log "Created database..."
|
||||
;;
|
||||
q)
|
||||
|
27
setup.sh
Executable file
27
setup.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
log () {
|
||||
printf "%s\n" "$1"
|
||||
}
|
||||
|
||||
DIR="$HOME/.ani-cli/"
|
||||
DB="history.sqlite3"
|
||||
|
||||
log "Deleting old directory..."
|
||||
rm -rf "$DIR"
|
||||
log "Directory deleted..."
|
||||
|
||||
log "Creating directory $DIR"
|
||||
mkdir -p "$DIR"
|
||||
log "Directory created"
|
||||
|
||||
log "Creating history database..."
|
||||
sqlite3 "$DIR"/"$DB" < sql/watch_history_tbl.sql
|
||||
sqlite3 "$DIR"/"$DB" < sql/search_history_tbl.sql
|
||||
log "History database created..."
|
||||
|
||||
log "Moving theme files..."
|
||||
cp themes/meh.rasi "$DIR"/
|
||||
cp themes/arc_dark_transparent_colors.rasi "$DIR"/
|
||||
log "Theme files moved..."
|
34
themes/arc_dark_transparent_colors.rasi
Normal file
34
themes/arc_dark_transparent_colors.rasi
Normal file
@ -0,0 +1,34 @@
|
||||
/*******************************************************
|
||||
* ROFI Arch Dark Transparent colors for EndeavourOS
|
||||
* Maintainer: joekamprad <joekamprad@endeavouros.com>
|
||||
*******************************************************/
|
||||
* {
|
||||
selected-normal-foreground: rgba ( 255, 147, 5, 100 % );
|
||||
foreground: rgba ( 196, 203, 212, 100 % );
|
||||
normal-foreground: @foreground;
|
||||
alternate-normal-background: rgba ( 45, 48, 59, 1 % );
|
||||
red: rgba ( 220, 50, 47, 100 % );
|
||||
selected-urgent-foreground: rgba ( 249, 249, 249, 100 % );
|
||||
blue: rgba ( 38, 139, 210, 100 % );
|
||||
urgent-foreground: rgba ( 204, 102, 102, 100 % );
|
||||
alternate-urgent-background: rgba ( 75, 81, 96, 90 % );
|
||||
active-foreground: rgba ( 101, 172, 255, 100 % );
|
||||
lightbg: rgba ( 238, 232, 213, 100 % );
|
||||
selected-active-foreground: rgba ( 249, 249, 249, 100 % );
|
||||
alternate-active-background: rgba ( 45, 48, 59, 88 % );
|
||||
background: rgba ( 45, 48, 59, 88 % );
|
||||
alternate-normal-foreground: @foreground;
|
||||
normal-background: rgba ( 45, 48, 59, 1 % );
|
||||
lightfg: rgba ( 88, 104, 117, 100 % );
|
||||
selected-normal-background: rgba ( 24, 26, 32, 100 % );
|
||||
border-color: rgba ( 124, 131, 137, 100 % );
|
||||
spacing: 2;
|
||||
separatorcolor: rgba ( 45, 48, 59, 1 % );
|
||||
urgent-background: rgba ( 45, 48, 59, 15 % );
|
||||
selected-urgent-background: rgba ( 165, 66, 66, 100 % );
|
||||
alternate-urgent-foreground: @urgent-foreground;
|
||||
background-color: rgba ( 0, 0, 0, 0 % );
|
||||
alternate-active-foreground: @active-foreground;
|
||||
active-background: rgba ( 29, 31, 33, 17 % );
|
||||
selected-active-background: rgba ( 26, 28, 35, 100 % );
|
||||
}
|
@ -13,7 +13,7 @@ configuration {
|
||||
markup: true;
|
||||
}
|
||||
|
||||
@import "~/.config/rofi/arc_dark_transparent_colors.rasi"
|
||||
@import "~/.ani-cli/arc_dark_transparent_colors.rasi"
|
||||
|
||||
window {
|
||||
background-color: @background;
|
||||
|
Loading…
Reference in New Issue
Block a user