mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-10-28 04:44:11 -07:00
Compare commits
4 Commits
7c2b547b57
...
50af29a5bd
Author | SHA1 | Date | |
---|---|---|---|
|
50af29a5bd | ||
|
86f5da5976 | ||
|
9a19dbf60c | ||
|
ddb8d01ff2 |
15
ani-cli
15
ani-cli
@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
BASE_URL=$(curl -s -L -o /dev/null -w "%{url_effective}\n" https://gogoanime.cm)
|
||||
CFG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/aniwrapper"
|
||||
HISTORY_DB="$CFG_DIR/history.sqlite3"
|
||||
PLAYER_CMD="mpv"
|
||||
@ -15,7 +14,6 @@ SILENT=0
|
||||
|
||||
player_fn="mpv"
|
||||
playable="\.mp4|\.mkv|\.ts|\.mp3|\.webm"
|
||||
playable_list="mp4,mkv,ts,mp3,webm"
|
||||
prog="ani-cli"
|
||||
c_red="\033[1;31m"
|
||||
c_green="\033[1;32m"
|
||||
@ -336,6 +334,7 @@ get_directory_data() {
|
||||
[ "$search_dir" = "/" ] && cnt=0 # account for no ../ on /
|
||||
for directory in "$1"/*; do
|
||||
directory="${directory##*/}"
|
||||
[ ! -d "$search_dir/$directory" ] && continue
|
||||
[ -z "$inputlist" ] && inputlist="$directory" || inputlist="$inputlist|$directory"
|
||||
if ! check_db "directory" "$search_dir/$directory"; then
|
||||
lg "$search_dir/$directory opened before... adding $cnt to list" 1> /dev/stderr
|
||||
@ -345,7 +344,8 @@ get_directory_data() {
|
||||
done
|
||||
shopt -s nullglob # set nullglob to avoid printing output if no files with extension exist
|
||||
shopt -s nocaseglob # case insensitive globbing
|
||||
for filename in "$1"/*."{$playable_list}"; do
|
||||
for filename in "$search_dir"/*.{mp4,mkv,ts,mp3,webm}; do
|
||||
filename="${filename##*/}"
|
||||
[ -z "$inputlist" ] && inputlist="$filename" || inputlist="$inputlist|$filename"
|
||||
if ! check_db "file" "$search_dir" "$filename"; then
|
||||
lg "$filename watched before... adding $cnt to list" 1> /dev/stderr
|
||||
@ -355,13 +355,14 @@ get_directory_data() {
|
||||
done
|
||||
shopt -u nullglob
|
||||
shopt -u nocaseglob
|
||||
lg "INPUTLIST: $inputlist"
|
||||
if [[ -n "$inputlist" && "$search_dir" != / ]]; then
|
||||
inputlist="../|$inputlist|Back|Quit"
|
||||
elif [[ -z "$inputlist" && "$search_dir" != / ]]; then
|
||||
inputlist="../|Back|Quit"
|
||||
elif [[ "$search_dir" = / ]]; then
|
||||
inputlist="$inputlist|Back|Quit"
|
||||
else
|
||||
inputlist="Quit"
|
||||
fi
|
||||
lg "INPUT LIST: $inputlist" 1> /dev/stderr
|
||||
lg "WATCHED LIST: $watched" 1> /dev/stderr
|
||||
@ -689,13 +690,13 @@ open_episode() {
|
||||
{
|
||||
mkdir -p "$dl_dir" || die "Could not create directory"
|
||||
if command -v "notify-send" > /dev/null; then
|
||||
if aria2c --referer="$dpage_link" "$video_url" --dir="$dl_dir" -o "$episode.mp4" --download-result=hide; then
|
||||
if aria2c -x 16 -s 16 --referer="$dpage_link" "$video_url" --dir="$dl_dir" -o "$episode.mp4" --download-result=hide; then
|
||||
notify-send -i "$ANIWRAPPER_ICON_PATH" "Download complete for ${anime_id//-/ } - Episode: $episode"
|
||||
else
|
||||
notify-send -i "$MAISAN_ICON_PATH" "Download failed for ${anime_id//-/ } - Episode: $episode. Please retry or check your internet connection"
|
||||
fi
|
||||
else
|
||||
if aria2c --referer="$dpage_link" "$video_url" --dir="$dl_dir" -o "$episode.mp4" --download-result=hide; then
|
||||
if aria2c -x 16 -s 16 --referer="$dpage_link" "$video_url" --dir="$dl_dir" -o "$episode.mp4" --download-result=hide; then
|
||||
((SILENT != 1)) && printf "${c_green}Downloaded complete for %s - Episode: %s${c_reset}\n" "${anime_id//-/ }" "$episode"
|
||||
else
|
||||
((SILENT != 1)) && printf "${c_red}Download failed for %s - Episode: %s, please retry or check your internet connection${c_reset}\n" "${anime_id//-/ }" "$episode"
|
||||
@ -851,9 +852,11 @@ parse_args() {
|
||||
main() {
|
||||
case $scrape in
|
||||
query)
|
||||
BASE_URL=$(curl -s -L -o /dev/null -w "%{url_effective}\n" https://gogoanime.cm)
|
||||
stream
|
||||
;;
|
||||
history)
|
||||
BASE_URL=$(curl -s -L -o /dev/null -w "%{url_effective}\n" https://gogoanime.cm)
|
||||
stmt="SELECT DISTINCT anime_name FROM watch_history ORDER BY watch_date DESC"
|
||||
search_results=$(printf "%s\n" "$stmt" | sqlite3 -noheader "$HISTORY_DB")
|
||||
[ -z "$search_results" ] && die "History is empty"
|
||||
|
@ -65,7 +65,7 @@ seppuku() {
|
||||
}
|
||||
|
||||
quit() {
|
||||
lg 'Quitting...'
|
||||
((SILENT != 1)) && lg 'Quitting...'
|
||||
exit 0
|
||||
}
|
||||
|
||||
@ -326,7 +326,7 @@ main() {
|
||||
}
|
||||
|
||||
parse_args "$@"
|
||||
lg "CONFIG DIR: $CFG_DIR"
|
||||
lg "ROFI CFG: $CFG_FILE"
|
||||
((SILENT != 1)) && lg "CONFIG DIR: $CFG_DIR"
|
||||
((SILENT != 1)) && lg "ROFI CFG: $CFG_FILE"
|
||||
check_flags
|
||||
main
|
||||
|
Loading…
Reference in New Issue
Block a user