add support for playing iHeartRadio stations by id

This commit is contained in:
Nolan Gilley 2019-12-06 22:27:35 +00:00
parent 9ab7dadd34
commit 710a4a925d

View File

@ -45,6 +45,7 @@
# (thanks to rich-gepp https://github.com/rich-gepp) # (thanks to rich-gepp https://github.com/rich-gepp)
# 2019-08-05: v0.14 added Volume setting via routine, and $SPEAKVOL # 2019-08-05: v0.14 added Volume setting via routine, and $SPEAKVOL
# 2019-11-18: v0.14a download 200 routines instead of only the first 20 # 2019-11-18: v0.14a download 200 routines instead of only the first 20
# 2019-12-06: v0.15 support iHeartRadio station ids
# #
### ###
# #
@ -131,6 +132,7 @@ UTTERANCE=""
SEQUENCECMD="" SEQUENCECMD=""
SEQUENCEVAL="" SEQUENCEVAL=""
STATIONID="" STATIONID=""
IHEARTID=""
QUEUE="" QUEUE=""
SONG="" SONG=""
ALBUM="" ALBUM=""
@ -148,7 +150,7 @@ LASTALEXA=""
usage() usage()
{ {
echo "$0 [-d <device>|ALL] -e <pause|play|next|prev|fwd|rwd|shuffle|repeat|vol:<0-100>> |" echo "$0 [-d <device>|ALL] -e <pause|play|next|prev|fwd|rwd|shuffle|repeat|vol:<0-100>> |"
echo " -b [list|<\"AA:BB:CC:DD:EE:FF\">] | -q | -r <\"station name\"|stationid> |" echo " -b [list|<\"AA:BB:CC:DD:EE:FF\">] | -q | -r <\"station name\"|stationid> | -c <iHeart stationid> |"
echo " -s <trackID|'Artist' 'Album'> | -t <ASIN> | -u <seedID> | -v <queueID> | -w <playlistId> |" echo " -s <trackID|'Artist' 'Album'> | -t <ASIN> | -u <seedID> | -v <queueID> | -w <playlistId> |"
echo " -i | -p | -P | -S | -a | -m <multiroom_device> [device_1 .. device_X] | -lastalexa | -l | -h" echo " -i | -p | -P | -S | -a | -m <multiroom_device> [device_1 .. device_X] | -lastalexa | -l | -h"
echo echo
@ -158,6 +160,7 @@ usage()
echo " -q : query queue" echo " -q : query queue"
echo " -n : query notifications" echo " -n : query notifications"
echo " -r : play tunein radio" echo " -r : play tunein radio"
echo " -c : play iHeartRadio station"
echo " -s : play library track/library album" echo " -s : play library track/library album"
echo " -t : play Prime playlist" echo " -t : play Prime playlist"
echo " -u : play Prime station" echo " -u : play Prime station"
@ -233,6 +236,15 @@ while [ "$#" -gt 0 ] ; do
fi fi
fi fi
;; ;;
-c)
if [ "${2#-}" != "${2}" -o -z "$2" ] ; then
echo "ERROR: missing argument for ${1}"
usage
exit 1
fi
IHEARTID=$2
shift
;;
-s) -s)
if [ "${2#-}" != "${2}" -o -z "$2" ] ; then if [ "${2#-}" != "${2}" -o -z "$2" ] ; then
echo "ERROR: missing argument for ${1}" echo "ERROR: missing argument for ${1}"
@ -629,6 +641,17 @@ ${CURL} ${OPTS} -s -b ${COOKIE} -A "${BROWSER}" -H "DNT: 1" -H "Connection: keep
"https://${ALEXA}/api/tunein/queue-and-play?deviceSerialNumber=${DEVICESERIALNUMBER}&deviceType=${DEVICETYPE}&guideId=${STATIONID}&contentType=station&callSign=&mediaOwnerCustomerId=${MEDIAOWNERCUSTOMERID}" "https://${ALEXA}/api/tunein/queue-and-play?deviceSerialNumber=${DEVICESERIALNUMBER}&deviceType=${DEVICETYPE}&guideId=${STATIONID}&contentType=station&callSign=&mediaOwnerCustomerId=${MEDIAOWNERCUSTOMERID}"
} }
#
# play iHeart radio station
#
play_iheart()
{
${CURL} ${OPTS} -s -b ${COOKIE} -A "${BROWSER}" -H "DNT: 1" -H "Connection: keep-alive" -L\
-H "Content-Type: application/json; charset=UTF-8" -H "Referer: https://alexa.${AMAZON}/spa/index.html" -H "Origin: https://alexa.${AMAZON}"\
-H "csrf: $(awk "\$0 ~/.${AMAZON}.*csrf[ \\s\\t]+/ {print \$7}" ${COOKIE})" -X POST\
"https://${ALEXA}/api/iheartradio/queue-and-play-live-station" -d '{"deviceSerialNumber": "'${DEVICESERIALNUMBER}'", "deviceType": "'${DEVICETYPE}'", "stationId": "'${IHEARTID}'", "mediaOwnerCustomerId": "'${MEDIAOWNERCUSTOMERID}'"}'
}
# #
# play library track # play library track
# #
@ -878,7 +901,7 @@ rm -f ${COOKIE}
rm -f ${TMP}/.alexa.*.list rm -f ${TMP}/.alexa.*.list
} }
if [ -z "$LASTALEXA" -a -z "$BLUETOOTH" -a -z "$LEMUR" -a -z "$PLIST" -a -z "$HIST" -a -z "$SEEDID" -a -z "$ASIN" -a -z "$PRIME" -a -z "$TYPE" -a -z "$QUEUE" -a -z "$NOTIFICATIONS" -a -z "$LIST" -a -z "$COMMAND" -a -z "$STATIONID" -a -z "$SONG" -a -n "$LOGOFF" ] ; then if [ -z "$LASTALEXA" -a -z "$BLUETOOTH" -a -z "$LEMUR" -a -z "$PLIST" -a -z "$HIST" -a -z "$SEEDID" -a -z "$ASIN" -a -z "$PRIME" -a -z "$TYPE" -a -z "$QUEUE" -a -z "$NOTIFICATIONS" -a -z "$LIST" -a -z "$COMMAND" -a -z "$STATIONID" -a -z "$IHEARTID" -a -z "$SONG" -a -n "$LOGOFF" ] ; then
echo "only logout option present, logging off ..." echo "only logout option present, logging off ..."
log_off log_off
exit 0 exit 0
@ -1014,6 +1037,10 @@ elif [ -n "$STATIONID" ] ; then
set_var set_var
echo "playing stationID:${STATIONID} on dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} mediaownerid:${MEDIAOWNERCUSTOMERID}" echo "playing stationID:${STATIONID} on dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} mediaownerid:${MEDIAOWNERCUSTOMERID}"
play_radio play_radio
elif [ -n "$IHEARTID" ] ; then
set_var
echo "playing stationID:${STATIONID} on dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} mediaownerid:${MEDIAOWNERCUSTOMERID}"
play_iheart
elif [ -n "$SONG" ] ; then elif [ -n "$SONG" ] ; then
set_var set_var
echo "playing library track:${SONG} on dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} mediaownerid:${MEDIAOWNERCUSTOMERID}" echo "playing library track:${SONG} on dev:${DEVICE} type:${DEVICETYPE} serial:${DEVICESERIALNUMBER} mediaownerid:${MEDIAOWNERCUSTOMERID}"