-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathexample.py
52 lines (39 loc) · 3 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""
This file is part of the wv_cdm_api project (https://github.com/GetWVKeys/wv_cdm_api)
Copyright (C) 2022 Notaghost, Puyodead1 and GetWVKeys contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
# this is a simple file for testing the api functions correctly
import base64
import json
import requests
LICENSE_URL = "https://cwip-shaka-proxy.appspot.com/no_auth"
PSSH = "AAAAp3Bzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAIcSEFF0U4YtQlb9i61PWEIgBNcSEPCTfpp3yFXwptQ4ZMXZ82USEE1LDKJawVjwucGYPFF+4rUSEJAqBRprNlaurBkm/A9dkjISECZHD0KW1F0Eqbq7RC4WmAAaDXdpZGV2aW5lX3Rlc3QiFnNoYWthX2NlYzViZmY1ZGM0MGRkYzlI49yVmwY="
API_URL = "http://localhost:8080/api"
CERT = "CAUSxQUKvwIIAxIQKHA0VMAI9jYYredEPbbEyBiL5/mQBSKOAjCCAQoCggEBALUhErjQXQI/zF2V4sJRwcZJtBd82NK+7zVbsGdD3mYePSq8MYK3mUbVX9wI3+lUB4FemmJ0syKix/XgZ7tfCsB6idRa6pSyUW8HW2bvgR0NJuG5priU8rmFeWKqFxxPZmMNPkxgJxiJf14e+baq9a1Nuip+FBdt8TSh0xhbWiGKwFpMQfCB7/+Ao6BAxQsJu8dA7tzY8U1nWpGYD5LKfdxkagatrVEB90oOSYzAHwBTK6wheFC9kF6QkjZWt9/v70JIZ2fzPvYoPU9CVKtyWJOQvuVYCPHWaAgNRdiTwryi901goMDQoJk87wFgRwMzTDY4E5SGvJ2vJP1noH+a2UMCAwEAAToSc3RhZ2luZy5nb29nbGUuY29tEoADmD4wNSZ19AunFfwkm9rl1KxySaJmZSHkNlVzlSlyH/iA4KrvxeJ7yYDa6tq/P8OG0ISgLIJTeEjMdT/0l7ARp9qXeIoA4qprhM19ccB6SOv2FgLMpaPzIDCnKVww2pFbkdwYubyVk7jei7UPDe3BKTi46eA5zd4Y+oLoG7AyYw/pVdhaVmzhVDAL9tTBvRJpZjVrKH1lexjOY9Dv1F/FJp6X6rEctWPlVkOyb/SfEJwhAa/K81uDLyiPDZ1Flg4lnoX7XSTb0s+Cdkxd2b9yfvvpyGH4aTIfat4YkF9Nkvmm2mU224R1hx0WjocLsjA89wxul4TJPS3oRa2CYr5+DU4uSgdZzvgtEJ0lksckKfjAF0K64rPeytvDPD5fS69eFuy3Tq26/LfGcF96njtvOUA4P5xRFtICogySKe6WnCUZcYMDtQ0BMMM1LgawFNg4VA+KDCJ8ABHg9bOOTimO0sswHrRWSWX1XF15dXolCk65yEqz5lOfa2/fVomeopkU"
r = requests.post(API_URL, json={"method": "GetChallenge", "params": {"cert": CERT, "device": "", "init": PSSH, "licensetype": "STREAMING", "raw": False}, "token": "testsecret123"})
if not r.ok:
print(f"Failed to get challenge: [{r.status_code}] {r.text}")
exit(1)
print(json.dumps(r.json(), indent=4))
challenge = r.json()["challenge"]
session_id = r.json()["session_id"]
r2 = requests.post(LICENSE_URL, data=base64.b64decode(challenge))
if not r2.ok:
print(f"Failed to get license: [{r2.status_code}] {r2.text}")
exit(1)
license_b64 = base64.b64encode(r2.content).decode()
print("License: ", license_b64)
r3 = requests.post(API_URL, json={"method": "GetKeys", "params": {"cdmkeyresponse": license_b64, "session_id": session_id}, "token": "testsecret123"})
if not r3.ok:
print(f"Failed to get keys: [{r3.status_code}] {r3.text}")
exit(1)
print(json.dumps(r3.json(), indent=4))