Made oathtool configurable

This commit is contained in:
Alex 2019-07-08 21:12:09 +02:00
parent 7a69d45dad
commit ca7a12deb1
3 changed files with 22 additions and 15 deletions

View File

@ -13,6 +13,7 @@ ALEXA - the URL you would use for the Alexa Web App
CURL - location of your cURL binary CURL - location of your cURL binary
OPTS - any cURL options you require OPTS - any cURL options you require
TMP - location of the temp dir TMP - location of the temp dir
OATHTOOL - command line for oathtool MFA
``` ```
You will very likely want to set the language to: You will very likely want to set the language to:
``` ```
@ -51,9 +52,3 @@ alexa-remote-control [-d <device>|ALL] -e <pause|play|next|prev|fwd|rwd|shuffle|
There's also a "plain" version, which lacks some functionality (-i, -p, -P, -S and no radio station names and no routines) but doesn't require 'jq' for JSON processing. There's also a "plain" version, which lacks some functionality (-i, -p, -P, -S and no radio station names and no routines) but doesn't require 'jq' for JSON processing.
http://blog.loetzimmer.de/2017/10/amazon-alexa-hort-auf-die-shell-echo.html http://blog.loetzimmer.de/2017/10/amazon-alexa-hort-auf-die-shell-echo.html

18
alexa_remote_control.sh Normal file → Executable file
View File

@ -24,15 +24,15 @@
# 2018-01-28: v0.8c added configurable browser string # 2018-01-28: v0.8c added configurable browser string
# 2018-02-17: v0.8d no need to write the cookie file on every "check_status" # 2018-02-17: v0.8d no need to write the cookie file on every "check_status"
# 2018-02-27: v0.8e added "lastalexa" option for HA-Bridge to send its command to a specific device # 2018-02-27: v0.8e added "lastalexa" option for HA-Bridge to send its command to a specific device
# (Markus Wennesheimer: https://wennez.wordpress.com/light-on-with-alexa-for-each-room/) # (Markus Wennesheimer: https://wennez.wordpress.com/light-on-with-alexa-for-each-room/)
# 2018-02-27: v0.9 unsuccessful logins will now give a short info how to debug the login # 2018-02-27: v0.9 unsuccessful logins will now give a short info how to debug the login
# 2018-03-09: v0.9a workaround for login problem, force curl to use http1.1 # 2018-03-09: v0.9a workaround for login problem, force curl to use http1.1
# 2018-05-17: v0.9b update browser string and accept language # 2018-05-17: v0.9b update browser string and accept language
# 2018-05-23: v0.9c update accept language (again) # 2018-05-23: v0.9c update accept language (again)
# 2018-06-12: v0.10 introducing TTS and more # 2018-06-12: v0.10 introducing TTS and more
# (thanks to Michael Geramb and his openHAB2 Amazon Echo Control binding) # (thanks to Michael Geramb and his openHAB2 Amazon Echo Control binding)
# https://github.com/openhab/openhab2-addons/tree/master/addons/binding/org.openhab.binding.amazonechocontrol # https://github.com/openhab/openhab2-addons/tree/master/addons/binding/org.openhab.binding.amazonechocontrol
# (thanks to Ralf Otto for implementing this feature in this script) # (thanks to Ralf Otto for implementing this feature in this script)
# 2018-06-13: v0.10a added album play of imported library # 2018-06-13: v0.10a added album play of imported library
# 2018-06-18: v0.10b added Alexa routine execution # 2018-06-18: v0.10b added Alexa routine execution
# 2019-01-22: v0.11 added repeat command, added environment variable parsing # 2019-01-22: v0.11 added repeat command, added environment variable parsing
@ -56,7 +56,9 @@
SET_EMAIL='amazon_account@email.address' SET_EMAIL='amazon_account@email.address'
SET_PASSWORD='Very_Secret_Amazon_Account_Password' SET_PASSWORD='Very_Secret_Amazon_Account_Password'
#SET_MFA_SECRET='1234 5678 9ABC DEFG HIJK LMNO PQRS TUVW XYZ0 1234 5678 9ABC DEFG' SET_MFA_SECRET=''
# something like:
# 1234 5678 9ABC DEFG HIJK LMNO PQRS TUVW XYZ0 1234 5678 9ABC DEFG
SET_LANGUAGE='de,en-US;q=0.7,en;q=0.3' SET_LANGUAGE='de,en-US;q=0.7,en;q=0.3'
#SET_LANGUAGE='en-US' #SET_LANGUAGE='en-US'
@ -83,6 +85,9 @@ SET_OPTS='--compressed --http1.1'
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:1.0) bash-script/1.0'
#SET_BROWSER='Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0' #SET_BROWSER='Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0'
# oathtool command line
SET_OATHTOOL='oathtool --base32 --totp'
# tmp path # tmp path
SET_TMP="/tmp" SET_TMP="/tmp"
@ -102,6 +107,7 @@ CURL=${CURL:-$SET_CURL}
OPTS=${OPTS:-$SET_OPTS} OPTS=${OPTS:-$SET_OPTS}
TTS_LOCALE=${TTS_LOCALE:-$SET_TTS_LOCALE} TTS_LOCALE=${TTS_LOCALE:-$SET_TTS_LOCALE}
TMP=${TMP:-$SET_TMP} TMP=${TMP:-$SET_TMP}
OATHTOOL=${OOATHTOOL:-$SET_OATHTOOL}
COOKIE="${TMP}/.alexa.cookie" COOKIE="${TMP}/.alexa.cookie"
DEVLIST="${TMP}/.alexa.devicelist.json" DEVLIST="${TMP}/.alexa.devicelist.json"
@ -407,8 +413,8 @@ ${CURL} ${OPTS} -s -c ${COOKIE} -b ${COOKIE} -A "${BROWSER}" -H "Accept-Language
# #
# add OTP if using MFA # add OTP if using MFA
# #
if [ ! -z "${MFA_SECRET}" ] ; then if [ -n "${MFA_SECRET}" ] ; then
OTP=$(oathtool --base32 --totp "${MFA_SECRET}") OTP=$(${OATHTOOL} "${MFA_SECRET}")
PASSWORD="${PASSWORD}${OTP}" PASSWORD="${PASSWORD}${OTP}"
fi fi

12
alexa_remote_control_plain.sh Normal file → Executable file
View File

@ -15,7 +15,9 @@
SET_EMAIL='amazon_account@email.address' SET_EMAIL='amazon_account@email.address'
SET_PASSWORD='Very_Secret_Amazon_Account_Password' SET_PASSWORD='Very_Secret_Amazon_Account_Password'
#SET_MFA_SECRET='1234 5678 9ABC DEFG HIJK LMNO PQRS TUVW XYZ0 1234 5678 9ABC DEFG' SET_MFA_SECRET=''
# something like:
# 1234 5678 9ABC DEFG HIJK LMNO PQRS TUVW XYZ0 1234 5678 9ABC DEFG
SET_LANGUAGE='de,en-US;q=0.7,en;q=0.3' SET_LANGUAGE='de,en-US;q=0.7,en;q=0.3'
#SET_LANGUAGE='en-US' #SET_LANGUAGE='en-US'
@ -42,6 +44,9 @@ SET_OPTS='--compressed --http1.1'
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:1.0) bash-script/1.0'
#SET_BROWSER='Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0' #SET_BROWSER='Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0'
# oathtool command line
SET_OATHTOOL='oathtool --base32 --totp'
# tmp path # tmp path
SET_TMP="/tmp" SET_TMP="/tmp"
@ -61,6 +66,7 @@ CURL=${CURL:-$SET_CURL}
OPTS=${OPTS:-$SET_OPTS} OPTS=${OPTS:-$SET_OPTS}
TTS_LOCALE=${TTS_LOCALE:-$SET_TTS_LOCALE} TTS_LOCALE=${TTS_LOCALE:-$SET_TTS_LOCALE}
TMP=${TMP:-$SET_TMP} TMP=${TMP:-$SET_TMP}
OATHTOOL=${OOATHTOOL:-$SET_OATHTOOL}
COOKIE="${TMP}/.alexa.cookie" COOKIE="${TMP}/.alexa.cookie"
DEVLIST="${TMP}/.alexa.devicelist.json" DEVLIST="${TMP}/.alexa.devicelist.json"
@ -347,8 +353,8 @@ ${CURL} ${OPTS} -s -c ${COOKIE} -b ${COOKIE} -A "${BROWSER}" -H "Accept-Language
# #
# add OTP if using MFA # add OTP if using MFA
# #
if [ ! -z "${MFA_SECRET}" ] ; then if [ -n "${MFA_SECRET}" ] ; then
OTP=$(oathtool --base32 --totp "${MFA_SECRET}") OTP=$(${OATHTOOL} "${MFA_SECRET}")
PASSWORD="${PASSWORD}${OTP}" PASSWORD="${PASSWORD}${OTP}"
fi fi