Skip to content

Commit

Permalink
Refactor: Use corsFetch for all schemes
Browse files Browse the repository at this point in the history
Currently corsFetch is very stable and does not need to be used differently from pyfetch depending on whether the license server values the Origin header.
Nested await is no longer necessary and the code is more concise.
It is expected to be less confusing for debugging and for people creating new schemes.
  • Loading branch information
FoxRefire committed Jul 30, 2024
1 parent 7ec8ad8 commit 5c56da8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 26 deletions.
7 changes: 2 additions & 5 deletions python/schemes/DRMToday.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
res = await (await pyfetch(licUrl,
method="POST",
headers=licHeaders,
body=challenge
)).json()
res = await corsFetch(licUrl, "POST", licHeaders, challenge, "json")

licence = res['license']

7 changes: 2 additions & 5 deletions python/schemes/GlobalTV.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
payload = loadBody("json")
challengeArr = list(challenge)
payload['license_request_data']=challengeArr
licence = await (await pyfetch(licUrl,
method="POST",
headers=licHeaders,
body=json.dumps(payload)
)).bytes()

licence = await corsFetch(licUrl, "POST", licHeaders, payload, "blob")
7 changes: 2 additions & 5 deletions python/schemes/NosTV.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
b64challenge = base64.b64encode(challenge).decode()
res = await (await pyfetch(licUrl,
method="POST",
headers=licHeaders,
body=json.dumps({"challenge": b64challenge})
)).json()
res = await corsFetch(licUrl, "POST", licHeaders, {"challenge": b64challenge}, "json")

licence = res["license"][0]
9 changes: 3 additions & 6 deletions python/schemes/Polsat.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
payload = loadBody("json")
challengeB64 = base64.b64encode(challenge).decode()
payload['params']['object'] = challengeB64
licence = await (await pyfetch(licUrl,
method="POST",
headers=licHeaders,
body=json.dumps(payload)
)).json()
licence = licence['result']['object']['license']
res = await corsFetch(licUrl, "POST", licHeaders, payload, "json")

licence = res['result']['object']['license']
7 changes: 2 additions & 5 deletions python/schemes/thePlatform.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
payload = loadBody("json")
b64challenge = base64.b64encode(challenge).decode()
payload["getWidevineLicense"]["widevineChallenge"]=b64challenge
res = await (await pyfetch(licUrl,
method="POST",
headers=licHeaders,
body=json.dumps(payload)
)).json()
res = await corsFetch(licUrl, "POST", licHeaders, payload, "json")

licence = res["getWidevineLicenseResponse"]["license"]

0 comments on commit 5c56da8

Please sign in to comment.