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 # 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). 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 ## Usage
# watch anime ### Wrapper Script `aniwrapper`
ani-cli <query>
# download anime # Launch Menu (Contains same options as below, but in a rofi menu)
ani-cli -d <query> aniwrapper
# resume watching anime ### ani-cli Script
ani-cli -H
# 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 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 This would open/download episodes 1 2 3 4 5 6
## Dependencies ## Dependencies
* grep - grep
* curl - curl
* sed - sed
* mpv - mpv
* ffmpeg - 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 #!/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 # dependencies: grep sed curl video_player
# video_player ( needs to be able to play urls ) # video_player ( needs to be able to play urls )
player_fn="mpv" player_fn="mpv"
@ -7,15 +17,7 @@ player_fn="mpv"
prog="ani-cli" prog="ani-cli"
logfile="${XDG_CACHE_HOME:-$HOME/.cache}/ani-hsts" logfile="${XDG_CACHE_HOME:-$HOME/.cache}/ani-hsts"
# Set config directory # sql=$(sqlite3 -noheader "$HISTORY_DB")
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")
c_red="\033[1;31m" c_red="\033[1;31m"
c_green="\033[1;32m" c_green="\033[1;32m"
@ -117,7 +119,7 @@ check_anime_name() {
} }
run_stmt() { run_stmt() {
printf "%s\n" "$1" | sqlite3 -noheader "$history_db" printf "%s\n" "$1" | sqlite3 -noheader "$HISTORY_DB"
} }
check_db() { check_db() {
@ -195,13 +197,13 @@ get_search_query() {
stmt="SELECT DISTINCT anime_name \ stmt="SELECT DISTINCT anime_name \
FROM search_history \ FROM search_history \
ORDER BY search_date DESC;" ORDER BY search_date DESC;"
# hist=$(echo "$stmt" | sqlite3 -noheader "$history_db") # hist=$(echo "$stmt" | sqlite3 -noheader "$HISTORY_DB")
hist=$(run_stmt "$stmt") hist=$(run_stmt "$stmt")
if [ -z "$*" ]; then if [ -z "$*" ]; then
query=$(printf "%s\n" "${hist[@]}" | query=$(printf "%s\n" "${hist[@]}" |
rofi -dmenu -l 12 -p "Search Anime:" \ rofi -dmenu -l 12 -p "Search Anime:" \
-config "$config_dir"/meh.rasi) -config "$CFG_DIR/${CFG_FILE}")
# printf "Search Anime: " # printf "Search Anime: "
# read -r query # read -r query
else else
@ -261,7 +263,7 @@ anime_selection() {
# get the anime from indexed list # get the anime from indexed list
user_input=$(printf "${menu[@]}" | user_input=$(printf "${menu[@]}" |
rofi -dmenu -config "$config_dir"/meh.rasi \ rofi -dmenu -config "$CFG_DIR/${CFG_FILE}" \
-a "$searched" \ -a "$searched" \
-l 12 -i -p "Enter number:") -l 12 -i -p "Enter number:")
[ "$?" -ne 0 ] && return 1 [ "$?" -ne 0 ] && return 1
@ -336,7 +338,7 @@ episode_selection() {
-a "$watch_history" \ -a "$watch_history" \
-p "Select Episode [1, $last_ep_number]:" \ -p "Select Episode [1, $last_ep_number]:" \
-mesg "$msg" \ -mesg "$msg" \
-config "$config_dir"/meh.rasi -config "$CFG_DIR/${CFG_FILE}"
) )
ep_choice_start=$(printf '%s\n' "${choice}" | awk '{print $1}') ep_choice_start=$(printf '%s\n' "${choice}" | awk '{print $1}')
ep_choice_end=$(printf '%s\n' "${choice}" | awk '{print $NF}') ep_choice_end=$(printf '%s\n' "${choice}" | awk '{print $NF}')
@ -366,14 +368,14 @@ open_episode() {
FROM watch_history \ FROM watch_history \
WHERE anime_name = '$anime_id' \ WHERE anime_name = '$anime_id' \
ORDER BY episode_number ASC;" 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") hist=$(run_stmt "$stmt")
if [[ "$VERBOSE" -eq 1 ]]; then if [[ "$VERBOSE" -eq 1 ]]; then
echo "HISTORY: ${hist[*]}" echo "HISTORY: ${hist[*]}"
fi fi
episode=$(printf "%s\n" "${hist[@]}" | episode=$(printf "%s\n" "${hist[@]}" |
rofi -dmenu -l 12 -p "Choose Episode:" \ rofi -dmenu -l 12 -p "Choose Episode:" \
-config "$config_dir"/meh.rasi) -config "$CFG_DIR/${CFG_FILE}")
printf "$c_reset" printf "$c_reset"
fi fi
@ -473,7 +475,7 @@ if [[ "$list_history" -eq 1 ]]; then
ORDER BY search_date DESC" ORDER BY search_date DESC"
hist=$(run_stmt "$stmt") hist=$(run_stmt "$stmt")
printf "%s\n" "${hist[@]}" | printf "%s\n" "${hist[@]}" |
rofi -config "$config_dir"/meh.rasi \ rofi -config "$CFG_DIR/${CFG_FILE}" \
-dmenu -l 12 -i -p "Search History" -dmenu -l 12 -i -p "Search History"
exit 0 exit 0
fi fi
@ -490,7 +492,7 @@ case $scrape in
history) history)
# search_results=$(sed -n -E 's/\t[0-9]*//p' "$logfile") # search_results=$(sed -n -E 's/\t[0-9]*//p' "$logfile")
stmt="SELECT DISTINCT anime_name FROM watch_history ORDER BY watch_date DESC" 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" [ -z "$search_results" ] && die "History is empty"
anime_selection "${search_results[@]}" anime_selection "${search_results[@]}"
stmt="SELECT episode_number FROM watch_history ORDER BY watch_date DESC LIMIT 1" 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 CMD=/usr/local/bin/ani-cli
DEFAULT="$HOME/Videos/sauce/" DEFAULT="$HOME/Videos/sauce/"
CFG_DIR="$XDG_CONFIG_HOME/ani-cli" 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 # not a wrapper around the ani-cli-rofi
options="1. Stream|2. Download|3. Continue|4. Quit" 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" ] && ( [ "$choice" == "4. Quit" ] && (
echo 'Quitting...' echo 'Quitting...'
@ -25,7 +26,7 @@ if [[ "$selection" == "1." ]]; then
echo "STREAMING..." echo "STREAMING..."
$CMD $CMD
elif [[ "$selection" == "2." ]]; then 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:") -l 1 -p "Enter downlaod dir:")
# if dl_dir is none set to current directory # if dl_dir is none set to current directory
[ "$dl_dir" == "" ] && dl_dir="$DEFAULT" [ "$dl_dir" == "" ] && dl_dir="$DEFAULT"

View File

@ -36,15 +36,15 @@ fi
# Move theme files and skip-intro script to correct locations # Move theme files and skip-intro script to correct locations
log "Moving theme files..." log "Moving theme files..."
cp themes/meh.rasi "$DIR"/ cp themes/* "$DIR"/
cp themes/arc_dark_transparent_colors.rasi "$DIR"/
log "Theme files moved..." log "Theme files moved..."
log "Creating mpv/scripts/ directory if it doesn't exist..." log "Creating mpv/scripts/ directory if it doesn't exist..."
mkdir -p "$MPV_DIR/scripts/" mkdir -p "$MPV_DIR/scripts/"
log "Created mpv scripts directory..." log "Created mpv scripts directory..."
log "Moving skip-intro.lua into 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 "Moved skip-intro.lua into scripts directory..."
log "Setup Complete...." 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 { configuration {
font: "mononoki Nerd Font 14"; font: "Open Sans 15";
show-icons: true;
display-drun: "Dmenu"; display-drun: "Dmenu";
scroll-method: 0; scroll-method: 0;
disable-history: false; disable-history: false;
sidebar-mode: true; 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 { window {
background-color: @background; background-color: @background;
border: 0; border: 0;
padding: 25; anchor: north;
width: 69%; location: north;
y-offset: 25%;
padding: 25;
width: 69%;
} }
listview { listview {
lines: 12; lines: 12;
columns: 2; columns: 2;
} }
mainbox { mainbox {
border: 0; border: 0;
padding: 15; padding: 12;
} }
message { message {
border: 2px 0px 0px ; border: 2px 0px 0px ;
border-color: @separatorcolor; border-color: @separatorcolor;
padding: 1px ; padding: 1px ;
text-color: @active-foreground; text-color: @active-foreground;
padding: 6px 10px;
} }
textbox { textbox {
text-color: @foreground; text-color: @foreground;
background-color: @blackwidget;
} }
listview { listview {
dynamic: true;
fixed-height: 0; fixed-height: 0;
border: 8px 0px 0px ; border: 8px 0px 0px ;
border-color: @separatorcolor; border-color: @separatorcolor;
spacing: 10px ; spacing: 10px ;
scrollbar: false; scrollbar: false;
padding: 2px 0px 0px ; padding: 2px 0px 0px 0px;
margin: 0px 0px 1px 0px;
} }
element { element {
border: 2px; border: 2px;
border-color: #d19a66; border-color: #d19a66;
padding: 8px; padding: 2px 15px;
} }
element-text { element-text {
background-color: inherit; background-color: inherit;
@ -122,19 +160,24 @@ case-indicator {
text-color: @normal-foreground; text-color: @normal-foreground;
} }
entry { entry {
padding: 6px 10px;
spacing: 0; spacing: 0;
text-color: @normal-foreground; text-color: @normal-foreground;
} }
prompt { prompt {
spacing: 0; spacing: 0;
text-color: #51afef; text-color: #51afef;
padding: 5px 0px;
} }
inputbar { inputbar {
children: [ prompt,textbox-prompt-colon,entry,case-indicator ]; children: [ prompt,textbox-prompt-colon,entry,case-indicator ];
padding: 15px 0px;
} }
textbox-prompt-colon { textbox-prompt-colon {
expand: false; expand: false;
str: ":"; str: ":";
margin: 0px 0.3em 0em 0em ; margin: 0px 0.3em 0em 0em ;
text-color: #51afef; text-color: #51afef;
padding: 5px 0px;
} }