Skip to content

Instantly share code, notes, and snippets.

@asuna
Created September 23, 2023 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asuna/8d828a4a4d5ff006f3f514a6f499aafb to your computer and use it in GitHub Desktop.
Save asuna/8d828a4a4d5ff006f3f514a6f499aafb to your computer and use it in GitHub Desktop.
get wvkeys via getwvkeys.cc
import argparse
import requests
import json
from datetime import datetime
def format_timestamp(timestamp):
if isinstance(timestamp, int):
formatted_time = datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S')
return formatted_time
return str(timestamp)
def main():
parser = argparse.ArgumentParser(description="Send a request to the API with custom headers, pssh, and license_url.")
parser.add_argument("-H", "--header", action="append", help="Add a custom header in the format key:value")
parser.add_argument("-P", "--pssh", help="Add pssh value")
parser.add_argument("-s", "--license_url", help="Add license_url")
args = parser.parse_args()
request_header = "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:106.0) Gecko/20100101 Firefox/106.0"
# API URL and initial headers
api_url = "https://getwvkeys.cc/api"
headers = {
"Content-Type": "application/json",
"X-API-Key": '<YourKey>'
}
# Add custom headers
if args.header:
for request_header in args.header:
key, value = request_header.split(":", 1)
headers[key.strip()] = value.strip()
# Check if pssh and license_url are provided
if not args.pssh or not args.license_url:
print("Both pssh and license_url are required.")
return
payload = {
"license_url": args.license_url,
"pssh": args.pssh,
"headers": request_header,
"proxy": "",
"buildinfo": "",
"cache": "false"
}
# Make the initial API request with handling redirects
response = requests.post(api_url, headers=headers, json=payload)
if response.status_code == 200 or response.status_code == 302:
response_data = response.json()
if "keys" in response_data and isinstance(response_data["keys"], list):
keys = response_data.get("keys", [])
string_keys = []
for key_info in keys:
if isinstance(key_info, dict):
added_at = key_info.get('added_at')
if added_at:
added_at_timestamp = added_at
added_at_formatted = format_timestamp(added_at_timestamp)
print(f" added_at (cached keys): {added_at_formatted}")
print(f" license_url: {key_info.get('license_url')}")
print(f" key: {key_info.get('key')}")
print(f" kid: {response_data.get('kid')}")
elif isinstance(key_info, str):
string_keys.append(key_info)
for key_info in string_keys:
added_at = response_data.get('added_at')
if added_at:
added_at_timestamp = added_at
added_at_formatted = format_timestamp(added_at_timestamp)
print(f" added_at (new keys): {added_at_formatted}")
print(f" license_url: {response_data.get('license_url')}")
if isinstance(key_info, str):
print(f" key: {key_info}")
print(f" kid: {response_data.get('kid')}")
else:
print("Error:", response.status_code)
print(response.text)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment