mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-10-28 04:44:11 -07:00
modify setup to locally set $XDG_CONFIG_HOME env var if it is not set
This commit is contained in:
parent
2c0921842e
commit
404beb96c0
127
ani-cli
127
ani-cli
@ -9,11 +9,10 @@ logfile="${XDG_CACHE_HOME:-$HOME/.cache}/ani-hsts"
|
|||||||
|
|
||||||
# Set config directory
|
# Set config directory
|
||||||
if [[ -z "$XDG_CONFIG_HOME" ]]; then
|
if [[ -z "$XDG_CONFIG_HOME" ]]; then
|
||||||
config_dir="$HOME/.config/ani-cli"
|
XDG_CONFIG_HOME="$HOME/.config"
|
||||||
else
|
|
||||||
config_dir="$XDG_CONFIG_HOME/ani-cli"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
config_dir="$XDG_CONFIG_HOME/ani-cli"
|
||||||
history_db="$XDG_CONFIG_HOME/ani-cli/history.sqlite3"
|
history_db="$XDG_CONFIG_HOME/ani-cli/history.sqlite3"
|
||||||
|
|
||||||
# sql=$(sqlite3 -noheader "$history_db")
|
# sql=$(sqlite3 -noheader "$history_db")
|
||||||
@ -386,17 +385,17 @@ open_episode() {
|
|||||||
video_url=$(get_links "$dpage_url")
|
video_url=$(get_links "$dpage_url")
|
||||||
|
|
||||||
case $video_url in
|
case $video_url in
|
||||||
*streamtape*)
|
*streamtape*)
|
||||||
# If direct download not available then scrape streamtape.com
|
# If direct download not available then scrape streamtape.com
|
||||||
BROWSER=${BROWSER:-firefox}
|
BROWSER=${BROWSER:-firefox}
|
||||||
printf "scraping streamtape.com\n"
|
printf "scraping streamtape.com\n"
|
||||||
video_url=$(curl -s "$video_url" | sed -n -E '
|
video_url=$(curl -s "$video_url" | sed -n -E '
|
||||||
/^<script>document/{
|
/^<script>document/{
|
||||||
s/^[^"]*"([^"]*)" \+ '\''([^'\'']*).*/https:\1\2\&dl=1/p
|
s/^[^"]*"([^"]*)" \+ '\''([^'\'']*).*/https:\1\2\&dl=1/p
|
||||||
q
|
q
|
||||||
}
|
}
|
||||||
')
|
')
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ $is_download -eq 0 ]; then
|
if [ $is_download -eq 0 ]; then
|
||||||
@ -442,24 +441,24 @@ scrape=query
|
|||||||
download_dir="."
|
download_dir="."
|
||||||
while getopts 'hd:Hl' OPT; do
|
while getopts 'hd:Hl' OPT; do
|
||||||
case $OPT in
|
case $OPT in
|
||||||
h)
|
h)
|
||||||
help_text
|
help_text
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
d)
|
d)
|
||||||
is_download=1
|
is_download=1
|
||||||
download_dir="$OPTARG"
|
download_dir="$OPTARG"
|
||||||
|
|
||||||
if [ "$VERBOSE" -eq 1 ]; then
|
if [ "$VERBOSE" -eq 1 ]; then
|
||||||
echo "DOWNLOAD DIR: $download_dir"
|
echo "DOWNLOAD DIR: $download_dir"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
H)
|
H)
|
||||||
scrape=history
|
scrape=history
|
||||||
;;
|
;;
|
||||||
l)
|
l)
|
||||||
list_history=1
|
list_history=1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $((OPTIND - 1))
|
shift $((OPTIND - 1))
|
||||||
@ -480,26 +479,26 @@ if [[ "$list_history" -eq 1 ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
case $scrape in
|
case $scrape in
|
||||||
query)
|
query)
|
||||||
|
|
||||||
get_search_query "$*"
|
get_search_query "$*"
|
||||||
search_results=$(search_anime "$query")
|
search_results=$(search_anime "$query")
|
||||||
[ -z "$search_results" ] && die "No search results found"
|
[ -z "$search_results" ] && die "No search results found"
|
||||||
anime_selection "$search_results"
|
anime_selection "$search_results"
|
||||||
episode_selection
|
episode_selection
|
||||||
;;
|
;;
|
||||||
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"
|
||||||
run_stmt "$stmt"
|
run_stmt "$stmt"
|
||||||
ep_choice_start=$?
|
ep_choice_start=$?
|
||||||
echo "EPISODE: $ep_choice_start"
|
echo "EPISODE: $ep_choice_start"
|
||||||
# ep_choice_start=$(sed -n -E "s/${selection_id}\t//p" "$logfile")
|
# ep_choice_start=$(sed -n -E "s/${selection_id}\t//p" "$logfile")
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
{ # checking input
|
{ # checking input
|
||||||
@ -538,29 +537,29 @@ while :; do
|
|||||||
# choice=$(printf '%s\n' "$choice" | awk '{print $1}')
|
# choice=$(printf '%s\n' "$choice" | awk '{print $1}')
|
||||||
printf "$c_reset"
|
printf "$c_reset"
|
||||||
case $choice in
|
case $choice in
|
||||||
n)
|
n)
|
||||||
episode=$((episode + 1))
|
episode=$((episode + 1))
|
||||||
;;
|
;;
|
||||||
p)
|
p)
|
||||||
episode=$((episode - 1))
|
episode=$((episode - 1))
|
||||||
;;
|
;;
|
||||||
|
|
||||||
s)
|
s)
|
||||||
printf "${c_blue}Choose episode $c_cyan[1-%d]$c_reset:$c_green " $last_ep_number
|
printf "${c_blue}Choose episode $c_cyan[1-%d]$c_reset:$c_green " $last_ep_number
|
||||||
read episode
|
read episode
|
||||||
printf "$c_reset"
|
printf "$c_reset"
|
||||||
[ "$episode" -eq "$episode" ] 2>/dev/null || die "Invalid number entered"
|
[ "$episode" -eq "$episode" ] 2>/dev/null || die "Invalid number entered"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
r) ;;
|
r) ;;
|
||||||
|
|
||||||
q)
|
q)
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
die "invalid choice"
|
die "invalid choice"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
open_episode "$selection_id" "$episode" "$download_dir"
|
open_episode "$selection_id" "$episode" "$download_dir"
|
||||||
done
|
done
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
[ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME="$HOME/.config"
|
||||||
|
|
||||||
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"
|
||||||
|
|
||||||
|
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 '|' \
|
choice=$(echo "${options[@]}" | rofi -dmenu -sep '|' -config "$CFG_DIR/meh.rasi" -l 4 -i -p "Enter choice:")
|
||||||
-config "$CFG_DIR/meh.rasi" -l 4 -i -p "Enter choice:")
|
|
||||||
|
|
||||||
[ "$choice" == "4. Quit" ] && (
|
[ "$choice" == "4. Quit" ] && (
|
||||||
echo 'Quitting...'
|
echo 'Quitting...'
|
||||||
|
15
setup.sh
15
setup.sh
@ -8,22 +8,17 @@ log() {
|
|||||||
printf "%s\n" "$1"
|
printf "%s\n" "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
# DIR="$HOME/.ani-cli/"
|
|
||||||
DB="history.sqlite3"
|
DB="history.sqlite3"
|
||||||
|
|
||||||
|
# Set the XDG_CONFIG_HOME locally if not set
|
||||||
if [[ -z "$XDG_CONFIG_HOME" ]]; then
|
if [[ -z "$XDG_CONFIG_HOME" ]]; then
|
||||||
DIR="$HOME/.config/ani-cli"
|
XDG_CONFIG_HOME="$HOME/.config"
|
||||||
MPV_DIR="$HOME/.config/mpv"
|
|
||||||
else
|
|
||||||
DIR="$XDG_CONFIG_HOME/ani-cli"
|
|
||||||
MPV_DIR="$XDG_CONFIG_HOME/mpv"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "%s\n" "INSTALL DIR: $DIR"
|
DIR="$XDG_CONFIG_HOME/ani-cli"
|
||||||
|
MPV_DIR="$XDG_CONFIG_HOME/mpv"
|
||||||
|
|
||||||
# log "Deleting old directory..."
|
printf "%s\n" "INSTALL DIR: $DIR"
|
||||||
# rm -rf "$DIR"
|
|
||||||
# log "Directory deleted..."
|
|
||||||
|
|
||||||
if [[ ! -d "$DIR" ]]; then
|
if [[ ! -d "$DIR" ]]; then
|
||||||
log "Creating directory $DIR"
|
log "Creating directory $DIR"
|
||||||
|
Loading…
Reference in New Issue
Block a user