Compare commits

...

3 Commits

Author SHA1 Message Date
ksyasuda
e511d03505 update readme 2022-02-01 01:25:08 -08:00
ksyasuda
ac47d9c350 make silent option as silent as possible? 2022-01-31 23:32:26 -08:00
ksyasuda
a1576f1549 add option to switch themes from the main menu 2022-01-31 23:29:32 -08:00
3 changed files with 105 additions and 68 deletions

View File

@ -4,7 +4,7 @@
[**_Setup_**](#setup) | [**_Usage_**](#usage) | [**_Screenshots_**](#screenshots) [**_Setup_**](#setup) | [**_Usage_**](#usage) | [**_Screenshots_**](#screenshots)
![Aniwrapper screenshot](https://imgur.com/Nvd9oJV.png) ![Aniwrapper screenshot](https://imgur.com/HFq5gCq.png)
</div> </div>
@ -15,13 +15,13 @@ which itself is a fork of
pystardust's [old-ani-cli](https://github.com/pystardust/ani-cli/tree/old-ani-cli) pystardust's [old-ani-cli](https://github.com/pystardust/ani-cli/tree/old-ani-cli)
This fork is a wrapper around a modified version of ani-cli, which uses [rofi](https://github.com/davatorium/rofi) This fork is a wrapper around a modified version of ani-cli, which uses [rofi](https://github.com/davatorium/rofi)
to gather information and control the program. to gather information and control the program flow.
In addition to `rofi`, I've also changed the way saving history works by In addition to `rofi`, I've also changed the way saving history works by
integrating a local [sqlite3](https://www.sqlite.org/index.html) database with a table for integrating a local [sqlite3](https://www.sqlite.org/index.html) database with a table for
search and watch history search, watch, and file history
While this is a fork of a fork of pystardust's old-ani-cli, I would call this more of a light fork of the [the main ani-cli](https://github.com/pystardust/ani-cli). While this is a fork of a fork of pystardust's old-ani-cli, I would call this more of a light fork of the [the main ani-cli](https://github.com/pystardust/ani-cli).
I have implemented most of the main features from the main script and continue to use the same scraping logic I have implemented most of the main features from the original script and continue to use the same scraping logic
This tool scrapes the site [gogoanime](https://gogoanime.cm). This tool scrapes the site [gogoanime](https://gogoanime.cm).
@ -29,15 +29,12 @@ This tool scrapes the site [gogoanime](https://gogoanime.cm).
**Table of Contents** **Table of Contents**
- [Aniwrapper](#aniwrapper)
- [Introduction](#introduction) - [Introduction](#introduction)
- [Setup](#setup) - [Setup](#setup)
- [Skip Intro Script](#skip-intro-script) - [Skip Intro Script](#skip-intro-script)
- [Installing](#installing) - [Installing](#installing)
- [Arch Linux](#arch-linux) - [Arch Linux](#arch-linux)
- [Manual Install](#manual-install) - [Manual Install](#manual-install)
- [Install the Dependencies](#install-the-dependencies)
- [Clone the repo](#clone-the-repo)
- [Run the setup and install the script](#run-the-setup-and-install-the-script) - [Run the setup and install the script](#run-the-setup-and-install-the-script)
- [Aniwrapper Menus](#aniwrapper-menus) - [Aniwrapper Menus](#aniwrapper-menus)
- [Search Anime](#search-anime) - [Search Anime](#search-anime)
@ -51,6 +48,7 @@ This tool scrapes the site [gogoanime](https://gogoanime.cm).
- [Option 3: Continue](#option-3-continue) - [Option 3: Continue](#option-3-continue)
- [Option 4: Play from File](#option-4-play-from-file) - [Option 4: Play from File](#option-4-play-from-file)
- [Option 5: Sync History](#option-5-sync-history) - [Option 5: Sync History](#option-5-sync-history)
- [Option 6: Choose Theme](#option-6-choose-theme)
- [ani-cli](#ani-cli) - [ani-cli](#ani-cli)
- [Screenshots](#screenshots) - [Screenshots](#screenshots)
@ -97,9 +95,7 @@ yay -S aniwrapper-git
### Manual Install ### Manual Install
To install manually, make sure the dependencies are installed first Install the Dependencies
#### Install the Dependencies
```sh ```sh
# Arch # Arch
@ -109,9 +105,7 @@ pacman -S --needed aria2 curl grep mpv rofi sed sqlite3
apt install aria2 curl grep mpv rofi sed sqlite3 apt install aria2 curl grep mpv rofi sed sqlite3
``` ```
#### Clone the repo Clone and switch into the repo directory
Use the following command to clone the Git repository locally and switch into the cloned directory
```sh ```sh
git clone https://github.com/ksyasuda/aniwrapper && cd aniwrapper git clone https://github.com/ksyasuda/aniwrapper && cd aniwrapper
@ -134,7 +128,7 @@ There are several menus used to drive the program forward
The first menu consists of a search box and a list of anime titles corresponding to past valid searches. Choose an option from the menu, or enter in a unique search query to search for a new anime. The result from this will be used to query against `gogoanime` and return similar named anime The first menu consists of a search box and a list of anime titles corresponding to past valid searches. Choose an option from the menu, or enter in a unique search query to search for a new anime. The result from this will be used to query against `gogoanime` and return similar named anime
As of the update on **_2022-01-01_**, if selecting an anime from the search history list, the [anime selection](#anime-selection) menu will be skipped and the program will move on to [episode selection](#episode-selection) If selecting an anime from the provided list, the [anime selection](#anime-selection) menu will be skipped and the program will move on to [episode selection](#episode-selection) for the chosen anime
### Dealing with conflicting search queries / rofi grabbing from search list ### Dealing with conflicting search queries / rofi grabbing from search list
@ -153,16 +147,16 @@ The above output was produced by searching: `isekai -`
## Anime Selection ## Anime Selection
The next menu is where you select the anime to watch from a narrowed down list. Elements that have a blue border and text color indicate which anime have been watched before The next menu is where you select the anime to watch from a narrowed down list of candidates. Titles that are highlighed in blue indicate that anime has been selected before
## Episode Selection ## Episode Selection
> Half-episodes (ex. saihate-no-paladin episode 7.5) are selectable, however they will not show up in the episodes list. > Half-episodes (ex. saihate-no-paladin episode 7.5) are selectable, however they will not show up in the episodes list.
> To select half episodes add 'h' to the beginning for episodes like '7.5' -> 'h7' to select saihate-no-paladin episode 7.5 > To select half episodes add 'h' to the beginning for episodes like '7.5' -> 'h7' to select saihate-no-paladin episode 7.5
This menu will promt you to select the episode(s) to watch/download Here you will be prompted to select the episode(s) to watch/download
Multiple episodes can be viewed/downloaded by giving the episode range like so Multiple episodes can be downloaded by giving the episode range like so
``` ```
Select Episode [1-13]: 1 6 Select Episode [1-13]: 1 6
@ -170,8 +164,6 @@ Select Episode [1-13]: 1 6
This would open/download episodes 1 2 3 4 5 6 This would open/download episodes 1 2 3 4 5 6
Like in the previous menu, any element with a blue border and text-color indicates that episode has been watched before
# Usage # Usage
## aniwrapper ## aniwrapper
@ -213,11 +205,16 @@ aniwrapper -d
### Option 1: Streaming ### Option 1: Streaming
- [click here](https://imgur.com/nLjqLCL.gif) for an example showing streaming a new anime
- [click here](https://imgur.com/undefined.png) for an example showing streaming a previously watched anime
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 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
<details>
<summary>Example</summary>
![example](https://imgur.com/Op9XLcY.gif)
</details>
### Option 2: Download ### Option 2: Download
The default download location is `$HOME/Videos/sauce` and will be chosen as the download directory unless otherwise specified The default download location is `$HOME/Videos/sauce` and will be chosen as the download directory unless otherwise specified
@ -232,6 +229,14 @@ The continue option queries the `sqlite3` history databse and pulls the list of
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` 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`
<details>
<summary>Example</summary>
![example](https://imgur.com/M2MOgso.gif)
</details>
### Option 5: Sync History ### Option 5: Sync History
This option allows you to sync your search/watch history across devices. It queries the database on the remote machine and inserts/updates the necessary rows This option allows you to sync your search/watch history across devices. It queries the database on the remote machine and inserts/updates the necessary rows
@ -242,6 +247,18 @@ At the moment, the requirements are as follows:
- The username must be the same across both devices - The username must be the same across both devices
- The `history.sqlite3` file must be in the default location: `$XDG_CONFIG_HOME/aniwrapper/history.sqlite3` - The `history.sqlite3` file must be in the default location: `$XDG_CONFIG_HOME/aniwrapper/history.sqlite3`
### Option 6: Choose Theme
Allows for changing the aniwrapper theme from the main menu
<details>
<summary>Example</summary>
![example](https://imgur.com/o97YqLe.gif)
</details>
## ani-cli ## ani-cli
``` ```
@ -275,13 +292,16 @@ ani-cli -c
# Screenshots # Screenshots
<div> <div align="center">
![aniwrapper main menu](https://imgur.com/Nvd9oJV.png) Main Menu (default theme)
- [query anime](https://imgur.com/vSyaoG6.png) ![aniwrapper main menu](https://imgur.com/HFq5gCq.png)
- [aniwrapper streaming options](https://imgur.com/7JxvZz8.png)
- [aniwrapper file selection](https://imgur.com/vFTxAgu.png) | | |
- [aniwrapper episode selection menu](https://imgur.com/vlOg8uc.png) | :---------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------: |
| <details><summary>doom-one</summary> ![doomone](https://imgur.com/zMU0i8l.png) </details> | <details><summary>dracula</summary> ![dracula](https://imgur.com/BPdIuX3.png)</details> |
| <details><summary>fancy</summary>![fancy](https://imgur.com/CZx73NL.png)</details> | <details><summary>material</summary>![material](https://imgur.com/eTWkxw2.png)</details> |
| <details><summary>onedark</summary>![onedark](https://imgur.com/rchqtBm.png)</details> | <details><summary>flamingo (sidebar theme)</summary>![flamingo-theme](https://imgur.com/pxF7hRE.png)</details> |
</div> </div>

View File

@ -679,7 +679,7 @@ open_episode() {
nohup "$player_fn" --http-header-fields="Referer:$dpage_link" "$video_url" > /dev/null 2>&1 & nohup "$player_fn" --http-header-fields="Referer:$dpage_link" "$video_url" > /dev/null 2>&1 &
PID=$! PID=$!
if command -v "notify-send" > /dev/null; then if command -v "notify-send" > /dev/null; then
notify-send -i "$ANIWRAPPER_ICON_PATH" "Playing $anime_id - Episode $episode" ((SILENT != 1)) && notify-send -i "$ANIWRAPPER_ICON_PATH" "Playing $anime_id - Episode $episode"
else else
((SILENT != 1)) && printf "${c_green}\nVideo playing" ((SILENT != 1)) && printf "${c_green}\nVideo playing"
fi fi
@ -692,9 +692,9 @@ open_episode() {
mkdir -p "$dl_dir" || die "Could not create directory" mkdir -p "$dl_dir" || die "Could not create directory"
if command -v "notify-send" > /dev/null; then if command -v "notify-send" > /dev/null; then
if aria2c -x 16 -s 16 --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" ((SILENT != 1)) && notify-send -i "$ANIWRAPPER_ICON_PATH" "Download complete for ${anime_id//-/ } - Episode: $episode"
else else
notify-send -i "$MAISAN_ICON_PATH" "Download failed for ${anime_id//-/ } - Episode: $episode. Please retry or check your internet connection" ((SILENT != 1)) && notify-send -i "$MAISAN_ICON_PATH" "Download failed for ${anime_id//-/ } - Episode: $episode. Please retry or check your internet connection"
fi fi
else else
if aria2c -x 16 -s 16 --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

View File

@ -22,8 +22,8 @@ IS_ROFI=1
VERBOSE=0 VERBOSE=0
SILENT=0 SILENT=0
quit="6. Quit" quit="7. Quit"
options="1. Stream|2. Download|3. Continue|4. Play from File|5. Sync History|$quit" options="1. Stream|2. Download|3. Continue|4. Play from File|5. Sync History|6. Choose Theme|$quit"
theme=default theme=default
############# #############
@ -123,38 +123,10 @@ generate_span() {
printf "%s\n" "$span" printf "%s\n" "$span"
} }
parse_args() { set_theme() {
while getopts 'vhqcdf:-:t:T:CQ:D:S' OPT; do new_theme="$1"
case "$OPT" in lg "theme: $new_theme"
h) case "$new_theme" in
help_text
exit 0
;;
v)
VERBOSE=1
;;
q)
GET_QUALITY=1
lg "Quality prompt enabled"
;;
c)
IS_ROFI=0
lg "Command-line (ani-cli) mode set"
;;
d)
IS_DOWNLOAD=1
lg "Download flag set..."
;;
f)
IS_PLAY_FROM_FILE=1
play_path="$OPTARG"
lg "Play from file flag set... skipping main menu"
lg "PLAY_PATH: $play_path"
;;
t)
theme="$OPTARG"
lg "custom theme provided: $theme"
case "$theme" in
aniwrapper) aniwrapper)
lg "Default theme chosen... doing nothing" lg "Default theme chosen... doing nothing"
theme=default theme=default
@ -185,6 +157,39 @@ parse_args() {
;; ;;
esac esac
CFG_FILE="$CFG_DIR/themes/$ROFI_THEME" CFG_FILE="$CFG_DIR/themes/$ROFI_THEME"
}
parse_args() {
while getopts 'vhqcdf:-:t:T:CQ:D:S' OPT; do
case "$OPT" in
h)
help_text
exit 0
;;
v)
VERBOSE=1
;;
q)
GET_QUALITY=1
lg "Quality prompt enabled"
;;
c)
IS_ROFI=0
lg "Command-line (ani-cli) mode set"
;;
d)
IS_DOWNLOAD=1
lg "Download flag set..."
;;
f)
IS_PLAY_FROM_FILE=1
play_path="$OPTARG"
lg "Play from file flag set... skipping main menu"
lg "PLAY_PATH: $play_path"
;;
t)
theme="$OPTARG"
set_theme "$theme"
;; ;;
C) C)
lg "Connecting to history database -> $CFG_DIR/history.sqlite3" lg "Connecting to history database -> $CFG_DIR/history.sqlite3"
@ -248,7 +253,7 @@ check_flags() {
######## ########
main() { main() {
choice=$(echo "${options[@]}" | rofi -dpi "$DPI" -dmenu -only-match -sep '|' \ choice=$(echo "${options[@]}" | rofi -dpi "$DPI" -dmenu -only-match -sep '|' \
-config "$CFG_FILE" -l 6 -i -p "Aniwrapper") -config "$CFG_FILE" -l 7 -i -p "Aniwrapper")
[ "$choice" == "$quit" ] && quit [ "$choice" == "$quit" ] && quit
@ -320,9 +325,21 @@ main() {
fi fi
;; ;;
6.) 6.)
# --------------------------------------------------------------------------- # -----------------------------------------------------------------
# choose theme
# -----------------------------------------------------------------
[ -z "$THEMES" ] && seppuku "No themes provided... exiting"
choice=$(rofi -dmenu -config "$CFG_FILE" -dpi "$DPI" \
-only-match -l 4 -i -p "Choose theme: " -sep '|' \
-theme-str 'listview { columns: 2; }' <<< "$THEMES")
theme=$(awk '{ print $1 }' <<< "$choice")
set_theme "$theme"
main
;;
7.)
# -----------------------------------------------------------------
# get out # get out
# --------------------------------------------------------------------------- # -----------------------------------------------------------------
quit quit
;; ;;
*) *)