mirror of
https://github.com/adef17286-sudo/KIJK_dl.git
synced 2025-10-13 17:18:10 +00:00
74 lines
2.9 KiB
Python
74 lines
2.9 KiB
Python
|
import requests
|
||
|
import re
|
||
|
import sys
|
||
|
|
||
|
def fetch_video_info(guid):
|
||
|
url = f"https://api.prd.video.talpa.network/graphql?query=query+GetVideoQuery%28%24guid%3A%5BString%5D%29%7Bprograms%28guid%3A%24guid%29%7Bitems%7Bguid+type+metadata+availableRegion+...Media+...Tracks+...Sources%7D%7D%7Dfragment+Media+on+Program%7Bmedia%7Btype+availableDate+availabilityState+airedDateTime+expirationDate%7D%7Dfragment+Tracks+on+Program%7Btracks%7Bfile+kind+label%7D%7Dfragment+Sources+on+Program%7Bsources%7Btype+file+drm%7D%7D&variables=%7B%22guid%22%3A%22{guid}%22%7D"
|
||
|
|
||
|
headers = {
|
||
|
"accept": "*/*",
|
||
|
"accept-language": "nl-NL,nl;q=0.9,en-US;q=0.8,en;q=0.7",
|
||
|
"content-type": "application/json",
|
||
|
"priority": "u=1, i",
|
||
|
"sec-ch-ua": "\"Google Chrome\";v=\"141\", \"Not?A_Brand\";v=\"8\", \"Chromium\";v=\"141\"",
|
||
|
"sec-ch-ua-mobile": "?0",
|
||
|
"sec-ch-ua-platform": "\"Windows\"",
|
||
|
"sec-fetch-dest": "empty",
|
||
|
"sec-fetch-mode": "cors",
|
||
|
"sec-fetch-site": "cross-site",
|
||
|
}
|
||
|
|
||
|
response = requests.get(url, headers=headers)
|
||
|
|
||
|
if response.status_code == 200:
|
||
|
json_response = response.json()
|
||
|
|
||
|
dash_link = None
|
||
|
widevine_license_server = None
|
||
|
|
||
|
items = json_response.get('data', {}).get('programs', {}).get('items', [])
|
||
|
|
||
|
for item in items:
|
||
|
for source in item.get('sources', []):
|
||
|
if source['type'] == 'dash' and 'drm' in source and 'widevine' in source['drm']:
|
||
|
dash_link = source['file']
|
||
|
widevine_license_server = source['drm']['widevine']['url']
|
||
|
break # Exit loop once we find the first match
|
||
|
|
||
|
return {
|
||
|
"dash_link": dash_link,
|
||
|
"widevine_license_server": widevine_license_server
|
||
|
}
|
||
|
else:
|
||
|
return {"error": f"Request failed with status code {response.status_code}"}
|
||
|
|
||
|
def extract_guid(url):
|
||
|
# Check if the URL starts with the required base URL
|
||
|
if not url.startswith("https://www.kijk.nl/programmas/"):
|
||
|
return None
|
||
|
|
||
|
# Regex to extract GUID (the segment before the last slash)
|
||
|
match = re.match(r'https://www\.kijk\.nl/programmas/[^/]+/([^/?]+)', url)
|
||
|
if match:
|
||
|
return match.group(1)
|
||
|
return None
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
if len(sys.argv) != 2:
|
||
|
print("Usage: python script.py {url}")
|
||
|
sys.exit(1)
|
||
|
|
||
|
user_url = sys.argv[1]
|
||
|
guid = extract_guid(user_url)
|
||
|
|
||
|
if guid:
|
||
|
video_info = fetch_video_info(guid)
|
||
|
|
||
|
if 'error' not in video_info:
|
||
|
print(f"DASH Link: {video_info['dash_link']}")
|
||
|
print(f"Widevine License Server: {video_info['widevine_license_server']}")
|
||
|
else:
|
||
|
print(video_info['error'])
|
||
|
else:
|
||
|
print("Invalid URL. Please ensure it starts with 'https://www.kijk.nl/programmas/' and contains a GUID.")
|