#!/bin/bash # # gdead - Stream shows from archive.org # Copyright © 2021-2022 Keith Irwin (www.ki9.us) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # Vars UA="gdead/curl/bash;https://gitea.gf4.pw/ki9/gdead" # 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;; -g|--gui) GUI='true'; shift;; *) SHOW_DATE="$SHOW_DATE $1"; shift;; esac done # 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-2022 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" # Metadata search URL 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" # Metadata search 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.org" exit 4 fi if [ "$res" == "null" ]; then echo "No shows found." exit 5 fi # Stream it... stream="https://archive.org/download/$res/${res}_vbr.m3u" if [ "${GUI}" == "true" ]; then vlc --http-user-agent "$UA" --qt-system-tray "$stream" else nvlc --play-and-exit --http-user-agent "$UA" "$stream" fi