mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-10-28 04:44:11 -07:00
replaced json with tsv
This commit is contained in:
parent
8d359fef31
commit
22f223a4ec
19
ani-cli
19
ani-cli
@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# dependencies: sed curl jq 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"
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ dep_ch () {
|
|||||||
# Start Up #
|
# Start Up #
|
||||||
############
|
############
|
||||||
|
|
||||||
dep_ch "$player_fn" "curl" "sed" "jq"
|
dep_ch "$player_fn" "curl" "sed" "grep"
|
||||||
|
|
||||||
# option parsing
|
# option parsing
|
||||||
is_download=0
|
is_download=0
|
||||||
@ -125,7 +125,7 @@ shift $((OPTIND - 1))
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# create history file
|
# create history file
|
||||||
[ -f $logfile ] || printf "{}" > $logfile
|
[ -f $logfile ] || printf "" > $logfile
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
## Anime selection ##
|
## Anime selection ##
|
||||||
@ -134,7 +134,7 @@ shift $((OPTIND - 1))
|
|||||||
if [ $resume_watching -eq 0 ]; then
|
if [ $resume_watching -eq 0 ]; then
|
||||||
search_results=$(search_anime "$query")
|
search_results=$(search_anime "$query")
|
||||||
else
|
else
|
||||||
search_results=$(jq -r 'keys[]' $logfile)
|
search_results=$(cut -f1 $logfile)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -z "$search_results" ] && die "No search results found"
|
[ -z "$search_results" ] && die "No search results found"
|
||||||
@ -195,7 +195,7 @@ if [ $resume_watching -eq 0 ]; then
|
|||||||
read ep_choice_start ep_choice_end
|
read ep_choice_start ep_choice_end
|
||||||
printf "$c_reset"
|
printf "$c_reset"
|
||||||
else
|
else
|
||||||
ep_choice_start=$(jq ".\"${selection_id}\"" $logfile)
|
ep_choice_start=$(awk "/${selection_id}/ { print \$2 }" $logfile)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
{ # checking input
|
{ # checking input
|
||||||
@ -236,8 +236,13 @@ open_episode () {
|
|||||||
|
|
||||||
if [ $is_download -eq 0 ]; then
|
if [ $is_download -eq 0 ]; then
|
||||||
# write anime and episode number
|
# write anime and episode number
|
||||||
jq ".\"${selection_id}\" = $((ep+1))" $logfile > "${logfile}.new" \
|
if $(grep -w "${selection_id}" $logfile >/dev/null); then
|
||||||
&& mv "${logfile}.new" $logfile
|
awk -F'\t' "
|
||||||
|
BEGIN {OFS=\"\\t\"}; NR != $choice; NR == $choice { \$2=$((episode+1));print }
|
||||||
|
" $logfile > "${logfile}.new" && mv "${logfile}.new" $logfile
|
||||||
|
else
|
||||||
|
printf "%s\t%d\n" "$selection_id" $((episode+1)) >> $logfile
|
||||||
|
fi
|
||||||
|
|
||||||
setsid -f $player_fn "$video_url" >/dev/null 2>&1
|
setsid -f $player_fn "$video_url" >/dev/null 2>&1
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user