diff --git a/.gitignore b/.gitignore index ab3e8ce..d71db58 100644 --- a/.gitignore +++ b/.gitignore @@ -162,3 +162,6 @@ cython_debug/ # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ +# Clips +Clips/* +!Clips/placeholder diff --git a/Clips/placeholder b/Clips/placeholder new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a41ed54 Binary files /dev/null and b/requirements.txt differ diff --git a/run.py b/run.py new file mode 100644 index 0000000..9eb6231 --- /dev/null +++ b/run.py @@ -0,0 +1,39 @@ +import glob +import json +from base64 import b64decode as b64d + +import colorama +import requests +from xmltodict import parse as xparse + +licenses = [_ for _ in glob.glob(r'.\Clips\[!placeholder]*')] +uri = 'https://displaycatalog.mp.microsoft.com/v7.0/products?bigIds={}&market=US&languages=en-US,neutral&MS-CV=DGU1mcuYo0WMMp+F.1' + + +def get_game_name(pid: str) -> str: + req = requests.get(uri.format(pid)) + + if req.status_code == 200: + j = req.json() + return j['Products'][0]['LocalizedProperties'][0]['ProductTitle'] + else: + return 'Unknown Title' + + +def main(): + for lic in licenses: + clip = lic[lic.rfind('\\') + 1:] + data = json.loads(json.dumps(xparse(open(lic, 'r').read()), indent=4)) + signed_lic = json.loads(json.dumps(xparse(b64d(data['License']['SignedLicense']).decode()))) + custom_policy = json.loads(b64d(signed_lic['SignedLicense']['SVLicense']['CustomPolicies'].encode()).decode()) + content_id = custom_policy['packages'][0]['packageIdentifier'] + product_id = custom_policy['packages'][0]['productId'] + game = get_game_name(product_id) + + print(f'\033[91m{clip}\033[97m is for product: \033[91m{game}\033[97m ContentID: \033[91m{content_id}\033[99m') + + +if __name__ == '__main__': + colorama.init() + + main()