mirror of
https://github.com/thorsten-gehrig/alexa-remote-control.git
synced 2025-11-10 18:52:41 +01:00
Changed Speak and Automation with spaces
Due to a limitation in whitespace handling of cURL POST data automation sequences are now cached in a file and then POSTed.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
# Amazon Alexa Remote Control (PLAIN shell)
|
||||
# alex(at)loetzimmer.de
|
||||
#
|
||||
# 2019-01-22: v0.11 (for updates see http://blog.loetzimmer.de/2017/10/amazon-alexa-hort-auf-die-shell-echo.html)
|
||||
# 2019-02-03: v0.11a (for updates see http://blog.loetzimmer.de/2017/10/amazon-alexa-hort-auf-die-shell-echo.html)
|
||||
#
|
||||
###
|
||||
#
|
||||
@@ -17,7 +17,7 @@
|
||||
SET_EMAIL='amazon_account@email.address'
|
||||
SET_PASSWORD='Very_Secret_Amazon_Account_Password'
|
||||
|
||||
SET_LANGUAGE="de-DE"
|
||||
SET_LANGUAGE="de,en-US;q=0.7,en;q=0.3"
|
||||
#SET_LANGUAGE="en-US"
|
||||
|
||||
SET_AMAZON='amazon.de'
|
||||
@@ -38,7 +38,7 @@ SET_OPTS='--compressed --http1.1'
|
||||
|
||||
# browser identity
|
||||
SET_BROWSER='Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:1.0) bash-script/1.0'
|
||||
#SET_BROWSER='Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0'
|
||||
#SET_BROWSER='Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0'
|
||||
|
||||
# tmp path
|
||||
SET_TMP="/tmp"
|
||||
@@ -279,7 +279,7 @@ case "$COMMAND" in
|
||||
;;
|
||||
speak:*)
|
||||
SEQUENCECMD='Alexa.Speak'
|
||||
TTS=$(echo ${COMMAND##*:} | sed -r 's/[^-a-zA-Z0-9_,?! ]//g' | sed 's/ /_/g')
|
||||
TTS=$(echo ${COMMAND##*:} | sed -r 's/[^-a-zA-Z0-9_,?! ]//g')
|
||||
TTS=",\\\"textToSpeak\\\":\\\"${TTS}\\\""
|
||||
;;
|
||||
weather)
|
||||
@@ -505,10 +505,16 @@ if [ -n "${SEQUENCECMD}" ]
|
||||
echo "Sequence command: ${SEQUENCECMD}"
|
||||
COMMAND="{\"behaviorId\":\"PREVIEW\",\"sequenceJson\":\"{\\\"@type\\\":\\\"com.amazon.alexa.behaviors.model.Sequence\\\",\\\"startNode\\\":{\\\"@type\\\":\\\"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode\\\",\\\"type\\\":\\\"${SEQUENCECMD}\\\",\\\"operationPayload\\\":{\\\"deviceType\\\":\\\"${DEVICETYPE}\\\",\\\"deviceSerialNumber\\\":\\\"${DEVICESERIALNUMBER}\\\",\\\"locale\\\":\\\"${LANGUAGE}\\\",\\\"customerId\\\":\\\"${MEDIAOWNERCUSTOMERID}\\\"${TTS}}}}\",\"status\":\"ENABLED\"}"
|
||||
|
||||
# Due to some weird shell-escape-behavior the command has t be written to a file before POSTing it
|
||||
echo $COMMAND > "${TMP}/.alexa.cmd"
|
||||
|
||||
${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 -d ${COMMAND}\
|
||||
-H "csrf: $(awk "\$0 ~/.${AMAZON}.*csrf[ \\s\\t]+/ {print \$7}" ${COOKIE})" -X POST -d @"${TMP}/.alexa.cmd"\
|
||||
"https://${ALEXA}/api/behaviors/preview"
|
||||
|
||||
rm -f "${TMP}/.alexa.cmd"
|
||||
|
||||
else
|
||||
${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}"\
|
||||
|
||||
Reference in New Issue
Block a user