#1 added -r and -a flags and some date ranging
parent
331d8bf812
commit
21cb48a5e1
28
README.md
28
README.md
|
@ -13,10 +13,34 @@ ln -s /usr/local/src/gdead/gdead /usr/local/bin/gdead
|
|||
|
||||
## Usage
|
||||
|
||||
Takes year, month, and day as arguments and plays the top-rated soundboard on [archive.org](https://archive.org/details/GratefulDead). All three args are required.
|
||||
```
|
||||
gdead [-r|--rand|--random] [-a|--aud|--audience] [year [month [day]]]
|
||||
```
|
||||
|
||||
Takes `year`, `month`, and `day` as arguments and plays the top-rated soundboard on [archive.org](https://archive.org/details/GratefulDead). Providing no unnamed parameters searches the entire vault.
|
||||
|
||||
**NOTE**: *The date parsing is still pretty primitive so don't be an edge case: use 4-digit years and 2-digit months/days. *
|
||||
|
||||
### Audience recordings
|
||||
|
||||
By default, `gdead` only returns soundboards and matrices. To use audience-recordings too, use the `-a` flag
|
||||
|
||||
### Random
|
||||
|
||||
To sort by random instead of rating, use the `-r` flag.
|
||||
|
||||
## Examples
|
||||
|
||||
Play the top-rated version of Woodstock Festival, including audience-tapes:
|
||||
|
||||
```sh
|
||||
gdead 1969 08 16
|
||||
gdead -a 1969 08 16
|
||||
```
|
||||
|
||||
Play a random show from '72:
|
||||
|
||||
```sh
|
||||
gdead -r 1972
|
||||
```
|
||||
|
||||
## License
|
||||
|
|
64
gdead
64
gdead
|
@ -21,26 +21,50 @@
|
|||
UA="gdead/curl/bash;https://gitea.gf4.pw/ki9/gdead"
|
||||
START="$(date +%s)" # unix timestamp
|
||||
|
||||
# Args
|
||||
YYYY=$1
|
||||
MM=$2
|
||||
DD=$3
|
||||
# Parse params
|
||||
SHOW_DATE=""
|
||||
SORT="sort%5B%5D=num_favorites+asc&sort%5B%5D=avg_rating+asc&sort%5B%5D=num_reviews+asc"
|
||||
SBD="+AND+subject%3A%28soundboard%29"
|
||||
while (( "$#" )); do
|
||||
case "$1" in
|
||||
-a|--aud|--audience)
|
||||
SBD=""; shift;;
|
||||
-r|--rand|--random)
|
||||
SORT="sort%5B%5D=random+asc"; shift;;
|
||||
*)
|
||||
SHOW_DATE="$SHOW_DATE $1"; shift;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Initial output
|
||||
# Parse show date
|
||||
YYYY="$(echo $SHOW_DATE | awk '{print $1}')"
|
||||
MM="$(echo $SHOW_DATE | awk '{print $2}')"
|
||||
DD="$(echo $SHOW_DATE | awk '{print $3}')"
|
||||
YYYY1="1900"; YYYY2="2020"
|
||||
MM1="01"; MM2="12"
|
||||
DD1="01"; DD2="31"
|
||||
if [ "$YYYY" != "" ]; then
|
||||
YYYY1="$YYYY"; YYYY2="$YYYY"
|
||||
if [ "$MM" != "" ]; then
|
||||
MM1="$MM"; MM2="$MM"
|
||||
if ["$DD" != "" ]; then
|
||||
DD1="$DD"; DD2="$DD"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Print license
|
||||
echo " gdead Copyright © 2021 Keith Irwin (www.ki9.us)"
|
||||
echo " This program comes with ABSOLUTELY NO WARRANTY; for details"
|
||||
echo " see the LICENSE.md that came with it"
|
||||
echo " This is free software, and you are welcome to redistribute it"
|
||||
echo " under certain conditions"
|
||||
echo
|
||||
|
||||
# Metadata search URL
|
||||
URL="https://archive.org/advancedsearch.php?q=collection%3A%28GratefulDead%29+\
|
||||
AND+subject%3A%28soundboard%29+\
|
||||
AND+date%3A%5B$YYYY-$MM-$DD+TO+$YYYY-$MM-$DD%5D\
|
||||
&fl%5B%5D=avg_rating&fl%5B%5D=downloads&fl%5B%5D=identifier&fl%5B%5D=source&fl%5B%5D=title\
|
||||
&sort%5B%5D=num_favorites+asc&sort%5B%5D=avg_rating+asc&sort%5B%5D=num_reviews+asc\
|
||||
&rows=10&page=1&output=json&callback=c&save=yes#raw"
|
||||
URL="https://archive.org/advancedsearch.php?q=collection%3A%28GratefulDead%29$SBD\
|
||||
+AND+date%3A%5B$YYYY1-$MM1-$DD1+TO+$YYYY1-$MM2-$DD2%5D\
|
||||
&fl%5B%5D=identifier\
|
||||
&$SORT&rows=1&page=1&output=json&callback=c&save=yes#raw"
|
||||
|
||||
# Prepare pipe
|
||||
PIPE="/tmp/$START.gdead.fifo"
|
||||
|
@ -48,12 +72,18 @@ rm "$PIPE" 2>/dev/null
|
|||
mkfifo "$PIPE"
|
||||
|
||||
# Metadata search
|
||||
first_res=$(curl --user-agent "$UA" --silent "$URL" | cut -c 3- | head -c-2 | jq -r '.response.docs[0].identifier')
|
||||
res=$(curl --user-agent "$UA" --silent "$URL" | cut -c 3- | head -c-2 | jq -r '.response.docs[0].identifier')
|
||||
if [ "$res" == "" ]; then
|
||||
echo "FATAL: Could not connect to archive.ort"
|
||||
exit 4
|
||||
fi
|
||||
|
||||
# Remove pipe
|
||||
rm $PIPE 2>/dev/null
|
||||
|
||||
# Stream it
|
||||
#vlc --http-user-agent "$UA" --qt-system-tray --qt-start-minimized \
|
||||
nvlc --http-user-agent "$UA" \
|
||||
"https://archive.org/download/$first_res/${first_res}_vbr.m3u"
|
||||
# Stream it...
|
||||
stream="https://archive.org/download/$res/${res}_vbr.m3u"
|
||||
# ...with VLC in the system tray
|
||||
#vlc --http-user-agent "$UA" --qt-system-tray --qt-start-minimized "$stream"
|
||||
# ...with ncurses VLC
|
||||
nvlc --http-user-agent "$UA" "$stream"
|
||||
|
|
Loading…
Reference in New Issue