Mythus commited on
Commit
3f14202
·
verified ·
1 Parent(s): c3fc6b7

Delete cool.py

Browse files
Files changed (1) hide show
  1. cool.py +0 -145
cool.py DELETED
@@ -1,145 +0,0 @@
1
- import requests
2
- import json
3
- from info import get_info_tmdb,is_movie
4
- from convert import get_TMDb_id_from_IMDb_id
5
- from loadenv import load_env
6
- _,MYSTERIUS_KEY = load_env()
7
- def get_links(slug,season,episode,ismovie):
8
- try:
9
- headers = {
10
- "x-api-key": MYSTERIUS_KEY
11
- }
12
- response = requests.get("https://mammamia-urlo-ulala12431.hf.space/api/cookie", headers=headers)
13
- Auths = response.json()
14
- Bearer = Auths.get('cookie')
15
- ap_session = Auths.get('auth')
16
-
17
- cookies = {'ap_session': ap_session}
18
-
19
- headers = {
20
- 'accept': 'application/json, text/plain, */*',
21
- 'accept-language': 'it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7',
22
- 'authorization': f'Bearer {Bearer}',
23
- 'referer': f'https://altadefinizione-originale.com/play/{slug}',
24
- 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 OPR/111.0.0.0',
25
- 'x-requested-with': 'XMLHttpRequest',
26
- }
27
- if ismovie == 1:
28
-
29
- response = requests.get(f'https://altadefinizione-originale.com/api/post/urls/stream/{slug}',cookies=cookies,headers=headers)
30
- elif ismovie == 0:
31
- print("HERE SEASON",season)
32
- print("HERE EPISODE",episode)
33
- request_url =f'https://altadefinizione-originale.com/api/post/urls/stream/{slug}/{season}/{episode}'
34
- print(request_url)
35
- response = requests.get(request_url,cookies=cookies,headers=headers)
36
- try:
37
- video_data = response.json() # Assuming this is the JSON response containing video streams
38
-
39
- if 'streams' not in video_data:
40
- print("Invalid JSON format: 'streams' key not found or incorrect structure")
41
- return None
42
-
43
- streams = video_data['streams']
44
-
45
- resolutions = {}
46
-
47
- for stream in streams:
48
- resolution_name = stream['resolution']['name'].lower() # Convert resolution name to lowercase
49
- url = stream['url']
50
-
51
- # Remove everything after '.mp4' in the URL
52
- mp4_index = url.find('.mp4')
53
- if mp4_index != -1:
54
- url = url[:mp4_index + 4] # +4 to include '.mp4' in the substring
55
-
56
- resolutions[resolution_name] = url
57
-
58
- return resolutions
59
-
60
- except KeyError as e:
61
- print(f"KeyError: {e}")
62
- return None
63
- except json.JSONDecodeError as e:
64
- print(f"JSONDecodeError: {e}")
65
- return None
66
-
67
- except requests.RequestException as e:
68
- print(f"Request error: {e}")
69
- return None
70
-
71
-
72
- # Example usage: Fetch video links
73
-
74
-
75
- # Print the dictionary
76
-
77
-
78
-
79
-
80
-
81
- def search_imdb(showname,tmdba):
82
- tmdba = str(tmdba)
83
- query = f'https://altadefinizione-originale.com/api/search?search={showname}&page=1'
84
- response = requests.get(query)
85
- if response.status_code == 200:
86
- data = response.json()
87
- if 'data' in data:
88
- for item in data['data']:
89
- if item.get('tmdb_id') == tmdba:
90
- slug = item.get('slug')
91
- print(slug)
92
- return slug
93
-
94
-
95
-
96
- def parse_links(resolution_links):
97
- results = {}
98
- if resolution_links:
99
- print("Video links:")
100
- for resolution, link in resolution_links.items():
101
- if "cdn.altadefinizione-originale.com" in link:
102
- link = link.replace("cdn.altadefinizione-originale.com","protectlinknt.b-cdn.net")
103
- print(f"{resolution}: {link}")
104
- results[resolution] = link
105
- return results
106
- else:
107
- print("Failed to fetch video links")
108
-
109
-
110
- def cool(imdb):
111
- try:
112
- type = "Cool"
113
- general = is_movie(imdb)
114
- ismovie = general[0]
115
- imdb_id = general[1]
116
- if ismovie == 0 :
117
- season = int(general[2])
118
- episode = int(general[3])
119
-
120
- if "tt" in imdb:
121
- #Get showname
122
- tmdba = get_TMDb_id_from_IMDb_id(imdb_id)
123
- else:
124
- tmdba = imdb_id.replace("tmdb:","")
125
-
126
- showname = get_info_tmdb(tmdba,ismovie,type)
127
-
128
-
129
- slug = search_imdb(showname,tmdba)
130
- print(ismovie)
131
- if ismovie == 1:
132
- season = None
133
- episode = None
134
- resolution_links = get_links(slug,episode,season,ismovie)
135
- results = parse_links(resolution_links)
136
- return results
137
- elif ismovie == 0:
138
- season = season -1
139
- episode = episode - 1
140
- resolution_links = get_links(slug,season,episode,ismovie)
141
- results = parse_links(resolution_links)
142
- return results
143
- except Exception as e:
144
- print("Cool Error")
145
- return None