diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..2c8d52c --- /dev/null +++ b/install.sh @@ -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 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index b6d8bb8..0000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -requests -pycryptodome -ecpy -construct -click \ No newline at end of file diff --git a/vinetrimmer/devices/reprovision.bat b/vinetrimmer/devices/reprovision.bat new file mode 100644 index 0000000..f93aa66 --- /dev/null +++ b/vinetrimmer/devices/reprovision.bat @@ -0,0 +1 @@ +pyplayready reprovision-device hisense_smarttv_he55a7000euwts_sl3000.prd \ No newline at end of file diff --git a/vinetrimmer/services/amazon.py b/vinetrimmer/services/amazon.py index dcfe9c3..09e1686 100644 --- a/vinetrimmer/services/amazon.py +++ b/vinetrimmer/services/amazon.py @@ -1161,35 +1161,6 @@ class Amazon(BaseService): return bearer["access_token"] 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 cookies = { @@ -1203,59 +1174,65 @@ class Amazon(BaseService): 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': '*/*' } - data = { - 'di.os.name': 'iOS', - 'app_version': '2.2.223830.0', - 'domain': '.' + 'api.amazon.com', + data2 = { + **device, + 'domain': '.' + self.endpoints["token"].split("/")[-3], 'source_token': refresh_token, 'requested_token_type': 'auth_cookies', '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 - response = requests.post(url=self.endpoints["token"], headers=headers, cookies=cookies, data=data).json() + # 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=data2) + cookies = {} + if response.status_code == 200: # 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']}]") + raw_cookies = response.json()['response']['tokens']['cookies']['.amazon.com'] + for cookie in raw_cookies: + 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. - cookies = {} - for cookie in raw_cookies: - cookies[cookie['Name']] = cookie['Value'] - + headers = { 'Content-Type': 'application/json; charset=utf-8', 'Accept-Encoding': 'gzip, deflate, br', 'Connection': 'keep-alive', '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', + 'x-amzn-identity-auth-domain': self.endpoints["token"].split("/")[-3], + 'x-amzn-requestid': str(uuid4()).replace('-', '') } - json_data = { **device, 'requested_token_type': 'access_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 + # 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. - response = requests.post(url=self.endpoints["token"], headers=headers, cookies=cookies, json=json_data).json() + + response = requests.post(url=self.endpoints["token"], headers=headers, json=json_data, cookies=cookies) + response_json = response.json() - if "error" in response: - self.cache_path.unlink(missing_ok=True) # Remove the cached device as its tokens have expired + 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( - 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) - if response["token_type"] != "bearer": + self.log.debug(response_json) + if response_json["token_type"] != "bearer": raise self.log.exit("Unexpected returned refreshed token type") return response