Changes
Possible fix for Amazon refresh token Basic install.sh for Linux Removed unnecessary requirements.txt
This commit is contained in:
parent
1d94ecef7f
commit
88a682d1ef
25
install.sh
Normal file
25
install.sh
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
git clone -b dev --single-branch https://github.com/chu23465/VT-PR
|
||||||
|
cd VT-PR
|
||||||
|
python -m pip install poetry==1.8.5
|
||||||
|
poetry config virtualenvs.in-project true
|
||||||
|
poetry lock --no-update
|
||||||
|
poetry install
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install ffmpeg
|
||||||
|
sudo apt-get install aria2
|
||||||
|
sudo apt install mkvtoolnix
|
||||||
|
ffmpeg --version
|
||||||
|
ffprobe --version
|
||||||
|
ffplay --version
|
||||||
|
aria2c --version
|
||||||
|
mkvmerge --version
|
||||||
|
rm -r ./binaries/
|
||||||
|
mkdir ./binaries/
|
||||||
|
mv -v ./linux_binaries/* ./binaries/
|
||||||
|
cp aria2c ./binaries/
|
||||||
|
cp ffmpeg ./binaries/
|
||||||
|
cp ffprobe ./binaries/
|
||||||
|
cp ffplay ./binaries/
|
||||||
|
cp mkvtoolnix ./binaries/
|
||||||
|
cd ./binaries/
|
||||||
|
find . -type f -print0 | xargs -0 chmod -x
|
@ -1,5 +0,0 @@
|
|||||||
requests
|
|
||||||
pycryptodome
|
|
||||||
ecpy
|
|
||||||
construct
|
|
||||||
click
|
|
1
vinetrimmer/devices/reprovision.bat
Normal file
1
vinetrimmer/devices/reprovision.bat
Normal file
@ -0,0 +1 @@
|
|||||||
|
pyplayready reprovision-device hisense_smarttv_he55a7000euwts_sl3000.prd
|
@ -1161,35 +1161,6 @@ class Amazon(BaseService):
|
|||||||
return bearer["access_token"]
|
return bearer["access_token"]
|
||||||
|
|
||||||
def refresh(self, device: dict, refresh_token: str, access_token: str) -> dict:
|
def refresh(self, device: dict, refresh_token: str, access_token: str) -> dict:
|
||||||
"""
|
|
||||||
json3 = {
|
|
||||||
'app_name': 'ioBroker Alexa2',
|
|
||||||
'app_version': '2.2.556530.0',
|
|
||||||
'di.sdk.version': '6.12.4',
|
|
||||||
'source_token': refresh_token,
|
|
||||||
'package_name': 'com.amazon.echo',
|
|
||||||
'di.hw.version': 'iPhone',
|
|
||||||
'platform': 'iOS',
|
|
||||||
'requested_token_type': 'access_token',
|
|
||||||
'source_token_type': 'refresh_token',
|
|
||||||
'di.os.name': 'iOS',
|
|
||||||
'di.os.version': '16.6',
|
|
||||||
'current_version': '6.12.4'
|
|
||||||
}
|
|
||||||
json4 = {
|
|
||||||
'di.os.name': 'iOS',
|
|
||||||
'app_version': '2.2.223830.0',
|
|
||||||
'domain': '.' + 'api.amazon.com',
|
|
||||||
'source_token': refresh_token,
|
|
||||||
'requested_token_type': 'auth_cookies',
|
|
||||||
'source_token_type': 'refresh_token',
|
|
||||||
'di.hw.version': 'iPhone',
|
|
||||||
'di.sdk.version': '6.10.0',
|
|
||||||
'cookies': {},
|
|
||||||
'app_name': 'Amazon Alexa',
|
|
||||||
'di.os.version': '11.4.1'
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
# https://gitlab.com/keatontaylor/alexapy/-/commit/540b6333d973177bbc98e6ef39b00134f80ef0bb
|
# https://gitlab.com/keatontaylor/alexapy/-/commit/540b6333d973177bbc98e6ef39b00134f80ef0bb
|
||||||
|
|
||||||
cookies = {
|
cookies = {
|
||||||
@ -1203,59 +1174,65 @@ class Amazon(BaseService):
|
|||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
'Accept': '*/*'
|
'Accept': '*/*'
|
||||||
}
|
}
|
||||||
data = {
|
data2 = {
|
||||||
'di.os.name': 'iOS',
|
**device,
|
||||||
'app_version': '2.2.223830.0',
|
'domain': '.' + self.endpoints["token"].split("/")[-3],
|
||||||
'domain': '.' + 'api.amazon.com',
|
|
||||||
'source_token': refresh_token,
|
'source_token': refresh_token,
|
||||||
'requested_token_type': 'auth_cookies',
|
'requested_token_type': 'auth_cookies',
|
||||||
'source_token_type': 'refresh_token',
|
'source_token_type': 'refresh_token',
|
||||||
'di.hw.version': 'iPhone',
|
|
||||||
'di.sdk.version': '6.10.0',
|
|
||||||
'app_name': 'Amazon Alexa',
|
|
||||||
'di.os.version': '11.4.1'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
|
||||||
# using the refresh token get the cookies needed for making calls to alexa.amazon.com
|
# using the refresh token get the cookies needed for making calls to alexa.amazon.com
|
||||||
response = requests.post(url=self.endpoints["token"], headers=headers, cookies=cookies, data=data).json()
|
response = requests.post(url=self.endpoints["token"], headers=headers, cookies=cookies, data=data2)
|
||||||
# Extract the cookies from the response
|
|
||||||
raw_cookies = response['response']['tokens']['cookies']['.amazon.com']
|
|
||||||
except:
|
|
||||||
error = response['response']["error"]
|
|
||||||
raise self.log.exit(f"Error when refreshing cookies: {error['message']} [{error['code']}]")
|
|
||||||
|
|
||||||
# Create a new cookies object to be used with requsts.
|
|
||||||
cookies = {}
|
cookies = {}
|
||||||
|
if response.status_code == 200:
|
||||||
|
# Extract the cookies from the response
|
||||||
|
raw_cookies = response.json()['response']['tokens']['cookies']['.amazon.com']
|
||||||
for cookie in raw_cookies:
|
for cookie in raw_cookies:
|
||||||
cookies[cookie['Name']] = cookie['Value']
|
cookies[cookie['Name']] = cookie['Value']
|
||||||
|
else:
|
||||||
|
error = response.json()['response']["error"]
|
||||||
|
#self.cache_path.unlink(missing_ok=True)
|
||||||
|
self.log.warn(f"Error when refreshing cookies: {error['message']} [{error['code']}]")
|
||||||
|
|
||||||
|
# Create a new cookies object to be used with requsts.
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/json; charset=utf-8',
|
'Content-Type': 'application/json; charset=utf-8',
|
||||||
'Accept-Encoding': 'gzip, deflate, br',
|
'Accept-Encoding': 'gzip, deflate, br',
|
||||||
'Connection': 'keep-alive',
|
'Connection': 'keep-alive',
|
||||||
'Accept': 'application/json; charset=utf-8',
|
'Accept': 'application/json; charset=utf-8',
|
||||||
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 PitanguiBridge/2.2.389238.0-[HARDWARE=iPhone12_3][SOFTWARE=14.3]',
|
'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36",
|
||||||
'Accept-Language': 'en-US,en-US;q=1.0',
|
'Accept-Language': 'en-US,en-US;q=1.0',
|
||||||
|
'x-amzn-identity-auth-domain': self.endpoints["token"].split("/")[-3],
|
||||||
|
'x-amzn-requestid': str(uuid4()).replace('-', '')
|
||||||
}
|
}
|
||||||
|
|
||||||
json_data = {
|
json_data = {
|
||||||
**device,
|
**device,
|
||||||
'requested_token_type': 'access_token',
|
'requested_token_type': 'access_token',
|
||||||
'source_token_type': 'refresh_token',
|
'source_token_type': 'refresh_token',
|
||||||
"source_token": refresh_token,
|
'source_token': str(refresh_token),
|
||||||
|
|
||||||
} # https://github.com/Sandmann79/xbmc/blob/dab17d913ee877d96115e6f799623bca158f3f24/plugin.video.amazon-test/resources/lib/login.py#L593
|
} # https://github.com/Sandmann79/xbmc/blob/dab17d913ee877d96115e6f799623bca158f3f24/plugin.video.amazon-test/resources/lib/login.py#L593
|
||||||
|
|
||||||
|
# Add cookies to session
|
||||||
|
#if cookies != {}:
|
||||||
|
# for k,v in cookies.iteritems():
|
||||||
|
# if not isinstance(v, str):
|
||||||
|
# v = str(v)
|
||||||
|
# self.session.cookies.set(k,v)
|
||||||
# make the call and print the response.
|
# make the call and print the response.
|
||||||
response = requests.post(url=self.endpoints["token"], headers=headers, cookies=cookies, json=json_data).json()
|
|
||||||
|
|
||||||
if "error" in response:
|
response = requests.post(url=self.endpoints["token"], headers=headers, json=json_data, cookies=cookies)
|
||||||
self.cache_path.unlink(missing_ok=True) # Remove the cached device as its tokens have expired
|
response_json = response.json()
|
||||||
|
|
||||||
|
if response.status_code != 200 or "error" in response_json:
|
||||||
|
#self.cache_path.unlink(missing_ok=True) # Remove the cached device as its tokens have expired
|
||||||
raise self.log.exit(
|
raise self.log.exit(
|
||||||
f"Failed to refresh device token: {response['error_description']} [{response['error']}]"
|
f"Failed to refresh device token -> {response_json['error_description']} [{response_json['error']}]"
|
||||||
)
|
)
|
||||||
self.log.debug(response)
|
self.log.debug(response_json)
|
||||||
if response["token_type"] != "bearer":
|
if response_json["token_type"] != "bearer":
|
||||||
raise self.log.exit("Unexpected returned refreshed token type")
|
raise self.log.exit("Unexpected returned refreshed token type")
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
Loading…
x
Reference in New Issue
Block a user