update default theme file and make config a var

move skip intro script into scripts directory

change setup.sh to reflect new directory and theme file
This commit is contained in:
ksyasuda 2021-11-02 15:18:23 -07:00
parent 404beb96c0
commit 40202b7c65
7 changed files with 127 additions and 86 deletions

View File

@ -1,33 +1,62 @@
# ani-cli
This is a fork of pystardust's [old-ani-cli](https://github.com/pystardust/ani-cli/tree/old-ani-cli)
This is a fork of [Dink4n's ani-cli](https://github.com/Dink4n/ani-cli),
which itself is a fork of
pystardust's [old-ani-cli](https://github.com/pystardust/ani-cli/tree/old-ani-cli)
A cli to browse and watch anime.
This fork is a wrapper around a modified version of ani-cli
and uses [rofi](https://github.com/davatorium/rofi) to gather information and control the program
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
search and watch history
It is built around Dink4n's fork of ani-cli since at the time of
creation, this is the version that has downloading working correctly
This tool scrapes the site [gogoanime](https://gogoanime.vc).
It is intended to be called from the wrapper script `aniwrapper`,
however using the ani-cli script itself is also possible
## Usage
# watch anime
ani-cli <query>
### Wrapper Script `aniwrapper`
# download anime
ani-cli -d <query>
# Launch Menu (Contains same options as below, but in a rofi menu)
aniwrapper
# resume watching anime
ani-cli -H
### ani-cli Script
# watch anime
ani-cli <query>
# download anime
ani-cli -d <download_directory>
# resume watching anime
ani-cli -H
# list searched anime
ani-cli -l
# play a playlist :soon:
ani-cli -p
Multiple episodes can be viewed/downloaded by giving the episode range like so
Choose episode [1-13]: 1 6
Choose episode [1-13]: 1 - 6
This would open/download episodes 1 2 3 4 5 6
## Dependencies
* grep
* curl
* sed
* mpv
* ffmpeg
- grep
- curl
- sed
- mpv
- skip-intro.lua (installed in setup.sh)
- ffmpeg
- rofi
- meh.rasi (installed in setup.sh)
- sqlite3

38
ani-cli
View File

@ -1,5 +1,15 @@
#!/usr/bin/env bash
# Set config directory if not already set
if [[ -z "$XDG_CONFIG_HOME" ]]; then
XDG_CONFIG_HOME="$HOME/.config"
fi
CFG_DIR="$XDG_CONFIG_HOME/ani-cli"
CFG_FILE="meh.rasi"
HISTORY_DB="$XDG_CONFIG_HOME/ani-cli/history.sqlite3"
# dependencies: grep sed curl video_player
# video_player ( needs to be able to play urls )
player_fn="mpv"
@ -7,15 +17,7 @@ player_fn="mpv"
prog="ani-cli"
logfile="${XDG_CACHE_HOME:-$HOME/.cache}/ani-hsts"
# Set config directory
if [[ -z "$XDG_CONFIG_HOME" ]]; then
XDG_CONFIG_HOME="$HOME/.config"
fi
config_dir="$XDG_CONFIG_HOME/ani-cli"
history_db="$XDG_CONFIG_HOME/ani-cli/history.sqlite3"
# sql=$(sqlite3 -noheader "$history_db")
# sql=$(sqlite3 -noheader "$HISTORY_DB")
c_red="\033[1;31m"
c_green="\033[1;32m"
@ -117,7 +119,7 @@ check_anime_name() {
}
run_stmt() {
printf "%s\n" "$1" | sqlite3 -noheader "$history_db"
printf "%s\n" "$1" | sqlite3 -noheader "$HISTORY_DB"
}
check_db() {
@ -195,13 +197,13 @@ get_search_query() {
stmt="SELECT DISTINCT anime_name \
FROM search_history \
ORDER BY search_date DESC;"
# hist=$(echo "$stmt" | sqlite3 -noheader "$history_db")
# hist=$(echo "$stmt" | sqlite3 -noheader "$HISTORY_DB")
hist=$(run_stmt "$stmt")
if [ -z "$*" ]; then
query=$(printf "%s\n" "${hist[@]}" |
rofi -dmenu -l 12 -p "Search Anime:" \
-config "$config_dir"/meh.rasi)
-config "$CFG_DIR/${CFG_FILE}")
# printf "Search Anime: "
# read -r query
else
@ -261,7 +263,7 @@ anime_selection() {
# get the anime from indexed list
user_input=$(printf "${menu[@]}" |
rofi -dmenu -config "$config_dir"/meh.rasi \
rofi -dmenu -config "$CFG_DIR/${CFG_FILE}" \
-a "$searched" \
-l 12 -i -p "Enter number:")
[ "$?" -ne 0 ] && return 1
@ -336,7 +338,7 @@ episode_selection() {
-a "$watch_history" \
-p "Select Episode [1, $last_ep_number]:" \
-mesg "$msg" \
-config "$config_dir"/meh.rasi
-config "$CFG_DIR/${CFG_FILE}"
)
ep_choice_start=$(printf '%s\n' "${choice}" | awk '{print $1}')
ep_choice_end=$(printf '%s\n' "${choice}" | awk '{print $NF}')
@ -366,14 +368,14 @@ open_episode() {
FROM watch_history \
WHERE anime_name = '$anime_id' \
ORDER BY episode_number ASC;"
# hist=$(echo "$stmt" | sqlite3 "$history_db" | awk '{ if ( NR > 2 ) { print } }')
# hist=$(echo "$stmt" | sqlite3 "$HISTORY_DB" | awk '{ if ( NR > 2 ) { print } }')
hist=$(run_stmt "$stmt")
if [[ "$VERBOSE" -eq 1 ]]; then
echo "HISTORY: ${hist[*]}"
fi
episode=$(printf "%s\n" "${hist[@]}" |
rofi -dmenu -l 12 -p "Choose Episode:" \
-config "$config_dir"/meh.rasi)
-config "$CFG_DIR/${CFG_FILE}")
printf "$c_reset"
fi
@ -473,7 +475,7 @@ if [[ "$list_history" -eq 1 ]]; then
ORDER BY search_date DESC"
hist=$(run_stmt "$stmt")
printf "%s\n" "${hist[@]}" |
rofi -config "$config_dir"/meh.rasi \
rofi -config "$CFG_DIR/${CFG_FILE}" \
-dmenu -l 12 -i -p "Search History"
exit 0
fi
@ -490,7 +492,7 @@ case $scrape in
history)
# search_results=$(sed -n -E 's/\t[0-9]*//p' "$logfile")
stmt="SELECT DISTINCT anime_name FROM watch_history ORDER BY watch_date DESC"
search_results=$(printf "%s\n" "$stmt" | sqlite3 -noheader "$history_db")
search_results=$(printf "%s\n" "$stmt" | sqlite3 -noheader "$HISTORY_DB")
[ -z "$search_results" ] && die "History is empty"
anime_selection "${search_results[@]}"
stmt="SELECT episode_number FROM watch_history ORDER BY watch_date DESC LIMIT 1"

View File

@ -5,14 +5,15 @@
CMD=/usr/local/bin/ani-cli
DEFAULT="$HOME/Videos/sauce/"
CFG_DIR="$XDG_CONFIG_HOME/ani-cli"
CFG_FILE="meh.rasi"
echo "CONFIG DIR: $CFG_DIR"
# echo "CONFIG DIR: $CFG_DIR"
# not a wrapper around the ani-cli-rofi
options="1. Stream|2. Download|3. Continue|4. Quit"
choice=$(echo "${options[@]}" | rofi -dmenu -sep '|' -config "$CFG_DIR/meh.rasi" -l 4 -i -p "Enter choice:")
choice=$(echo "${options[@]}" | rofi -dmenu -sep '|' -config "$CFG_DIR/$CFG_FILE" -l 4 -i -p "Enter choice:")
[ "$choice" == "4. Quit" ] && (
echo 'Quitting...'
@ -25,7 +26,7 @@ if [[ "$selection" == "1." ]]; then
echo "STREAMING..."
$CMD
elif [[ "$selection" == "2." ]]; then
dl_dir=$(rofi -dmenu -config "$CFG_DIR/meh.rasi" \
dl_dir=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
-l 1 -p "Enter downlaod dir:")
# if dl_dir is none set to current directory
[ "$dl_dir" == "" ] && dl_dir="$DEFAULT"

View File

@ -36,15 +36,15 @@ fi
# Move theme files and skip-intro script to correct locations
log "Moving theme files..."
cp themes/meh.rasi "$DIR"/
cp themes/arc_dark_transparent_colors.rasi "$DIR"/
cp themes/* "$DIR"/
log "Theme files moved..."
log "Creating mpv/scripts/ directory if it doesn't exist..."
mkdir -p "$MPV_DIR/scripts/"
log "Created mpv scripts directory..."
log "Moving skip-intro.lua into mpv scripts directory..."
cp skip-intro.lua "$MPV_DIR/scripts/skip-intro.lua"
cp scripts/* "$MPV_DIR/scripts/"
# cp skip-intro.lua "$MPV_DIR/scripts/skip-intro.lua"
log "Moved skip-intro.lua into scripts directory..."
log "Setup Complete...."

View File

@ -1,34 +0,0 @@
/*******************************************************
* ROFI Arch Dark Transparent colors for EndeavourOS
* Maintainer: joekamprad <joekamprad@endeavouros.com>
*******************************************************/
* {
selected-normal-foreground: rgba ( 255, 147, 5, 100 % );
foreground: rgba ( 196, 203, 212, 100 % );
normal-foreground: @foreground;
alternate-normal-background: rgba ( 45, 48, 59, 1 % );
red: rgba ( 220, 50, 47, 100 % );
selected-urgent-foreground: rgba ( 249, 249, 249, 100 % );
blue: rgba ( 38, 139, 210, 100 % );
urgent-foreground: rgba ( 204, 102, 102, 100 % );
alternate-urgent-background: rgba ( 75, 81, 96, 90 % );
active-foreground: rgba ( 101, 172, 255, 100 % );
lightbg: rgba ( 238, 232, 213, 100 % );
selected-active-foreground: rgba ( 249, 249, 249, 100 % );
alternate-active-background: rgba ( 45, 48, 59, 88 % );
background: rgba ( 45, 48, 59, 88 % );
alternate-normal-foreground: @foreground;
normal-background: rgba ( 45, 48, 59, 1 % );
lightfg: rgba ( 88, 104, 117, 100 % );
selected-normal-background: rgba ( 24, 26, 32, 100 % );
border-color: rgba ( 124, 131, 137, 100 % );
spacing: 2;
separatorcolor: rgba ( 45, 48, 59, 1 % );
urgent-background: rgba ( 45, 48, 59, 15 % );
selected-urgent-background: rgba ( 165, 66, 66, 100 % );
alternate-urgent-foreground: @urgent-foreground;
background-color: rgba ( 0, 0, 0, 0 % );
alternate-active-foreground: @active-foreground;
active-background: rgba ( 29, 31, 33, 17 % );
selected-active-background: rgba ( 26, 28, 35, 100 % );
}

View File

@ -1,53 +1,91 @@
/*******************************************************
* ROFI configs i3 Apps menu for EndeavourOS
* Maintainer: joekamprad <joekamprad@endeavouros.com>
*******************************************************/
configuration {
font: "mononoki Nerd Font 14";
show-icons: true;
font: "Open Sans 15";
display-drun: "Dmenu";
scroll-method: 0;
disable-history: false;
sidebar-mode: true;
}
@import "~/.config/ani-cli/arc_dark_transparent_colors.rasi"
* {
selected-normal-foreground: rgba ( 255, 147, 5, 100 % );
foreground: rgba ( 196, 203, 212, 100 % );
normal-foreground: @foreground;
alternate-normal-background: rgba ( 45, 48, 59, 1 % );
red: rgba ( 220, 50, 47, 100 % );
selected-urgent-foreground: rgba ( 249, 249, 249, 100 % );
blue: rgba ( 38, 139, 210, 100 % );
urgent-foreground: rgba ( 204, 102, 102, 100 % );
alternate-urgent-background: rgba ( 75, 81, 96, 90 % );
active-foreground: rgba ( 101, 172, 255, 100 % );
lightbg: rgba ( 238, 232, 213, 100 % );
selected-active-foreground: rgba ( 249, 249, 249, 100 % );
alternate-active-background: rgba ( 45, 48, 59, 88 % );
background: rgba ( 45, 48, 59, 88 % );
alternate-normal-foreground: @foreground;
normal-background: rgba ( 45, 48, 59, 1 % );
lightfg: rgba ( 88, 104, 117, 100 % );
selected-normal-background: rgba ( 24, 26, 32, 100 % );
border-color: rgba ( 124, 131, 137, 100 % );
spacing: 2;
separatorcolor: rgba ( 45, 48, 59, 1 % );
urgent-background: rgba ( 45, 48, 59, 15 % );
selected-urgent-background: rgba ( 165, 66, 66, 100 % );
alternate-urgent-foreground: @urgent-foreground;
background-color: rgba ( 0, 0, 0, 0 % );
alternate-active-foreground: @active-foreground;
active-background: rgba ( 29, 31, 33, 17 % );
selected-active-background: rgba ( 26, 28, 35, 100 % );
black: #1d1d1d;
blackwidget: #262626;
}
window {
background-color: @background;
border: 0;
padding: 25;
width: 69%;
border: 0;
anchor: north;
location: north;
y-offset: 25%;
padding: 25;
width: 69%;
}
listview {
lines: 12;
columns: 2;
}
mainbox {
border: 0;
padding: 15;
padding: 12;
}
message {
border: 2px 0px 0px ;
border-color: @separatorcolor;
padding: 1px ;
text-color: @active-foreground;
padding: 6px 10px;
}
textbox {
text-color: @foreground;
background-color: @blackwidget;
}
listview {
dynamic: true;
fixed-height: 0;
border: 8px 0px 0px ;
border-color: @separatorcolor;
spacing: 10px ;
scrollbar: false;
padding: 2px 0px 0px ;
padding: 2px 0px 0px 0px;
margin: 0px 0px 1px 0px;
}
element {
border: 2px;
border-color: #d19a66;
padding: 8px;
padding: 2px 15px;
}
element-text {
background-color: inherit;
@ -122,19 +160,24 @@ case-indicator {
text-color: @normal-foreground;
}
entry {
padding: 6px 10px;
spacing: 0;
text-color: @normal-foreground;
}
prompt {
spacing: 0;
text-color: #51afef;
padding: 5px 0px;
}
inputbar {
children: [ prompt,textbox-prompt-colon,entry,case-indicator ];
children: [ prompt,textbox-prompt-colon,entry,case-indicator ];
padding: 15px 0px;
}
textbox-prompt-colon {
expand: false;
str: ":";
margin: 0px 0.3em 0em 0em ;
text-color: #51afef;
padding: 5px 0px;
}