improvements

This commit is contained in:
ksyasuda 2022-01-08 15:34:18 -08:00
parent 27d4dd5ec3
commit 9be6dccf79
6 changed files with 22 additions and 109 deletions

View File

@ -406,9 +406,10 @@ find_media() {
fi fi
span=$(generate_span "Current directory: $inp") span=$(generate_span "Current directory: $inp")
inputlist=$(generate_inputlist "$inp") # run in parallel in background?
watched_files=$(generate_file_watchedlist "$inp") inputlist=$(generate_inputlist "$inp" &)
logger "watched files -> $watched_files" watched_files=$(generate_file_watchedlist "$inp" &)
wait
selection=$(rofi -dmenu -only-match -async-pre-read 33 -config "$ROFI_CFG" \ selection=$(rofi -dmenu -only-match -async-pre-read 33 -config "$ROFI_CFG" \
-l 12 -i -sep '|' -mesg "$span" -a "$watched_files" \ -l 12 -i -sep '|' -mesg "$span" -a "$watched_files" \
-p "Enter selection" <<< "${inputlist[@]}") -p "Enter selection" <<< "${inputlist[@]}")

View File

@ -48,7 +48,6 @@ Options:
-f <path_to_directory> (no trailing slash) specify starting directory for play for file mode -f <path_to_directory> (no trailing slash) specify starting directory for play for file mode
-Q <query> query the history database -Q <query> query the history database
" "
exit 0
} }
logger() { logger() {
@ -109,6 +108,7 @@ parse_args() {
case "$OPT" in case "$OPT" in
h) h)
help_text help_text
exit 0
;; ;;
v) v)
VERBOSE=1 VERBOSE=1
@ -177,7 +177,7 @@ parse_args() {
IS_CUSTOM_THEME=1 IS_CUSTOM_THEME=1
;; ;;
*) *)
logger "Invalid option" help_text
exit 1 exit 1
;; ;;
esac esac
@ -286,8 +286,7 @@ main() {
quit quit
;; ;;
*) *)
logger "Invalid choice..." help_text
exit 1
;; ;;
esac esac
} }

View File

@ -43,11 +43,13 @@ run_setup() {
log "Directory created" log "Directory created"
fi fi
log "CREATING/UPDATING HISTORY DATABASE TABLES" if [[ ! -f "$DIR/$DB" ]]; then
sqlite3 "$DIR/$DB" < sql/search_history_tbl.sql log "CREATING HISTORY DATABASE"
sqlite3 "$DIR/$DB" < sql/watch_history_tbl.sql sqlite3 "$DIR/$DB" < sql/search_history_tbl.sql
sqlite3 "$DIR/$DB" < sql/file_history.sql sqlite3 "$DIR/$DB" < sql/watch_history_tbl.sql
log "FINISHED CREATING/UPDATING THE TABLES" sqlite3 "$DIR/$DB" < sql/file_history.sql
log "FINISHED CREATING DB"
fi
if [[ ! -d "$DIR/themes" ]]; then if [[ ! -d "$DIR/themes" ]]; then
log "themes directory does not exist in filesystem... Creating and moving themes" log "themes directory does not exist in filesystem... Creating and moving themes"

View File

@ -1,32 +1,3 @@
DROP TABLE IF EXISTS temp_file_history;
CREATE TABLE IF NOT EXISTS temp_file_history (
id integer PRIMARY KEY AUTOINCREMENT,
directory varchar(200) NOT NULL,
filename varchar(200) NOT NULL,
watch_date DATETIME NOT NULL,
CHECK (LENGTH(directory) > 0),
CHECK (LENGTH(filename) > 0),
UNIQUE (directory, filename)
);
-- make sure table has been set up at least once
CREATE TABLE IF NOT EXISTS file_history (
id integer PRIMARY KEY AUTOINCREMENT,
directory varchar(200) NOT NULL,
filename varchar(200) NOT NULL,
watch_date DATETIME NOT NULL,
CHECK (LENGTH(directory) > 0),
CHECK (LENGTH(filename) > 0),
UNIQUE (directory, filename)
);
INSERT OR IGNORE INTO temp_file_history
SELECT * FROM file_history;
DROP TABLE file_history;
CREATE TABLE file_history ( CREATE TABLE file_history (
id integer PRIMARY KEY AUTOINCREMENT, id integer PRIMARY KEY AUTOINCREMENT,
directory varchar(200) NOT NULL, directory varchar(200) NOT NULL,
@ -36,9 +7,6 @@ CREATE TABLE file_history (
CHECK (LENGTH(filename) > 0), CHECK (LENGTH(filename) > 0),
UNIQUE (directory, filename) UNIQUE (directory, filename)
); );
CREATE UNIQUE INDEX dir_filename_idx ON file_history(directory, filename);
INSERT INTO file_history CREATE UNIQUE INDEX dir_filename_idx ON file_history (directory, filename);
SELECT * FROM temp_file_history;
DROP TABLE temp_file_history;

View File

@ -1,26 +1,3 @@
DROP TABLE IF EXISTS temp_search_history;
CREATE TABLE IF NOT EXISTS temp_search_history (
id integer PRIMARY KEY AUTOINCREMENT,
anime_name varchar(200) NOT NULL,
search_date DATETIME NOT NULL,
CHECK (LENGTH(anime_name) > 0),
UNIQUE (anime_name, search_date)
);
CREATE TABLE IF NOT EXISTS search_history (
id integer PRIMARY KEY AUTOINCREMENT,
anime_name varchar(200) NOT NULL,
search_date DATETIME NOT NULL,
CHECK (LENGTH(anime_name) > 0),
UNIQUE (anime_name, search_date)
);
INSERT OR IGNORE INTO temp_search_history
SELECT * FROM search_history;
DROP TABLE IF EXISTS search_history;
CREATE TABLE search_history ( CREATE TABLE search_history (
id integer PRIMARY KEY AUTOINCREMENT, id integer PRIMARY KEY AUTOINCREMENT,
anime_name varchar(200) NOT NULL, anime_name varchar(200) NOT NULL,
@ -31,8 +8,3 @@ CREATE TABLE search_history (
CREATE UNIQUE INDEX anime_search_idx ON search_history (anime_name, search_date); CREATE UNIQUE INDEX anime_search_idx ON search_history (anime_name, search_date);
INSERT INTO search_history
SELECT * FROM temp_search_history;
DROP TABLE temp_search_history;

View File

@ -1,41 +1,12 @@
DROP TABLE IF EXISTS temp_watch_history;
CREATE TABLE temp_watch_history (
id INTEGER PRIMARY KEY AUTOINCREMENT,
anime_name VARCHAR(200) NOT NULL,
episode_number INTEGER NOT NULL,
watch_date DATETIME NOT NULL,
CHECK(LENGTH(anime_name) > 0),
CHECK(episode_number > 0),
UNIQUE(anime_name, episode_number, watch_date)
);
CREATE TABLE IF NOT EXISTS watch_history (
id INTEGER PRIMARY KEY AUTOINCREMENT,
anime_name VARCHAR(200) NOT NULL,
episode_number INTEGER NOT NULL,
watch_date DATETIME NOT NULL,
CHECK(LENGTH(anime_name) > 0),
CHECK(episode_number > 0),
UNIQUE(anime_name, episode_number, watch_date)
);
INSERT OR IGNORE INTO temp_watch_history
SELECT * FROM watch_history;
DROP TABLE watch_history;
CREATE TABLE watch_history ( 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 DATETIME NOT NULL, watch_date DATETIME NOT NULL,
CHECK(LENGTH(anime_name) > 0), CHECK (LENGTH(anime_name) > 0),
CHECK(episode_number > 0), CHECK (episode_number > 0),
UNIQUE(anime_name, episode_number, watch_date) UNIQUE (anime_name, episode_number, watch_date)
); );
CREATE UNIQUE INDEX IF NOT EXISTS watch_anime_episode_idx ON watch_history(anime_name, episode_number);
INSERT INTO watch_history CREATE UNIQUE INDEX IF NOT EXISTS watch_anime_episode_idx ON watch_history (anime_name, episode_number);
SELECT * FROM temp_watch_history;
DROP TABLE IF EXISTS temp_watch_history;