diff --git a/ani-cli b/ani-cli index 5d9299a..3199f54 100755 --- a/ani-cli +++ b/ani-cli @@ -406,9 +406,10 @@ find_media() { fi span=$(generate_span "Current directory: $inp") - inputlist=$(generate_inputlist "$inp") - watched_files=$(generate_file_watchedlist "$inp") - logger "watched files -> $watched_files" + # run in parallel in background? + inputlist=$(generate_inputlist "$inp" &) + watched_files=$(generate_file_watchedlist "$inp" &) + wait selection=$(rofi -dmenu -only-match -async-pre-read 33 -config "$ROFI_CFG" \ -l 12 -i -sep '|' -mesg "$span" -a "$watched_files" \ -p "Enter selection" <<< "${inputlist[@]}") diff --git a/aniwrapper b/aniwrapper index 47106d0..29e137f 100755 --- a/aniwrapper +++ b/aniwrapper @@ -48,7 +48,6 @@ Options: -f (no trailing slash) specify starting directory for play for file mode -Q query the history database " - exit 0 } logger() { @@ -109,6 +108,7 @@ parse_args() { case "$OPT" in h) help_text + exit 0 ;; v) VERBOSE=1 @@ -177,7 +177,7 @@ parse_args() { IS_CUSTOM_THEME=1 ;; *) - logger "Invalid option" + help_text exit 1 ;; esac @@ -286,8 +286,7 @@ main() { quit ;; *) - logger "Invalid choice..." - exit 1 + help_text ;; esac } diff --git a/setup.sh b/setup.sh index bba298c..59144a7 100755 --- a/setup.sh +++ b/setup.sh @@ -43,11 +43,13 @@ run_setup() { log "Directory created" fi - log "CREATING/UPDATING HISTORY DATABASE TABLES" - sqlite3 "$DIR/$DB" < sql/search_history_tbl.sql - sqlite3 "$DIR/$DB" < sql/watch_history_tbl.sql - sqlite3 "$DIR/$DB" < sql/file_history.sql - log "FINISHED CREATING/UPDATING THE TABLES" + if [[ ! -f "$DIR/$DB" ]]; then + log "CREATING HISTORY DATABASE" + sqlite3 "$DIR/$DB" < sql/search_history_tbl.sql + sqlite3 "$DIR/$DB" < sql/watch_history_tbl.sql + sqlite3 "$DIR/$DB" < sql/file_history.sql + log "FINISHED CREATING DB" + fi if [[ ! -d "$DIR/themes" ]]; then log "themes directory does not exist in filesystem... Creating and moving themes" diff --git a/sql/file_history.sql b/sql/file_history.sql index 5cd63d9..9c71d56 100644 --- a/sql/file_history.sql +++ b/sql/file_history.sql @@ -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 ( id integer PRIMARY KEY AUTOINCREMENT, directory varchar(200) NOT NULL, @@ -36,9 +7,6 @@ CREATE TABLE file_history ( CHECK (LENGTH(filename) > 0), UNIQUE (directory, filename) ); -CREATE UNIQUE INDEX dir_filename_idx ON file_history(directory, filename); -INSERT INTO file_history -SELECT * FROM temp_file_history; +CREATE UNIQUE INDEX dir_filename_idx ON file_history (directory, filename); -DROP TABLE temp_file_history; diff --git a/sql/search_history_tbl.sql b/sql/search_history_tbl.sql index 538a361..7854369 100644 --- a/sql/search_history_tbl.sql +++ b/sql/search_history_tbl.sql @@ -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 ( id integer PRIMARY KEY AUTOINCREMENT, 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); -INSERT INTO search_history -SELECT * FROM temp_search_history; - -DROP TABLE temp_search_history; - diff --git a/sql/watch_history_tbl.sql b/sql/watch_history_tbl.sql index 4a6e9dc..347bf53 100644 --- a/sql/watch_history_tbl.sql +++ b/sql/watch_history_tbl.sql @@ -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 ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - anime_name VARCHAR(200) NOT NULL, - episode_number INTEGER NOT NULL, + 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) + CHECK (LENGTH(anime_name) > 0), + CHECK (episode_number > 0), + 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 -SELECT * FROM temp_watch_history; +CREATE UNIQUE INDEX IF NOT EXISTS watch_anime_episode_idx ON watch_history (anime_name, episode_number); -DROP TABLE IF EXISTS temp_watch_history;