mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-11-22 03:19:53 -08:00
add directory tracking and better regex
This commit is contained in:
parent
ce27ce7684
commit
0e1130f7c0
20
ani-cli
20
ani-cli
@ -183,8 +183,8 @@ check_db() {
|
|||||||
AND episode_number = '$2';"
|
AND episode_number = '$2';"
|
||||||
fi
|
fi
|
||||||
res=$(run_stmt "$stmt")
|
res=$(run_stmt "$stmt")
|
||||||
|
return $res
|
||||||
# logger "END check_db... Result -> $res"
|
# logger "END check_db... Result -> $res"
|
||||||
return "$res"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# return true (0) if $source_dt > $target_dt
|
# return true (0) if $source_dt > $target_dt
|
||||||
@ -202,7 +202,11 @@ check_date() {
|
|||||||
update_date() {
|
update_date() {
|
||||||
datetime=$(date +'%Y-%m-%d %H:%M:%S')
|
datetime=$(date +'%Y-%m-%d %H:%M:%S')
|
||||||
stmt=""
|
stmt=""
|
||||||
if [[ "$1" == "file" ]]; then
|
if [[ "$1" == "directory" ]]; then
|
||||||
|
logger "UPDATING FILE_HISTORY: directory='$2', filename='DIRECTORY', search_date='$datetime'"
|
||||||
|
stmt="UPDATE file_history SET watch_date = '$datetime' \
|
||||||
|
WHERE directory = '$2' and filename = '$3';"
|
||||||
|
elif [[ "$1" == "file" ]]; then
|
||||||
logger "UPDATING FILE_HISTORY: directory='$2', filename='$3', search_date='$datetime'"
|
logger "UPDATING FILE_HISTORY: directory='$2', filename='$3', search_date='$datetime'"
|
||||||
stmt="UPDATE file_history SET watch_date = '$datetime' \
|
stmt="UPDATE file_history SET watch_date = '$datetime' \
|
||||||
WHERE directory = '$2' and filename = '$3';"
|
WHERE directory = '$2' and filename = '$3';"
|
||||||
@ -246,7 +250,10 @@ insert_history() {
|
|||||||
res=$?
|
res=$?
|
||||||
else
|
else
|
||||||
logger "Row not found in DB... inserting"
|
logger "Row not found in DB... inserting"
|
||||||
if [[ "$1" == "file" ]]; then
|
if [[ "$1" == "directory" ]]; then
|
||||||
|
stmt="INSERT INTO file_history(directory, filename, watch_date) \
|
||||||
|
VALUES('$2', 'DIRECTORY', '$datetime');"
|
||||||
|
elif [[ "$1" == "file" ]]; then
|
||||||
stmt="INSERT INTO file_history(directory, filename, watch_date) \
|
stmt="INSERT INTO file_history(directory, filename, watch_date) \
|
||||||
VALUES('$2', '$3', '$datetime');"
|
VALUES('$2', '$3', '$datetime');"
|
||||||
elif [[ "$2" == "search" ]]; then
|
elif [[ "$2" == "search" ]]; then
|
||||||
@ -319,7 +326,7 @@ play_file() {
|
|||||||
logger "Checking if file is playable"
|
logger "Checking if file is playable"
|
||||||
if [[ "$1" =~ ($playable)$ ]]; then
|
if [[ "$1" =~ ($playable)$ ]]; then
|
||||||
filename=$(grep -oE '[^/]*$' <<< "$1")
|
filename=$(grep -oE '[^/]*$' <<< "$1")
|
||||||
directory=$(sed -E "s/\/$filename//" <<< "$1")
|
directory=$(sed -E "s/(\/[^\/]+$)//" <<< "$1")
|
||||||
insert_history "file" "$directory" "$filename" &
|
insert_history "file" "$directory" "$filename" &
|
||||||
if [[ "$1" =~ .mp3 ]]; then
|
if [[ "$1" =~ .mp3 ]]; then
|
||||||
logger ".mp3 file found... playing without video"
|
logger ".mp3 file found... playing without video"
|
||||||
@ -380,9 +387,8 @@ find_media() {
|
|||||||
get_directory_data "$inp"
|
get_directory_data "$inp"
|
||||||
[ -z "$inputlist" ] && return 1
|
[ -z "$inputlist" ] && return 1
|
||||||
|
|
||||||
span=$(generate_span "Current directory: $inp")
|
|
||||||
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 15 -i -sep '|' -mesg "$span" -a "$watched" \
|
-l 15 -i -sep '|' -mesg "$(generate_span "Current directory: $inp")" -a "$watched" \
|
||||||
-p "Enter selection" <<< "$inputlist")
|
-p "Enter selection" <<< "$inputlist")
|
||||||
|
|
||||||
case "$selection" in
|
case "$selection" in
|
||||||
@ -400,6 +406,7 @@ find_media() {
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [ -d "$inp/$selection" ] || [ -f "$inp/$selection" ]; then
|
if [ -d "$inp/$selection" ] || [ -f "$inp/$selection" ]; then
|
||||||
|
insert_history "directory" "$inp/$selection" &
|
||||||
if [ "$inp" = "/" ]; then
|
if [ "$inp" = "/" ]; then
|
||||||
find_media "$selection"
|
find_media "$selection"
|
||||||
else
|
else
|
||||||
@ -892,6 +899,7 @@ case $scrape in
|
|||||||
file)
|
file)
|
||||||
logger "STARTING DIR: $play_dir"
|
logger "STARTING DIR: $play_dir"
|
||||||
[ ! -d "$play_dir" ] && die "$play_dir does not exist"
|
[ ! -d "$play_dir" ] && die "$play_dir does not exist"
|
||||||
|
insert_history "directory" "$play_dir" &
|
||||||
video_path=$(find_media "$play_dir")
|
video_path=$(find_media "$play_dir")
|
||||||
retcode="$?"
|
retcode="$?"
|
||||||
if [ "$retcode" -ne 0 ]; then
|
if [ "$retcode" -ne 0 ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user