From f05854f123ed4a8059bff0024f96edea09975963 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 23 Jan 2019 01:00:37 +0100 Subject: [PATCH] Changed customerId retrieval CustomerId is now retrieved from the logged in user. The customerId in the device list is always from the user registering the device initially --- alexa_remote_control.sh | 9 +++++++-- alexa_remote_control_plain.sh | 26 +++++++++++++++----------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/alexa_remote_control.sh b/alexa_remote_control.sh index 4e81e58..3558557 100644 --- a/alexa_remote_control.sh +++ b/alexa_remote_control.sh @@ -445,7 +445,9 @@ check_status() # bootstrap with GUI-Version writes GUI version to cookie # returns among other the current authentication state # - AUTHSTATUS=$(${CURL} ${OPTS} -s -b ${COOKIE} -A "${BROWSER}" -H "DNT: 1" -H "Connection: keep-alive" -L https://${ALEXA}/api/bootstrap?version=${GUIVERSION} | sed -r 's/^.*"authenticated":([^,]+),.*$/\1/g') + AUTHSTATUS=$(${CURL} ${OPTS} -s -b ${COOKIE} -A "${BROWSER}" -H "DNT: 1" -H "Connection: keep-alive" -L https://${ALEXA}/api/bootstrap?version=${GUIVERSION}) + MEDIAOWNERCUSTOMERID=$(echo $AUTHSTATUS | sed -r 's/^.*"customerId":"([^,]+)",.*$/\1/g') + AUTHSTATUS=$(echo $AUTHSTATUS | sed -r 's/^.*"authenticated":([^,]+),.*$/\1/g') if [ "$AUTHSTATUS" = "true" ] ; then return 1 @@ -470,7 +472,10 @@ set_var() DEVICETYPE=$(jq --arg device "${DEVICE}" -r '.devices[] | select(.accountName == $device) | .deviceType' ${DEVLIST}) DEVICESERIALNUMBER=$(jq --arg device "${DEVICE}" -r '.devices[] | select(.accountName == $device) | .serialNumber' ${DEVLIST}) - MEDIAOWNERCUSTOMERID=$(jq --arg device "${DEVICE}" -r '.devices[] | select(.accountName == $device) | .deviceOwnerCustomerId' ${DEVLIST}) + + # customerId is now retrieved from the logged in user + # the customerId in the device list is always from the user registering the device initially + # MEDIAOWNERCUSTOMERID=$(jq --arg device "${DEVICE}" -r '.devices[] | select(.accountName == $device) | .deviceOwnerCustomerId' ${DEVLIST}) if [ -z "${DEVICESERIALNUMBER}" ] ; then echo "ERROR: unkown device dev:${DEVICE}" diff --git a/alexa_remote_control_plain.sh b/alexa_remote_control_plain.sh index f715aa4..e1e5ac7 100644 --- a/alexa_remote_control_plain.sh +++ b/alexa_remote_control_plain.sh @@ -396,7 +396,9 @@ check_status() # bootstrap with GUI-Version writes GUI version to cookie # returns among other the current authentication state # - AUTHSTATUS=$(${CURL} ${OPTS} -s -b ${COOKIE} -A "${BROWSER}" -H "DNT: 1" -H "Connection: keep-alive" -L https://${ALEXA}/api/bootstrap?version=${GUIVERSION} | sed -r 's/^.*"authenticated":([^,]+),.*$/\1/g') + AUTHSTATUS=$(${CURL} ${OPTS} -s -b ${COOKIE} -A "${BROWSER}" -H "DNT: 1" -H "Connection: keep-alive" -L https://${ALEXA}/api/bootstrap?version=${GUIVERSION}) + MEDIAOWNERCUSTOMERID=$(echo $AUTHSTATUS | sed -r 's/^.*"customerId":"([^,]+)",.*$/\1/g') + AUTHSTATUS=$(echo $AUTHSTATUS | sed -r 's/^.*"authenticated":([^,]+),.*$/\1/g') if [ "$AUTHSTATUS" = "true" ] ; then return 1 @@ -419,8 +421,8 @@ set_var() ATTR="serialNumber" SERIAL=`grep ${ATTR}\| ${DEVTXT} | sed "s/^.*${ATTR}|//" | sed 's/ /_/g'` - ATTR="deviceOwnerCustomerId" - MEDIAID=`grep ${ATTR}\| ${DEVTXT} | sed "s/^.*${ATTR}|//" | sed 's/ /_/g'` +# ATTR="deviceOwnerCustomerId" +# MEDIAID=`grep ${ATTR}\| ${DEVTXT} | sed "s/^.*${ATTR}|//" | sed 's/ /_/g'` ATTR="deviceFamily" FAMILY=`grep ${ATTR}\| ${DEVTXT} | sed "s/^.*${ATTR}|//" | sed 's/ /_/g'` @@ -457,14 +459,16 @@ set_var() done fi - C=0 - for I in $MEDIAID ; do - if [ $C -eq $IDX ] ; then - MEDIAOWNERCUSTOMERID=$I - break - fi - C=$((C+1)) - done +# customerId is now retrieved from the logged in user +# the customerId in the device list is always from the user registering the device initially +# C=0 +# for I in $MEDIAID ; do +# if [ $C -eq $IDX ] ; then +# MEDIAOWNERCUSTOMERID=$I +# break +# fi +# C=$((C+1)) +# done C=0 for I in $TYPE ; do