mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-11-22 03:19:53 -08:00
Compare commits
No commits in common. "24f3c251422a05d93d62adeaf21882a132d33ff5" and "2e9e28883ed9ff17facc43687a1036c994952c4a" have entirely different histories.
24f3c25142
...
2e9e28883e
102
ani-cli
102
ani-cli
@ -156,13 +156,23 @@ run_stmt() {
|
|||||||
# Return number of matches for anime/episode in db
|
# Return number of matches for anime/episode in db
|
||||||
check_db() {
|
check_db() {
|
||||||
if [[ "$1" == "directory" ]]; then
|
if [[ "$1" == "directory" ]]; then
|
||||||
stmt="SELECT DISTINCT COUNT(*) FROM file_history WHERE directory = '$2';"
|
stmt="SELECT DISTINCT COUNT(*) \
|
||||||
|
FROM file_history \
|
||||||
|
WHERE directory = '$2';"
|
||||||
elif [[ "$1" == "file" ]]; then
|
elif [[ "$1" == "file" ]]; then
|
||||||
stmt="SELECT DISTINCT COUNT(*) FROM file_history WHERE directory = '$2' AND filename = '$3';"
|
stmt="SELECT DISTINCT COUNT(*) \
|
||||||
|
FROM file_history \
|
||||||
|
WHERE directory = '$2' \
|
||||||
|
AND filename = '$3';"
|
||||||
elif [[ "$2" == "search" ]]; then
|
elif [[ "$2" == "search" ]]; then
|
||||||
stmt="SELECT DISTINCT COUNT(*) FROM search_history WHERE anime_name = '$1';"
|
stmt="SELECT DISTINCT COUNT(*) \
|
||||||
|
FROM search_history \
|
||||||
|
WHERE anime_name = '$1';"
|
||||||
else
|
else
|
||||||
stmt="SELECT DISTINCT COUNT(*) FROM watch_history WHERE anime_name = '$1' AND episode_number = '$2';"
|
stmt="SELECT DISTINCT COUNT(*) \
|
||||||
|
FROM watch_history \
|
||||||
|
WHERE anime_name = '$1' \
|
||||||
|
AND episode_number = '$2';"
|
||||||
fi
|
fi
|
||||||
res=$(run_stmt "$stmt")
|
res=$(run_stmt "$stmt")
|
||||||
return $res
|
return $res
|
||||||
@ -185,13 +195,16 @@ update_date() {
|
|||||||
stmt=""
|
stmt=""
|
||||||
if [[ "$1" == "directory" ]]; then
|
if [[ "$1" == "directory" ]]; then
|
||||||
lg "UPDATING FILE_HISTORY: directory='$2', filename='DIRECTORY', search_date='$datetime'"
|
lg "UPDATING FILE_HISTORY: directory='$2', filename='DIRECTORY', search_date='$datetime'"
|
||||||
stmt="UPDATE file_history SET watch_date = '$datetime' WHERE directory = '$2' and filename = '$3';"
|
stmt="UPDATE file_history SET watch_date = '$datetime' \
|
||||||
|
WHERE directory = '$2' and filename = '$3';"
|
||||||
elif [[ "$1" == "file" ]]; then
|
elif [[ "$1" == "file" ]]; then
|
||||||
lg "UPDATING FILE_HISTORY: directory='$2', filename='$3', search_date='$datetime'"
|
lg "UPDATING FILE_HISTORY: directory='$2', filename='$3', search_date='$datetime'"
|
||||||
stmt="UPDATE file_history SET watch_date = '$datetime' WHERE directory = '$2' and filename = '$3';"
|
stmt="UPDATE file_history SET watch_date = '$datetime' \
|
||||||
|
WHERE directory = '$2' and filename = '$3';"
|
||||||
elif [[ "$2" == "search" ]]; then
|
elif [[ "$2" == "search" ]]; then
|
||||||
lg "UPDATING SEARCH_HISTORY: anime_name='$1', search_date='$datetime'"
|
lg "UPDATING SEARCH_HISTORY: anime_name='$1', search_date='$datetime'"
|
||||||
stmt="UPDATE search_history SET search_date = '$datetime' WHERE anime_name = '$1';"
|
stmt="UPDATE search_history SET search_date = '$datetime' \
|
||||||
|
WHERE anime_name = '$1';"
|
||||||
elif [[ $# -ge 3 ]]; then
|
elif [[ $# -ge 3 ]]; then
|
||||||
temp_dt="${3// /:}"
|
temp_dt="${3// /:}"
|
||||||
[ -z "$temp_dt" ] && return 1
|
[ -z "$temp_dt" ] && return 1
|
||||||
@ -203,10 +216,14 @@ update_date() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
lg "UPDATING watch_history from sync. watch_date -> $temp_dt"
|
lg "UPDATING watch_history from sync. watch_date -> $temp_dt"
|
||||||
stmt="UPDATE watch_history SET watch_date = '$temp_dt' WHERE anime_name = '$1' AND episode_number = $2;"
|
stmt="UPDATE watch_history SET watch_date = '$temp_dt' \
|
||||||
|
WHERE anime_name = '$1' \
|
||||||
|
AND episode_number = $2;"
|
||||||
else
|
else
|
||||||
lg "UPDATING WATCH_HISTORY: anime_name='$1', episode_number='$2' search_date='$datetime'"
|
lg "UPDATING WATCH_HISTORY: anime_name='$1', episode_number='$2' search_date='$datetime'"
|
||||||
stmt="UPDATE watch_history SET watch_date = '$datetime' WHERE anime_name = '$1' AND episode_number = $2;"
|
stmt="UPDATE watch_history SET watch_date = '$datetime' \
|
||||||
|
WHERE anime_name = '$1' \
|
||||||
|
AND episode_number = $2;"
|
||||||
fi
|
fi
|
||||||
wait # in case there's another insert/update still running in background?
|
wait # in case there's another insert/update still running in background?
|
||||||
run_stmt "$stmt"
|
run_stmt "$stmt"
|
||||||
@ -225,23 +242,20 @@ insert_history() {
|
|||||||
res=$?
|
res=$?
|
||||||
else
|
else
|
||||||
lg "Row not found in DB... inserting"
|
lg "Row not found in DB... inserting"
|
||||||
case "$1" in
|
if [[ "$1" == "directory" ]]; then
|
||||||
directory)
|
stmt="INSERT INTO file_history(directory, filename, watch_date) \
|
||||||
stmt="INSERT INTO file_history(directory, filename, watch_date) VALUES('$2', 'DIRECTORY', '$datetime');"
|
VALUES('$2', 'DIRECTORY', '$datetime');"
|
||||||
;;
|
elif [[ "$1" == "file" ]]; then
|
||||||
file)
|
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
|
||||||
search)
|
stmt="INSERT INTO search_history(anime_name, search_date) \
|
||||||
stmt="INSERT INTO search_history(anime_name, search_date) VALUES('$2', '$datetime');"
|
VALUES('$1', '$datetime');"
|
||||||
;;
|
else
|
||||||
watch)
|
stmt="INSERT INTO \
|
||||||
stmt="INSERT INTO watch_history(anime_name, episode_number, watch_date) VALUES('$2', '$3', '$datetime');"
|
watch_history(anime_name, episode_number, watch_date) \
|
||||||
;;
|
VALUES('$1', '$2', '$datetime');"
|
||||||
sync)
|
fi
|
||||||
stmt="INSERT INTO watch_history(anime_name, episode_number, watch_date) VALUES('$2', '$3', '$4');"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
lg "INSERT STATEMENT -> $stmt"
|
lg "INSERT STATEMENT -> $stmt"
|
||||||
wait # in case there's another insert/update still running in background
|
wait # in case there's another insert/update still running in background
|
||||||
run_stmt "$stmt"
|
run_stmt "$stmt"
|
||||||
@ -278,7 +292,7 @@ sync_watch_history() {
|
|||||||
while read -r ep; do
|
while read -r ep; do
|
||||||
episode_num=$(awk -F '|' '{print $1}' <<< "$ep")
|
episode_num=$(awk -F '|' '{print $1}' <<< "$ep")
|
||||||
watch_date=$(awk -F '|' '{print $NF}' <<< "$ep")
|
watch_date=$(awk -F '|' '{print $NF}' <<< "$ep")
|
||||||
if ! insert_history "sync" "$anime_name" "$episode_num" "$watch_date"; then
|
if ! insert_history "$anime_name" "$episode_num" "$watch_date"; then
|
||||||
((++errs))
|
((++errs))
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@ -546,7 +560,7 @@ anime_selection() {
|
|||||||
[ -z "$name" ] && name="$anime_id"
|
[ -z "$name" ] && name="$anime_id"
|
||||||
[ -z "$selection_id" ] && die "Invalid number entered"
|
[ -z "$selection_id" ] && die "Invalid number entered"
|
||||||
|
|
||||||
insert_history "search" "$name" &
|
insert_history "$name" "search" &
|
||||||
|
|
||||||
read -r last_ep_number <<- EOF
|
read -r last_ep_number <<- EOF
|
||||||
$(search_eps "$selection_id")
|
$(search_eps "$selection_id")
|
||||||
@ -626,7 +640,7 @@ open_episode() {
|
|||||||
|
|
||||||
# Don't update watch history if downloading episode
|
# Don't update watch history if downloading episode
|
||||||
if [ "$is_download" -eq 0 ]; then
|
if [ "$is_download" -eq 0 ]; then
|
||||||
insert_history "watch" "$anime_id" "$episode" &
|
insert_history "$anime_id" "$episode" &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dpage_link=$(get_dpage_link "$anime_id" "$episode")
|
dpage_link=$(get_dpage_link "$anime_id" "$episode")
|
||||||
@ -699,7 +713,7 @@ stream() {
|
|||||||
# skip search_anime function and assign $query
|
# skip search_anime function and assign $query
|
||||||
anime_id="${query// /}"
|
anime_id="${query// /}"
|
||||||
selection_id="$anime_id"
|
selection_id="$anime_id"
|
||||||
insert_history "search" "$anime_id" &
|
insert_history "$anime_id" "search" &
|
||||||
read -r last_ep_number <<< "$(search_eps "$selection_id")"
|
read -r last_ep_number <<< "$(search_eps "$selection_id")"
|
||||||
fi
|
fi
|
||||||
episode_selection
|
episode_selection
|
||||||
@ -919,7 +933,7 @@ main() {
|
|||||||
fi
|
fi
|
||||||
printf "$c_blue[${c_cyan}%s$c_blue] $c_magenta%s$c_reset\n" "r" "replay current episode"
|
printf "$c_blue[${c_cyan}%s$c_blue] $c_magenta%s$c_reset\n" "r" "replay current episode"
|
||||||
printf "$c_blue[${c_cyan}%s$c_blue] $c_yellow%s$c_reset\n" "a" "search for another anime"
|
printf "$c_blue[${c_cyan}%s$c_blue] $c_yellow%s$c_reset\n" "a" "search for another anime"
|
||||||
printf "$c_blue[${c_cyan}%s$c_blue] $c_magenta%s$c_reset\n" "Q" "change video quality (current: $quality)"
|
printf "$c_blue[${c_cyan}%s$c_blue] $c_magenta%s$c_reset\n" "Q" "change video quality"
|
||||||
printf "$c_blue[${c_cyan}%s$c_blue] $c_red%s$c_reset\n" "q" "exit"
|
printf "$c_blue[${c_cyan}%s$c_blue] $c_red%s$c_reset\n" "q" "exit"
|
||||||
printf "${c_blue}Enter choice:${c_green} "
|
printf "${c_blue}Enter choice:${c_green} "
|
||||||
read -r choice
|
read -r choice
|
||||||
@ -947,33 +961,13 @@ main() {
|
|||||||
lg "NEW EPISODE: $selection_id - $episode"
|
lg "NEW EPISODE: $selection_id - $episode"
|
||||||
;;
|
;;
|
||||||
Q)
|
Q)
|
||||||
|
qualities="best|1080p|720p|480p|360p|worst"
|
||||||
if ((IS_ROFI == 1)); then
|
if ((IS_ROFI == 1)); then
|
||||||
case "$quality" in
|
|
||||||
best)
|
|
||||||
cur_quality=0
|
|
||||||
;;
|
|
||||||
1080p)
|
|
||||||
cur_quality=1
|
|
||||||
;;
|
|
||||||
720p)
|
|
||||||
cur_quality=2
|
|
||||||
;;
|
|
||||||
360p)
|
|
||||||
cur_quality=3
|
|
||||||
;;
|
|
||||||
worst)
|
|
||||||
cur_quality=4
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
cur_quality=0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
choice=$(rofi -dmenu -dpi "$DPI" -config "$ROFI_CFG" \
|
choice=$(rofi -dmenu -dpi "$DPI" -config "$ROFI_CFG" \
|
||||||
-i -l 5 -only-match -sep '|' -a "$cur_quality" -mesg "$(generate_span "Current quality: $quality")" \
|
-i -l 5 -only-match -sep '|' \
|
||||||
-p "Choose quality:" <<< "1. best|2. 1080p|3. 720p|4. 360p|5. worst")
|
-p "Choose quality:" <<< "1. best (default)|2. 1080p|3. 720p|4. 360p|5. worst")
|
||||||
quality=$(awk '{ print $2 }' <<< "$choice")
|
quality=$(awk '{ print $2 }' <<< "$choice")
|
||||||
else
|
else
|
||||||
qualities="best|1080p|720p|480p|360p|worst"
|
|
||||||
printf "${c_blue}Choose quality: [$qualities]:$c_reset "
|
printf "${c_blue}Choose quality: [$qualities]:$c_reset "
|
||||||
read -r quality
|
read -r quality
|
||||||
while [[ ! "$quality" =~ ($qualities) ]]; do
|
while [[ ! "$quality" =~ ($qualities) ]]; do
|
||||||
|
@ -11,7 +11,7 @@ CFG_FILE="$CFG_DIR/themes/aniwrapper.rasi"
|
|||||||
DEFAULT_DOWNLOAD="$HOME/Videos/sauce"
|
DEFAULT_DOWNLOAD="$HOME/Videos/sauce"
|
||||||
ROFI_THEME="aniwrapper.rasi"
|
ROFI_THEME="aniwrapper.rasi"
|
||||||
THEMES="aniwrapper (default)|dracula|doomone|fancy|flamingo|material|nord|onedark"
|
THEMES="aniwrapper (default)|dracula|doomone|fancy|flamingo|material|nord|onedark"
|
||||||
QUALITIES="1. best|2. 1080p|3. 720p|4. 360p|5. worst"
|
QUALITIES="1. best (default)|2. 1080p|3. 720p|4. 360p|5. worst"
|
||||||
QUALITY=best
|
QUALITY=best
|
||||||
DPI=96
|
DPI=96
|
||||||
GET_QUALITY=0
|
GET_QUALITY=0
|
||||||
@ -98,7 +98,7 @@ run() {
|
|||||||
get_quality() {
|
get_quality() {
|
||||||
if ((IS_ROFI == 1)); then
|
if ((IS_ROFI == 1)); then
|
||||||
selection=$(rofi -dpi "$DPI" -dmenu -config "$CFG_FILE" \
|
selection=$(rofi -dpi "$DPI" -dmenu -config "$CFG_FILE" \
|
||||||
-l 5 -selected-row 0 -a 0 \
|
-l 5 -selected-row 0 \
|
||||||
-theme-str 'listview {columns: 1;}' -p "Choose video quality:" \
|
-theme-str 'listview {columns: 1;}' -p "Choose video quality:" \
|
||||||
-sep '|' -only-match <<< "$QUALITIES")
|
-sep '|' -only-match <<< "$QUALITIES")
|
||||||
QUALITY=$(awk '{print $2}' <<< "$selection")
|
QUALITY=$(awk '{print $2}' <<< "$selection")
|
||||||
|
Loading…
Reference in New Issue
Block a user