Add episode database to peerflix script
This commit is contained in:
parent
ceadea0989
commit
268e7a0d6e
|
@ -2,7 +2,25 @@
|
|||
|
||||
directory=/tmp/webtorrent
|
||||
player=mpv
|
||||
data_file=$HOME/Documents/IT/peerflix-db.csv
|
||||
|
||||
parse_csv() {
|
||||
show_name=$(echo "$1" | cut -d "=" -f 3 | cut -d "%" -f 1 | tr + " ")
|
||||
episode=$(awk -F ',' -v var="$show_name" '$1 ~ var {print $2}' "$data_file")
|
||||
}
|
||||
|
||||
increment_episode() {
|
||||
next_episode=$((episode + 1))
|
||||
# TODO Make more resilient
|
||||
sed "s/$episode/$next_episode/" -i "$data_file"
|
||||
}
|
||||
|
||||
parse_csv "$1"
|
||||
if [ -z "$episode" ]; then
|
||||
webtorrent download "$1" -s -o "$directory" --"$player"
|
||||
read -rp "File number: " nr
|
||||
webtorrent download "$@" -s "$nr" -o "$directory" --"$player"
|
||||
else
|
||||
increment_episode
|
||||
webtorrent download "$@" -s "$episode" -o "$directory" --"$player"
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue