mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-11-22 03:19:53 -08:00
replace playlist feature with play from file and update readme
This commit is contained in:
parent
646564fb32
commit
eec96f21b4
36
README.md
36
README.md
@ -4,7 +4,7 @@
|
||||
|
||||
[**_Setup_**](#setup) | [**_Usage_**](#usage) | [**_Screenshots_**](#screenshots)
|
||||
|
||||
![Aniwrapper screenshot](https://imgur.com/QaftS71.png)
|
||||
![Aniwrapper screenshot](https://imgur.com/bhea2u3.png)
|
||||
|
||||
</div>
|
||||
|
||||
@ -52,7 +52,7 @@ however using the ani-cli script itself is also possible
|
||||
- [Option 1: Streaming](#option-1-streaming)
|
||||
- [Option 2: Download](#option-2-download)
|
||||
- [Option 3: Continue](#option-3-continue)
|
||||
- [Option 4: Playlist](#option-4-playlist)
|
||||
- [Option 4: Play from File](#option-4-play-from-file)
|
||||
- [Option 5: Sync History](#option-5-sync-history)
|
||||
- [ani-cli Script](#ani-cli-script)
|
||||
- [Screenshots](#screenshots)
|
||||
@ -156,18 +156,31 @@ In the episode selection menu, you can select an individual episode from the lis
|
||||
|
||||
## aniwrapper
|
||||
|
||||
# Launch aniwrapper menu
|
||||
# Launch menu (default video quality: best)
|
||||
aniwrapper
|
||||
|
||||
# Launch menu with quality selection
|
||||
aniwrapper -q
|
||||
|
||||
# Enable verbose logging
|
||||
aniwrapper -v
|
||||
|
||||
# Use ani-cli command-line mode (rofi disabled)
|
||||
aniwrapper -c
|
||||
|
||||
# Download anime in command-line mode
|
||||
aniwrapper -d
|
||||
|
||||
# All flags can be used in command-line mode as well
|
||||
# ex. The following command will launch aniwrapper in command-line download mode
|
||||
aniwrapper -cqd
|
||||
|
||||
|
||||
### Option 1: Streaming
|
||||
|
||||
<div align="center">
|
||||
|
||||
- [click here](https://imgur.com/nLjqLCL.gif) for an example showing streaming a new anime
|
||||
- [click here](https://imgur.com/nI455zI.gif) for an example showing streaming a previously watched anime
|
||||
|
||||
</div>
|
||||
|
||||
Streaming is the default option for the `aniwrapper` script and will prompt you with each of the menus specified in the _[aniwrapper Menus](#aniwrapper-menus)_ section
|
||||
|
||||
### Option 2: Download
|
||||
@ -180,9 +193,9 @@ After specifying the download directory (or leaving it blank for the default), y
|
||||
|
||||
The continue option queries the `sqlite3` history databse and pulls the list of distinct anime names from the `watch_history` table. Select an option from the list and the most recently watched episode of the selected anime will play
|
||||
|
||||
### Option 4: Playlist
|
||||
### Option 4: Play from File
|
||||
|
||||
_description coming soon_
|
||||
This option prompts you to provide the path to your `Videos` directory. Any path can be provided, but the script will begin the search from the provided path. From there, follow the prompts to select the video you want to watch and it will be opened in `mpv`
|
||||
|
||||
### Option 5: Sync History
|
||||
|
||||
@ -217,6 +230,9 @@ At the moment, the requirements are as follows:
|
||||
# sync history across devices
|
||||
ani-cli -s
|
||||
|
||||
# run ani-cli in command-line mode (rofi disabled)
|
||||
ani-cli -c
|
||||
|
||||
Multiple episodes can be viewed/downloaded by giving the episode range like so
|
||||
|
||||
Choose episode [1-13]: 1 6
|
||||
@ -228,7 +244,7 @@ This would open/download episodes 1 2 3 4 5 6
|
||||
<div align="center">
|
||||
|
||||
Aniwrapper Main Menu
|
||||
![aniwrapper frontpage](https://imgur.com/QaftS71.png)
|
||||
![aniwrapper frontpage](https://imgur.com/bhea2u3.png)
|
||||
Aniwrapper Streaming Menu
|
||||
![aniwrapper streaming options](https://imgur.com/jVJQERk.png)
|
||||
More to come soon... maybe
|
||||
|
242
aniwrapper
242
aniwrapper
@ -13,13 +13,14 @@ DEFAULT_PLAYLIST="$CFG_DIR/playlists/playlist.txt"
|
||||
CFG_FILE="meh.rasi"
|
||||
QUALITIES="1. best|2. worst"
|
||||
QUALITY="best"
|
||||
PLAYER_CMD="mpv"
|
||||
GET_QUALITY=0
|
||||
VERBOSE=0
|
||||
IS_ROFI=1
|
||||
IS_DOWNLOAD=0
|
||||
|
||||
quit="6. Quit"
|
||||
options="1. Stream|2. Download|3. Continue|4. Playlist|5. Sync History|$quit"
|
||||
options="1. Stream|2. Download|3. Continue|4. Play from File|5. Sync History|$quit"
|
||||
|
||||
|
||||
#############
|
||||
@ -69,85 +70,7 @@ log() {
|
||||
fi
|
||||
}
|
||||
|
||||
########
|
||||
# Main #
|
||||
########
|
||||
while getopts 'vhqcd' OPT; do
|
||||
case "$OPT" in
|
||||
h)
|
||||
help_text
|
||||
;;
|
||||
v)
|
||||
VERBOSE=1
|
||||
;;
|
||||
q)
|
||||
GET_QUALITY=1
|
||||
log "Quality prompt enabled"
|
||||
;;
|
||||
c)
|
||||
IS_ROFI=0
|
||||
log "Command-line (ani-cli) mode set"
|
||||
;;
|
||||
d)
|
||||
IS_DOWNLOAD=1
|
||||
log "Download flag set..."
|
||||
;;
|
||||
*)
|
||||
log "Invalid option"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
log "CONFIG DIR: $CFG_DIR"
|
||||
|
||||
# Check if command-line flag is set
|
||||
if [[ "$IS_ROFI" -eq 0 ]] && [[ "$IS_DOWNLOAD" -eq 0 ]]; then
|
||||
run -c
|
||||
exit $?
|
||||
elif [[ "$IS_ROFI" -eq 0 ]] && [[ "$IS_DOWNLOAD" -eq 1 ]]; then
|
||||
printf "%s" "Enter download dir: "
|
||||
read -r dl_dir
|
||||
log "Download dir: $dl_dir"
|
||||
run "-cd $dl_dir"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
choice=$(echo "${options[@]}" | rofi -dmenu -sep '|' \
|
||||
-config "$CFG_DIR/$CFG_FILE" -l 6 -i -p "Aniwrapper")
|
||||
|
||||
[ "$choice" == "$quit" ] && quit
|
||||
|
||||
selection=$(printf "%s\n" "$choice" | awk '{ print $1 }')
|
||||
|
||||
case "$selection" in
|
||||
1.)
|
||||
# ---------------------------------------------------------------------------
|
||||
# streaming
|
||||
# ---------------------------------------------------------------------------
|
||||
log "Streaming mode"
|
||||
run
|
||||
;;
|
||||
2.)
|
||||
# ---------------------------------------------------------------------------
|
||||
# download
|
||||
# ---------------------------------------------------------------------------
|
||||
log "Download anime"
|
||||
dl_dir=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
|
||||
-l 1 -p "Enter download dir:")
|
||||
# if dl_dir is none set to current directory
|
||||
[ "$dl_dir" == "" ] && dl_dir="$DEFAULT_DOWNLOAD"
|
||||
run -d "$dl_dir"
|
||||
;;
|
||||
3.)
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# continue
|
||||
# ---------------------------------------------------------------------------
|
||||
log "Continue watching"
|
||||
run -H
|
||||
;;
|
||||
4.)
|
||||
playlist_mode() {
|
||||
# ---------------------------------------------------------------------------
|
||||
# playlist mode
|
||||
# ---------------------------------------------------------------------------
|
||||
@ -170,6 +93,7 @@ case "$selection" in
|
||||
-config "$CFG_DIR/$CFG_FILE" -l 4 -i -p "Enter choice:")
|
||||
[ -z "$choice" ] && seppuku "No choice selected"
|
||||
[ "$choice" == "$quit" ] && quit
|
||||
|
||||
log "Selection: $choice"
|
||||
selection=$(printf "%s\n" "$choice" | awk '{ print $1 }')
|
||||
if [[ "$selection" == "1." ]]; then
|
||||
@ -261,6 +185,163 @@ case "$selection" in
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
play_file() {
|
||||
# opens the passed in file with $PLAYER_CMD
|
||||
log "Checking if file is playable"
|
||||
if [[ "$1" =~ (\.mp4|\.mkv|\.ts)$ ]]; then
|
||||
log "File is playable..."
|
||||
log "Playing file: $1"
|
||||
if [[ "$VERBOSE" -eq 1 ]]; then
|
||||
$PLAYER_CMD "$1"
|
||||
else
|
||||
$PLAYER_CMD "$1" &>/dev/null &
|
||||
fi
|
||||
exit $?
|
||||
else
|
||||
seppuku "File: $1 is not playable... Quitting"
|
||||
fi
|
||||
}
|
||||
|
||||
check_path() {
|
||||
pth="$1"
|
||||
if ! [ -d "$pth" ]; then
|
||||
seppuku "ERROR: Passed in directory is not valid: $inp"
|
||||
elif [[ $(find "$pth" -type f | wc -l) -eq 0 ]]; then
|
||||
seppuku "ERROR: Passed in directory is empty: $inp"
|
||||
fi
|
||||
}
|
||||
|
||||
find_videos() {
|
||||
# recursive function for finding path to video file given a starting directory
|
||||
inp="$1"
|
||||
# log "INPUT: $inp"
|
||||
if [ -f "$inp" ]; then
|
||||
echo "$inp"
|
||||
return 0
|
||||
fi
|
||||
check_path "$inp"
|
||||
selection=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
|
||||
-l 12 -i -p "Enter selection" <<< "$(ls "$inp")")
|
||||
if [ -z "$selection" ]; then
|
||||
seppuku "selection is empty... exiting"
|
||||
elif [ -d "$inp/$selection" ] || [ -f "$inp/$selection" ]; then
|
||||
find_videos "$inp/$selection"
|
||||
return $?
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
########
|
||||
# Main #
|
||||
########
|
||||
while getopts 'vhqcd' OPT; do
|
||||
case "$OPT" in
|
||||
h)
|
||||
help_text
|
||||
;;
|
||||
v)
|
||||
VERBOSE=1
|
||||
;;
|
||||
q)
|
||||
GET_QUALITY=1
|
||||
log "Quality prompt enabled"
|
||||
;;
|
||||
c)
|
||||
IS_ROFI=0
|
||||
log "Command-line (ani-cli) mode set"
|
||||
;;
|
||||
d)
|
||||
IS_DOWNLOAD=1
|
||||
log "Download flag set..."
|
||||
;;
|
||||
*)
|
||||
log "Invalid option"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
log "CONFIG DIR: $CFG_DIR"
|
||||
|
||||
# Check if command-line flag is set
|
||||
if [[ "$IS_ROFI" -eq 0 ]] && [[ "$IS_DOWNLOAD" -eq 0 ]]; then
|
||||
run -c
|
||||
exit $?
|
||||
elif [[ "$IS_ROFI" -eq 0 ]] && [[ "$IS_DOWNLOAD" -eq 1 ]]; then
|
||||
printf "%s" "Enter download dir: "
|
||||
read -r dl_dir
|
||||
log "Download dir: $dl_dir"
|
||||
run "-cd $dl_dir"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
choice=$(echo "${options[@]}" | rofi -dmenu -sep '|' \
|
||||
-config "$CFG_DIR/$CFG_FILE" -l 6 -i -p "Aniwrapper")
|
||||
|
||||
[ "$choice" == "$quit" ] && quit
|
||||
|
||||
selection=$(printf "%s\n" "$choice" | awk '{ print $1 }')
|
||||
|
||||
case "$selection" in
|
||||
1.)
|
||||
# ---------------------------------------------------------------------------
|
||||
# streaming
|
||||
# ---------------------------------------------------------------------------
|
||||
log "Streaming mode"
|
||||
run
|
||||
;;
|
||||
2.)
|
||||
# ---------------------------------------------------------------------------
|
||||
# download
|
||||
# ---------------------------------------------------------------------------
|
||||
log "Download anime"
|
||||
dl_dir=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
|
||||
-l 1 -p "Enter download dir:")
|
||||
# if dl_dir is none set to current directory
|
||||
[ "$dl_dir" == "" ] && dl_dir="$DEFAULT_DOWNLOAD"
|
||||
# make sure download directory exists
|
||||
if [ ! -d "$DEFAULT_DOWNLOAD" ]; then
|
||||
mkdir -p "$DEFAULT_DOWNLOAD"
|
||||
fi
|
||||
run -d "$dl_dir"
|
||||
;;
|
||||
3.)
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# continue
|
||||
# ---------------------------------------------------------------------------
|
||||
log "Continue watching"
|
||||
run -H
|
||||
;;
|
||||
4.)
|
||||
# ---------------------------------------------------------------------------
|
||||
# play
|
||||
# ---------------------------------------------------------------------------
|
||||
msg="Enter path to the videos directory or leave blank to go with the default: $HOME/Videos/sauce/"
|
||||
span="<span foreground='peachpuff' style='italic' size='small' weight='light'>$msg</span>"
|
||||
play_dir=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
|
||||
-l 1 -mesg "$span" -p "Enter path to play dir:")
|
||||
[ -z "$play_dir" ] && play_dir="$DEFAULT_DOWNLOAD"
|
||||
log "PLAY DIR: $play_dir"
|
||||
[ ! -d "$play_dir" ] && seppuku "$play_dir does not exist"
|
||||
video_path=$(find_videos "$play_dir")
|
||||
log "VIDEO PATH: $video_path"
|
||||
if [ -z "$video_path" ]; then
|
||||
seppuku "Something went wrong getting path"
|
||||
fi
|
||||
play_file "$video_path"
|
||||
# selected_dir="$play_dir/$selection"
|
||||
# [ ! -d "$selected_dir" ] && seppuku "$selected_dir does not exist"
|
||||
# log "Selection is a directory, searching one level down"
|
||||
# selection=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
|
||||
# -l 12 -i -p "Enter selection" <<< $(ls "$selected_dir"))
|
||||
# if [ -f "$selected_dir/$selection" ]; then
|
||||
# play_file "$selected_dir/$selection"
|
||||
# exit 0
|
||||
# fi
|
||||
# seppuku "Selection not a file. exiting"
|
||||
;;
|
||||
5.)
|
||||
log "Sync history database"
|
||||
@ -313,3 +394,4 @@ case "$selection" in
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user