|
21 | 21 | import logging
|
22 | 22 | import secrets
|
23 | 23 | import time
|
| 24 | +import uuid |
24 | 25 | import xml.etree.ElementTree as ET
|
25 | 26 | from urllib.parse import urlsplit
|
26 | 27 |
|
@@ -390,6 +391,8 @@ def run(self, curl=False):
|
390 | 391 | result = self.library.search(self.pssh)
|
391 | 392 | if result and len(result) > 0:
|
392 | 393 | cached = self.library.search_res_to_dict(self.kid, result)
|
| 394 | + if not curl and self.is_web: |
| 395 | + return render_template("cache.html", results=cached) |
393 | 396 | r = jsonify(cached)
|
394 | 397 | r.headers.add_header("X-Cache", "HIT")
|
395 | 398 | return r, 302
|
@@ -582,9 +585,11 @@ def __init__(
|
582 | 585 | self.downgrade = downgrade
|
583 | 586 | self.is_web = is_web
|
584 | 587 |
|
585 |
| - # if pssh: |
586 |
| - # kids = [x.read_attributes()[0] for x in self.pssh.wrm_headers] |
587 |
| - # self.kid = base64.b64decode(kids[0][0].value).hex() |
| 588 | + if pssh: |
| 589 | + kids = [x.read_attributes()[0] for x in self.pssh.wrm_headers] |
| 590 | + kid = kids[0][0].value |
| 591 | + decoded_kid = base64.b64decode(kid) |
| 592 | + self.kid = str(uuid.UUID(bytes_le=decoded_kid)) |
588 | 593 |
|
589 | 594 | @staticmethod
|
590 | 595 | def post_data(license_url, headers, data, proxy):
|
@@ -649,17 +654,16 @@ def external_license(self, method, params, web=False):
|
649 | 654 | raise Exception("Unknown method")
|
650 | 655 |
|
651 | 656 | def run(self, curl=False):
|
652 |
| - # TODO: |
653 | 657 | # Search for cached keys first
|
654 |
| - # if not self.force: |
655 |
| - # result = self.library.search(kid) |
656 |
| - # if result and len(result) > 0: |
657 |
| - # cached = self.library.search_res_to_dict(kid, result) |
658 |
| - # if not curl: |
659 |
| - # return render_template("cache.html", results=cached) |
660 |
| - # r = jsonify(cached) |
661 |
| - # r.headers.add_header("X-Cache", "HIT") |
662 |
| - # return r, 302 |
| 658 | + if not self.force and self.kid: |
| 659 | + result = self.library.search(self.kid) |
| 660 | + if result and len(result) > 0: |
| 661 | + cached = self.library.search_res_to_dict(self.kid, result) |
| 662 | + if not curl and self.is_web: |
| 663 | + return render_template("cache.html", results=cached) |
| 664 | + r = jsonify(cached) |
| 665 | + r.headers.add_header("X-Cache", "HIT") |
| 666 | + return r, 302 |
663 | 667 |
|
664 | 668 | if self.license_response is None:
|
665 | 669 | # Headers
|
|
0 commit comments