vega-cli 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vega_cli/__init__.py +1 -0
- vega_cli/__main__.py +6 -0
- vega_cli/cli.py +247 -0
- vega_cli/config.py +99 -0
- vega_cli/display.py +138 -0
- vega_cli/html.py +540 -0
- vega_cli/interactive.py +220 -0
- vega_cli/player.py +82 -0
- vega_cli/providers/__init__.py +13 -0
- vega_cli/providers/ani_dream.py +1089 -0
- vega_cli/providers/anikoto.py +820 -0
- vega_cli/providers/animesalt.py +649 -0
- vega_cli/providers/animesub.py +1374 -0
- vega_cli/providers/animeworld.py +504 -0
- vega_cli/providers/auto_embed.py +479 -0
- vega_cli/providers/castle.py +497 -0
- vega_cli/providers/cncverse.py +873 -0
- vega_cli/providers/common/__init__.py +51 -0
- vega_cli/providers/common/aes.py +152 -0
- vega_cli/providers/common/aniskip.py +186 -0
- vega_cli/providers/common/base_url.py +102 -0
- vega_cli/providers/common/cinemeta.py +231 -0
- vega_cli/providers/common/errors.py +25 -0
- vega_cli/providers/common/extractors/__init__.py +23 -0
- vega_cli/providers/common/extractors/abbasy.py +247 -0
- vega_cli/providers/common/extractors/buzzheavier.py +72 -0
- vega_cli/providers/common/extractors/cinejoy.py +33 -0
- vega_cli/providers/common/extractors/gdflix.py +170 -0
- vega_cli/providers/common/extractors/gofile.py +167 -0
- vega_cli/providers/common/extractors/hubcloud.py +277 -0
- vega_cli/providers/common/extractors/movy.py +349 -0
- vega_cli/providers/common/extractors/st111477.py +139 -0
- vega_cli/providers/common/extractors/transferit.py +53 -0
- vega_cli/providers/common/extractors/vegadrive.py +161 -0
- vega_cli/providers/common/extractors/vidstuck.py +379 -0
- vega_cli/providers/common/extractors/zcloud.py +158 -0
- vega_cli/providers/common/extractors/zypter.py +72 -0
- vega_cli/providers/common/headers.py +25 -0
- vega_cli/providers/common/http.py +121 -0
- vega_cli/providers/common/net_mirror.py +1494 -0
- vega_cli/providers/common/theintrodb.py +112 -0
- vega_cli/providers/common/unpack.py +54 -0
- vega_cli/providers/disney_mirror.py +31 -0
- vega_cli/providers/dramacool.py +297 -0
- vega_cli/providers/drive.py +695 -0
- vega_cli/providers/durbin_live.py +354 -0
- vega_cli/providers/eon_movies.py +752 -0
- vega_cli/providers/extraflix.py +701 -0
- vega_cli/providers/four_khdhub.py +307 -0
- vega_cli/providers/goku_hd.py +336 -0
- vega_cli/providers/hdhub4u.py +665 -0
- vega_cli/providers/internet_archive.py +552 -0
- vega_cli/providers/kartoons.py +642 -0
- vega_cli/providers/kartoons2.py +395 -0
- vega_cli/providers/katmovies.py +816 -0
- vega_cli/providers/kick_ass_anime.py +445 -0
- vega_cli/providers/kiss_kh.py +490 -0
- vega_cli/providers/live_tg_tv.py +540 -0
- vega_cli/providers/lux_movies.py +650 -0
- vega_cli/providers/mod.py +676 -0
- vega_cli/providers/movie_box_web.py +921 -0
- vega_cli/providers/movielinkdb.py +734 -0
- vega_cli/providers/movies4u.py +580 -0
- vega_cli/providers/moviezwap.py +199 -0
- vega_cli/providers/mxplayer.py +470 -0
- vega_cli/providers/netflix_mirror.py +32 -0
- vega_cli/providers/one_cinevood.py +596 -0
- vega_cli/providers/prime_mirror.py +31 -0
- vega_cli/providers/rareanimes.py +676 -0
- vega_cli/providers/registry.py +124 -0
- vega_cli/providers/showbox.py +245 -0
- vega_cli/providers/topmovies.py +707 -0
- vega_cli/providers/torrentio.py +398 -0
- vega_cli/providers/uhd.py +483 -0
- vega_cli/providers/vega.py +891 -0
- vega_cli/providers/youtube.py +566 -0
- vega_cli/providers/zeefliz.py +563 -0
- vega_cli/store.py +45 -0
- vega_cli/utils.py +90 -0
- vega_cli-0.1.0.dist-info/METADATA +8 -0
- vega_cli-0.1.0.dist-info/RECORD +84 -0
- vega_cli-0.1.0.dist-info/WHEEL +5 -0
- vega_cli-0.1.0.dist-info/entry_points.txt +2 -0
- vega_cli-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,752 @@
|
|
|
1
|
+
"""Pure-Python Vega EonMovies provider (ported from eonMovies/)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import re
|
|
7
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
8
|
+
from typing import Any
|
|
9
|
+
from urllib.parse import quote, urlencode, urljoin, urlparse
|
|
10
|
+
|
|
11
|
+
from ..html import Node, parse_html
|
|
12
|
+
from ..utils import format_season_title, normalize_url, to_relative_path
|
|
13
|
+
from .common import BaseProvider, get_base_url
|
|
14
|
+
from .common.extractors import hubcloud_extractor
|
|
15
|
+
|
|
16
|
+
_PROVIDER_VALUE = "eonMovies"
|
|
17
|
+
|
|
18
|
+
_CACHED_PROXY_ACTION = "40be6d9fdcc81dd69cf943cccce3e8fcf190219950"
|
|
19
|
+
_CACHED_DRIVE_ACTION = "40e5348909ff78510ee46337a237c1352fcc630ad2"
|
|
20
|
+
|
|
21
|
+
_SPACE_RE = re.compile(r"\s+")
|
|
22
|
+
_OG_TITLE_SUFFIX_RE = re.compile(r"\s+-\s+Download in HD\s*\|\s*EonMovies\s*$", re.IGNORECASE)
|
|
23
|
+
_BG_IMAGE_RE = re.compile(r"background-image\s*:\s*url\(['\"]?([^'\")]+)['\"]?\)", re.IGNORECASE)
|
|
24
|
+
_META_TAG_RE = re.compile(r"^(?:Movie|Series|WEB-DL|Hindi|English|Dual Audio)$", re.IGNORECASE)
|
|
25
|
+
_SERIES_RE = re.compile(r"series", re.IGNORECASE)
|
|
26
|
+
_SEASON_RE = re.compile(r"\bSeason\s*\d+\b", re.IGNORECASE)
|
|
27
|
+
_QUALITY_RE = re.compile(r"(?:^|[^0-9])(\d{3,4})p(?=$|[^a-z0-9])", re.IGNORECASE)
|
|
28
|
+
_DOTFLIX_URL_RE = re.compile(
|
|
29
|
+
r"https?://(?:[a-z\d-]+\.)*(?:dotflix|dtflix)\.[a-z\d.]+/share/[a-z\d]+",
|
|
30
|
+
re.IGNORECASE,
|
|
31
|
+
)
|
|
32
|
+
_DOTFLIX_HOST_RE = re.compile(r"(?:^|\.)(?:dotflix|dtflix)\.", re.IGNORECASE)
|
|
33
|
+
_DOTFLIX_CODE_RE = re.compile(r"^/share/([a-z\d]+)", re.IGNORECASE)
|
|
34
|
+
_HUBCLOUD_HOST_RE = re.compile(r"(?:^|\.)hubcloud\.", re.IGNORECASE)
|
|
35
|
+
_SHARE_DATA_RE = re.compile(r'"initialShareData":\s*(\{[^}]+\})')
|
|
36
|
+
_CHUNK_SRC_RE = re.compile(r'src="([^"]*/static/chunks/[^"]+\.js)"')
|
|
37
|
+
_DYN_CHUNK_RE = re.compile(r"static/chunks/[a-zA-Z0-9_\-.]+\.js")
|
|
38
|
+
_PROXY_ACTION_RE = re.compile(
|
|
39
|
+
r'createServerReference\)\("([a-f0-9]+)",[^)]*?"resolveProxyDownload"\)'
|
|
40
|
+
)
|
|
41
|
+
_DRIVE_ACTION_RE = re.compile(
|
|
42
|
+
r'createServerReference\)\("([a-f0-9]+)",[^)]*?"getDriveUrl"\)'
|
|
43
|
+
)
|
|
44
|
+
_PD_ID_RE = re.compile(r"/u/([a-zA-Z0-9]+)")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _get_stream_quality(label: str) -> str | None:
|
|
48
|
+
m = _QUALITY_RE.search(label)
|
|
49
|
+
if m:
|
|
50
|
+
return str(int(m.group(1)))
|
|
51
|
+
return "2160" if re.search(r"\b4k\b", label, re.IGNORECASE) else None
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _add_quality(streams: list[dict[str, Any]], quality: str | None) -> list[dict[str, Any]]:
|
|
55
|
+
resolved = quality
|
|
56
|
+
if not resolved:
|
|
57
|
+
for s in streams:
|
|
58
|
+
resolved = s.get("quality") or _get_stream_quality(str(s.get("link") or ""))
|
|
59
|
+
if resolved:
|
|
60
|
+
break
|
|
61
|
+
out: list[dict[str, Any]] = []
|
|
62
|
+
for s in streams:
|
|
63
|
+
item = dict(s)
|
|
64
|
+
if resolved:
|
|
65
|
+
item["server"] = f"{item.get('server', '')} {resolved}p".strip()
|
|
66
|
+
item["quality"] = resolved
|
|
67
|
+
out.append(item)
|
|
68
|
+
return out
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _get_dotflix_url(data: str) -> str:
|
|
72
|
+
m = _DOTFLIX_URL_RE.search(data)
|
|
73
|
+
return m.group(0) if m else ""
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _get_dotflix_sharing_code(value: str) -> str:
|
|
77
|
+
try:
|
|
78
|
+
parsed = urlparse(value)
|
|
79
|
+
if not parsed.hostname or not _DOTFLIX_HOST_RE.search(parsed.hostname):
|
|
80
|
+
return ""
|
|
81
|
+
m = _DOTFLIX_CODE_RE.match(parsed.path)
|
|
82
|
+
return m.group(1) if m else ""
|
|
83
|
+
except Exception:
|
|
84
|
+
return ""
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _is_hubcloud_url(value: str) -> bool:
|
|
88
|
+
try:
|
|
89
|
+
parsed = urlparse(value)
|
|
90
|
+
return bool(parsed.hostname and _HUBCLOUD_HOST_RE.search(parsed.hostname))
|
|
91
|
+
except Exception:
|
|
92
|
+
return False
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _dotflix_router_state(sharing_code: str) -> str:
|
|
96
|
+
tree = [
|
|
97
|
+
"",
|
|
98
|
+
{
|
|
99
|
+
"children": [
|
|
100
|
+
"share",
|
|
101
|
+
{
|
|
102
|
+
"children": [
|
|
103
|
+
["code", sharing_code, "d"],
|
|
104
|
+
{"children": ["__PAGE__", {}, None, None]},
|
|
105
|
+
None,
|
|
106
|
+
None,
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
None,
|
|
110
|
+
None,
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
None,
|
|
114
|
+
None,
|
|
115
|
+
True,
|
|
116
|
+
]
|
|
117
|
+
return quote(json.dumps(tree, separators=(",", ":")), safe="")
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _extract_server_action_field(data: Any, field: str) -> str:
|
|
121
|
+
if not isinstance(data, str):
|
|
122
|
+
return ""
|
|
123
|
+
for line in data.splitlines():
|
|
124
|
+
idx = line.find(":")
|
|
125
|
+
value = line[idx + 1 :] if idx != -1 else line
|
|
126
|
+
try:
|
|
127
|
+
payload = json.loads(value)
|
|
128
|
+
if isinstance(payload, dict) and payload.get("success") and isinstance(
|
|
129
|
+
payload.get(field), str
|
|
130
|
+
):
|
|
131
|
+
return payload[field]
|
|
132
|
+
except Exception:
|
|
133
|
+
continue
|
|
134
|
+
return ""
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class EonMoviesClient(BaseProvider):
|
|
138
|
+
"""Client for the EonMovies provider."""
|
|
139
|
+
|
|
140
|
+
name: str = "eonMovies"
|
|
141
|
+
catalog: list[dict[str, str]] = [
|
|
142
|
+
{"title": "Latest", "filter": ""},
|
|
143
|
+
{"title": "Bollywood", "filter": "bollywood"},
|
|
144
|
+
{"title": "Hollywood", "filter": "hollywood"},
|
|
145
|
+
{"title": "South Indian", "filter": "tollywood"},
|
|
146
|
+
{"title": "Web Series", "filter": "series"},
|
|
147
|
+
{"title": "Netflix", "filter": "netflix"},
|
|
148
|
+
]
|
|
149
|
+
genres: list[dict[str, str]] = []
|
|
150
|
+
settings_schema: list[dict[str, Any]] = [
|
|
151
|
+
{
|
|
152
|
+
"key": "eonMovies_quickDownload",
|
|
153
|
+
"type": "toggle",
|
|
154
|
+
"label": "Quick Download",
|
|
155
|
+
"description": (
|
|
156
|
+
"Automatically download the preferred server in 1-click "
|
|
157
|
+
"without showing server selection"
|
|
158
|
+
),
|
|
159
|
+
"defaultValue": True,
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"key": "eonMovies_preferredDownloadServer",
|
|
163
|
+
"type": "select",
|
|
164
|
+
"label": "Preferred Download Server",
|
|
165
|
+
"description": "Server to prioritize for 1-click quick download",
|
|
166
|
+
"options": [
|
|
167
|
+
{"label": "Auto (Best Available)", "value": "auto"},
|
|
168
|
+
{"label": "CF Worker (Fastest)", "value": "cf worker"},
|
|
169
|
+
{"label": "CF Storage (R2 Direct)", "value": "cf storage"},
|
|
170
|
+
{"label": "GDrive (Google Direct)", "value": "gdrive"},
|
|
171
|
+
{"label": "Pixeldrain", "value": "pixeldrain"},
|
|
172
|
+
{"label": "FastDl", "value": "fastdl"},
|
|
173
|
+
{"label": "HubCdn", "value": "hubcdn"},
|
|
174
|
+
],
|
|
175
|
+
"defaultValue": "auto",
|
|
176
|
+
},
|
|
177
|
+
]
|
|
178
|
+
|
|
179
|
+
def _fetch_posts(self, url: str, base_url: str) -> list[dict[str, str]]:
|
|
180
|
+
doc = self.fetch_html(url)
|
|
181
|
+
posts: list[dict[str, str]] = []
|
|
182
|
+
for container in doc.select(".image-container"):
|
|
183
|
+
anchor = container.closest("a[href]")
|
|
184
|
+
if not anchor:
|
|
185
|
+
continue
|
|
186
|
+
link = anchor.attr("href")
|
|
187
|
+
img = container.select_one("img")
|
|
188
|
+
image = ""
|
|
189
|
+
if img:
|
|
190
|
+
image = img.attr("data-src") or img.attr("src") or ""
|
|
191
|
+
card_title = anchor.select_one(".card-title")
|
|
192
|
+
title = (
|
|
193
|
+
_SPACE_RE.sub(" ", card_title.text()).strip()
|
|
194
|
+
if card_title
|
|
195
|
+
else (img.attr("alt") if img else "")
|
|
196
|
+
)
|
|
197
|
+
if title and link and image:
|
|
198
|
+
posts.append(
|
|
199
|
+
{
|
|
200
|
+
"title": title,
|
|
201
|
+
"link": to_relative_path(link, base_url),
|
|
202
|
+
"image": normalize_url(image, base_url),
|
|
203
|
+
}
|
|
204
|
+
)
|
|
205
|
+
return posts
|
|
206
|
+
|
|
207
|
+
def get_posts(self, filter_path: str = "", page: int = 1) -> list[dict[str, str]]:
|
|
208
|
+
base_url = get_base_url(_PROVIDER_VALUE, session=self.session)
|
|
209
|
+
qs = urlencode(
|
|
210
|
+
{
|
|
211
|
+
"action": "",
|
|
212
|
+
"page": str(page),
|
|
213
|
+
"name": "",
|
|
214
|
+
"category": filter_path,
|
|
215
|
+
}
|
|
216
|
+
)
|
|
217
|
+
url = f"{base_url.rstrip('/')}/?{qs}"
|
|
218
|
+
return self._fetch_posts(url, base_url)
|
|
219
|
+
|
|
220
|
+
def get_search_posts(self, query: str, page: int = 1) -> list[dict[str, str]]:
|
|
221
|
+
base_url = get_base_url(_PROVIDER_VALUE, session=self.session)
|
|
222
|
+
qs = urlencode(
|
|
223
|
+
{
|
|
224
|
+
"action": "search",
|
|
225
|
+
"page": str(page),
|
|
226
|
+
"name": query,
|
|
227
|
+
}
|
|
228
|
+
)
|
|
229
|
+
url = f"{base_url.rstrip('/')}/?{qs}"
|
|
230
|
+
return self._fetch_posts(url, base_url)
|
|
231
|
+
|
|
232
|
+
def get_meta(self, link: str) -> dict[str, Any]:
|
|
233
|
+
base_url = get_base_url(_PROVIDER_VALUE, session=self.session)
|
|
234
|
+
url = normalize_url(link, base_url)
|
|
235
|
+
doc = self.fetch_html(url)
|
|
236
|
+
|
|
237
|
+
og = doc.select_one('meta[property="og:title"]')
|
|
238
|
+
raw_title = og.attr("content") if og else ""
|
|
239
|
+
title = _OG_TITLE_SUFFIX_RE.sub("", raw_title).strip()
|
|
240
|
+
|
|
241
|
+
hero = doc.select_one("#heroBackdrop")
|
|
242
|
+
style = hero.attr("style") if hero else ""
|
|
243
|
+
bg_m = _BG_IMAGE_RE.search(style)
|
|
244
|
+
image = bg_m.group(1) if bg_m else ""
|
|
245
|
+
|
|
246
|
+
ov = doc.select_one(".overview-text")
|
|
247
|
+
synopsis = _SPACE_RE.sub(" ", ov.text()).strip() if ov else ""
|
|
248
|
+
|
|
249
|
+
pills_node = doc.select_one(".meta-pills")
|
|
250
|
+
pills_text = pills_node.text() if pills_node else ""
|
|
251
|
+
media_type = (
|
|
252
|
+
"series"
|
|
253
|
+
if (_SERIES_RE.search(pills_text) or _SEASON_RE.search(title))
|
|
254
|
+
else "movie"
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
genres_list = [
|
|
258
|
+
el.text().strip()
|
|
259
|
+
for el in doc.select("#movieGenresBox .genre-pill")
|
|
260
|
+
if el.text().strip()
|
|
261
|
+
]
|
|
262
|
+
meta_list = [
|
|
263
|
+
_SPACE_RE.sub(" ", el.text()).strip()
|
|
264
|
+
for el in doc.select(".meta-pill")
|
|
265
|
+
if _META_TAG_RE.match(_SPACE_RE.sub(" ", el.text()).strip())
|
|
266
|
+
]
|
|
267
|
+
tags = list(dict.fromkeys([*genres_list, *meta_list]))[:3]
|
|
268
|
+
|
|
269
|
+
direct_links: list[dict[str, str]] = []
|
|
270
|
+
for row in doc.select(".dl-row"):
|
|
271
|
+
row_name = row.select_one(".dl-row-name")
|
|
272
|
+
dl_title = row.attr("data-dlname") or (
|
|
273
|
+
_SPACE_RE.sub(" ", row_name.text()).strip() if row_name else ""
|
|
274
|
+
)
|
|
275
|
+
dl_anchor = row.select_one("a[href*='/dl/']")
|
|
276
|
+
href = dl_anchor.attr("href") if dl_anchor else ""
|
|
277
|
+
if dl_title and href:
|
|
278
|
+
direct_links.append(
|
|
279
|
+
{
|
|
280
|
+
"title": format_season_title(dl_title),
|
|
281
|
+
"link": normalize_url(href, base_url),
|
|
282
|
+
}
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
link_list: list[dict[str, Any]] = (
|
|
286
|
+
[{"title": "Downloads", "directLinks": direct_links}] if direct_links else []
|
|
287
|
+
)
|
|
288
|
+
quick_dl = self.kv.get("eonMovies_quickDownload")
|
|
289
|
+
|
|
290
|
+
return {
|
|
291
|
+
"title": title,
|
|
292
|
+
"image": image,
|
|
293
|
+
"synopsis": synopsis,
|
|
294
|
+
"imdbId": "",
|
|
295
|
+
"type": media_type,
|
|
296
|
+
"quickDownload": True if quick_dl is None else bool(quick_dl),
|
|
297
|
+
"tags": tags,
|
|
298
|
+
"linkList": link_list,
|
|
299
|
+
"webUrl": url,
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
def _call_dotflix_action(
|
|
303
|
+
self,
|
|
304
|
+
link: str,
|
|
305
|
+
action_id: str,
|
|
306
|
+
sharing_code: str,
|
|
307
|
+
headers: dict[str, str],
|
|
308
|
+
) -> str:
|
|
309
|
+
resp = self.session.post(
|
|
310
|
+
link,
|
|
311
|
+
data=json.dumps([sharing_code]),
|
|
312
|
+
headers={
|
|
313
|
+
**headers,
|
|
314
|
+
"Accept": "text/x-component",
|
|
315
|
+
"Content-Type": "text/plain;charset=UTF-8",
|
|
316
|
+
"Next-Action": action_id,
|
|
317
|
+
"Next-Router-State-Tree": _dotflix_router_state(sharing_code),
|
|
318
|
+
},
|
|
319
|
+
timeout=self.timeout,
|
|
320
|
+
)
|
|
321
|
+
resp.raise_for_status()
|
|
322
|
+
return resp.text
|
|
323
|
+
|
|
324
|
+
def _resolve_dotflix_worker(self, drive_url: str) -> str:
|
|
325
|
+
try:
|
|
326
|
+
data = self.fetch_json(
|
|
327
|
+
"https://dotflix.pobmovie0301.workers.dev/api/generate-link",
|
|
328
|
+
method="POST",
|
|
329
|
+
json_body={"driveUrl": drive_url},
|
|
330
|
+
headers={"Content-Type": "application/json"},
|
|
331
|
+
)
|
|
332
|
+
if isinstance(data, dict) and data.get("success") and isinstance(
|
|
333
|
+
data.get("workerUrl"), str
|
|
334
|
+
):
|
|
335
|
+
return data["workerUrl"]
|
|
336
|
+
except Exception:
|
|
337
|
+
pass
|
|
338
|
+
return ""
|
|
339
|
+
|
|
340
|
+
def _resolve_dotflix_actions_from_page(
|
|
341
|
+
self,
|
|
342
|
+
link: str,
|
|
343
|
+
headers: dict[str, str],
|
|
344
|
+
) -> dict[str, Any]:
|
|
345
|
+
try:
|
|
346
|
+
parsed = urlparse(link)
|
|
347
|
+
origin = f"{parsed.scheme}://{parsed.netloc}"
|
|
348
|
+
html = self.fetch_text(link, headers={**headers, "Referer": link})
|
|
349
|
+
if not html:
|
|
350
|
+
return {}
|
|
351
|
+
|
|
352
|
+
initial_share_data: dict[str, Any] | None = None
|
|
353
|
+
m_share = _SHARE_DATA_RE.search(html)
|
|
354
|
+
if m_share:
|
|
355
|
+
try:
|
|
356
|
+
initial_share_data = json.loads(m_share.group(1))
|
|
357
|
+
except Exception:
|
|
358
|
+
pass
|
|
359
|
+
|
|
360
|
+
chunks = _CHUNK_SRC_RE.findall(html)
|
|
361
|
+
if not chunks:
|
|
362
|
+
return {"initialShareData": initial_share_data}
|
|
363
|
+
|
|
364
|
+
def _get_chunk(src: str) -> str:
|
|
365
|
+
chunk_url = src if src.startswith("http") else f"{origin}{src}"
|
|
366
|
+
try:
|
|
367
|
+
return self.fetch_text(chunk_url, headers={**headers, "Referer": link})
|
|
368
|
+
except Exception:
|
|
369
|
+
return ""
|
|
370
|
+
|
|
371
|
+
with ThreadPoolExecutor(max_workers=6) as pool:
|
|
372
|
+
chunk_texts = list(pool.map(_get_chunk, chunks))
|
|
373
|
+
|
|
374
|
+
proxy_action: str | None = None
|
|
375
|
+
drive_action: str | None = None
|
|
376
|
+
second_level: set[str] = set()
|
|
377
|
+
|
|
378
|
+
for text in chunk_texts:
|
|
379
|
+
if not text:
|
|
380
|
+
continue
|
|
381
|
+
if not proxy_action:
|
|
382
|
+
pm = _PROXY_ACTION_RE.search(text)
|
|
383
|
+
if pm:
|
|
384
|
+
proxy_action = pm.group(1)
|
|
385
|
+
if not drive_action:
|
|
386
|
+
dm = _DRIVE_ACTION_RE.search(text)
|
|
387
|
+
if dm:
|
|
388
|
+
drive_action = dm.group(1)
|
|
389
|
+
for dyn in _DYN_CHUNK_RE.findall(text):
|
|
390
|
+
second_level.add(f"/_next/{dyn}")
|
|
391
|
+
|
|
392
|
+
if (not proxy_action or not drive_action) and second_level:
|
|
393
|
+
with ThreadPoolExecutor(max_workers=6) as pool:
|
|
394
|
+
dyn_texts = list(pool.map(_get_chunk, list(second_level)))
|
|
395
|
+
for text in dyn_texts:
|
|
396
|
+
if not text:
|
|
397
|
+
continue
|
|
398
|
+
if not proxy_action:
|
|
399
|
+
pm = _PROXY_ACTION_RE.search(text)
|
|
400
|
+
if pm:
|
|
401
|
+
proxy_action = pm.group(1)
|
|
402
|
+
if not drive_action:
|
|
403
|
+
dm = _DRIVE_ACTION_RE.search(text)
|
|
404
|
+
if dm:
|
|
405
|
+
drive_action = dm.group(1)
|
|
406
|
+
|
|
407
|
+
return {
|
|
408
|
+
"proxyAction": proxy_action,
|
|
409
|
+
"driveAction": drive_action,
|
|
410
|
+
"initialShareData": initial_share_data,
|
|
411
|
+
}
|
|
412
|
+
except Exception:
|
|
413
|
+
return {}
|
|
414
|
+
|
|
415
|
+
def _follow_download_link(self, link: str, headers: dict[str, str]) -> tuple[str, str]:
|
|
416
|
+
current_url = link
|
|
417
|
+
for _ in range(5):
|
|
418
|
+
resp = self.session.get(
|
|
419
|
+
current_url,
|
|
420
|
+
headers=headers,
|
|
421
|
+
timeout=15,
|
|
422
|
+
allow_redirects=False,
|
|
423
|
+
)
|
|
424
|
+
if not (200 <= resp.status_code < 400):
|
|
425
|
+
resp.raise_for_status()
|
|
426
|
+
location = resp.headers.get("location") or resp.headers.get("Location")
|
|
427
|
+
if location:
|
|
428
|
+
current_url = urljoin(current_url, location)
|
|
429
|
+
if _get_dotflix_sharing_code(current_url) or _is_hubcloud_url(current_url):
|
|
430
|
+
return "", current_url
|
|
431
|
+
continue
|
|
432
|
+
data = resp.text
|
|
433
|
+
resolved_url = (
|
|
434
|
+
current_url
|
|
435
|
+
if _get_dotflix_sharing_code(current_url)
|
|
436
|
+
else (_get_dotflix_url(data) or current_url)
|
|
437
|
+
)
|
|
438
|
+
return data, resolved_url
|
|
439
|
+
raise RuntimeError("EonMovies download redirect chain exceeded the limit")
|
|
440
|
+
|
|
441
|
+
def _resolve_dotflix_share_url(self, link: str, headers: dict[str, str]) -> str:
|
|
442
|
+
sharing_code = _get_dotflix_sharing_code(link)
|
|
443
|
+
visited: set[str] = set()
|
|
444
|
+
current_url = link
|
|
445
|
+
for _ in range(5):
|
|
446
|
+
if current_url in visited:
|
|
447
|
+
raise RuntimeError("Dotflix share redirect loop")
|
|
448
|
+
visited.add(current_url)
|
|
449
|
+
resp = self.session.get(
|
|
450
|
+
current_url,
|
|
451
|
+
headers={**headers, "Referer": current_url},
|
|
452
|
+
timeout=15,
|
|
453
|
+
allow_redirects=False,
|
|
454
|
+
)
|
|
455
|
+
if not (200 <= resp.status_code < 400):
|
|
456
|
+
resp.raise_for_status()
|
|
457
|
+
location = resp.headers.get("location") or resp.headers.get("Location")
|
|
458
|
+
target = urljoin(current_url, location) if location else (resp.url or current_url)
|
|
459
|
+
if _get_dotflix_sharing_code(target) != sharing_code:
|
|
460
|
+
raise RuntimeError("Dotflix redirected away from the requested share")
|
|
461
|
+
if not location:
|
|
462
|
+
return target
|
|
463
|
+
current_url = target
|
|
464
|
+
raise RuntimeError("Dotflix share redirect chain exceeded the limit")
|
|
465
|
+
|
|
466
|
+
def _extract_dotflix_stream(
|
|
467
|
+
self,
|
|
468
|
+
link: str,
|
|
469
|
+
headers: dict[str, str],
|
|
470
|
+
is_download: bool = False,
|
|
471
|
+
) -> list[dict[str, Any]]:
|
|
472
|
+
sharing_code = _get_dotflix_sharing_code(link)
|
|
473
|
+
if not sharing_code:
|
|
474
|
+
return []
|
|
475
|
+
|
|
476
|
+
link = self._resolve_dotflix_share_url(link, headers)
|
|
477
|
+
parsed = urlparse(link)
|
|
478
|
+
origin = f"{parsed.scheme}://{parsed.netloc}"
|
|
479
|
+
req_headers = {**headers, "Origin": origin, "Referer": link}
|
|
480
|
+
|
|
481
|
+
proxy_action = str(self.kv.get("dotflix_proxy_action") or _CACHED_PROXY_ACTION)
|
|
482
|
+
drive_action = str(self.kv.get("dotflix_drive_action") or _CACHED_DRIVE_ACTION)
|
|
483
|
+
|
|
484
|
+
streams: list[dict[str, Any]] = []
|
|
485
|
+
seen_links: set[str] = set()
|
|
486
|
+
media_type = "mkv"
|
|
487
|
+
file_quality: str | None = None
|
|
488
|
+
|
|
489
|
+
def _add_stream(server: str, stream_url: str) -> None:
|
|
490
|
+
if not stream_url or stream_url in seen_links:
|
|
491
|
+
return
|
|
492
|
+
seen_links.add(stream_url)
|
|
493
|
+
is_zip = bool(re.search(r"\.zip(?:\?|$)", stream_url, re.IGNORECASE))
|
|
494
|
+
streams.append(
|
|
495
|
+
{
|
|
496
|
+
"server": server,
|
|
497
|
+
"link": stream_url,
|
|
498
|
+
"type": "zip" if is_zip else media_type,
|
|
499
|
+
"quality": file_quality,
|
|
500
|
+
}
|
|
501
|
+
)
|
|
502
|
+
|
|
503
|
+
def _sort_streams() -> list[dict[str, Any]]:
|
|
504
|
+
def _prio(s: dict[str, Any]) -> int:
|
|
505
|
+
srv = str(s.get("server") or "")
|
|
506
|
+
if is_download:
|
|
507
|
+
return 0 if re.search(r"Quick Download|Proxy|Direct", srv) else 1
|
|
508
|
+
return 0 if re.search(r"Direct|Worker", srv) else 1
|
|
509
|
+
|
|
510
|
+
return sorted(streams, key=_prio)
|
|
511
|
+
|
|
512
|
+
def _post_json(path: str) -> dict[str, Any] | None:
|
|
513
|
+
try:
|
|
514
|
+
return self.fetch_json(
|
|
515
|
+
f"{origin}{path}",
|
|
516
|
+
method="POST",
|
|
517
|
+
json_body={"sharingCode": sharing_code},
|
|
518
|
+
headers={**req_headers, "Content-Type": "application/json"},
|
|
519
|
+
timeout=15,
|
|
520
|
+
)
|
|
521
|
+
except Exception:
|
|
522
|
+
return None
|
|
523
|
+
|
|
524
|
+
def _get_status() -> dict[str, Any] | None:
|
|
525
|
+
try:
|
|
526
|
+
return self.fetch_json(
|
|
527
|
+
f"{origin}/api/share-status/{sharing_code}",
|
|
528
|
+
headers=req_headers,
|
|
529
|
+
timeout=10,
|
|
530
|
+
)
|
|
531
|
+
except Exception:
|
|
532
|
+
return None
|
|
533
|
+
|
|
534
|
+
with ThreadPoolExecutor(max_workers=3) as pool:
|
|
535
|
+
f_resume = pool.submit(_post_json, "/api/generate-direct-drive-download")
|
|
536
|
+
f_quick = pool.submit(_post_json, "/api/generate-quick-download")
|
|
537
|
+
f_status = pool.submit(_get_status)
|
|
538
|
+
resume_res = f_resume.result()
|
|
539
|
+
quick_res = f_quick.result()
|
|
540
|
+
status_res = f_status.result()
|
|
541
|
+
|
|
542
|
+
if isinstance(status_res, dict) and isinstance(status_res.get("data"), dict):
|
|
543
|
+
file_info = status_res["data"]
|
|
544
|
+
filename = str(file_info.get("filename") or "")
|
|
545
|
+
file_quality = _get_stream_quality(filename)
|
|
546
|
+
ext = str(
|
|
547
|
+
file_info.get("fileType") or (filename.rsplit(".", 1)[-1] if "." in filename else "")
|
|
548
|
+
).lower()
|
|
549
|
+
if ext in ("zip", "mp4", "mkv", "m3u8"):
|
|
550
|
+
media_type = ext
|
|
551
|
+
|
|
552
|
+
for res_data, srv_name in (
|
|
553
|
+
(resume_res, "Dotflix Direct Resume"),
|
|
554
|
+
(quick_res, "Dotflix Quick Download"),
|
|
555
|
+
):
|
|
556
|
+
if (
|
|
557
|
+
isinstance(res_data, dict)
|
|
558
|
+
and res_data.get("success")
|
|
559
|
+
and isinstance(res_data.get("workerUrl"), str)
|
|
560
|
+
):
|
|
561
|
+
_add_stream(srv_name, res_data["workerUrl"])
|
|
562
|
+
|
|
563
|
+
if streams:
|
|
564
|
+
return _sort_streams()
|
|
565
|
+
|
|
566
|
+
def _safe_cf() -> dict[str, Any] | None:
|
|
567
|
+
try:
|
|
568
|
+
return self.fetch_json(
|
|
569
|
+
f"{origin}/api/secure-cloudflare-url/{sharing_code}",
|
|
570
|
+
headers={**req_headers, "Referer": link},
|
|
571
|
+
)
|
|
572
|
+
except Exception:
|
|
573
|
+
return None
|
|
574
|
+
|
|
575
|
+
def _safe_action(aid: str) -> str:
|
|
576
|
+
try:
|
|
577
|
+
return self._call_dotflix_action(link, aid, sharing_code, req_headers)
|
|
578
|
+
except Exception:
|
|
579
|
+
return ""
|
|
580
|
+
|
|
581
|
+
with ThreadPoolExecutor(max_workers=4) as pool:
|
|
582
|
+
f_direct = pool.submit(_post_json, "/api/extract-download")
|
|
583
|
+
f_cf = pool.submit(_safe_cf)
|
|
584
|
+
f_proxy = pool.submit(_safe_action, proxy_action)
|
|
585
|
+
f_drive = pool.submit(_safe_action, drive_action)
|
|
586
|
+
|
|
587
|
+
direct_res = f_direct.result()
|
|
588
|
+
cf_res = f_cf.result()
|
|
589
|
+
proxy_raw = f_proxy.result()
|
|
590
|
+
drive_raw = f_drive.result()
|
|
591
|
+
|
|
592
|
+
if (
|
|
593
|
+
isinstance(direct_res, dict)
|
|
594
|
+
and direct_res.get("success")
|
|
595
|
+
and isinstance(direct_res.get("downloadUrl"), str)
|
|
596
|
+
):
|
|
597
|
+
_add_stream("Dotflix Direct", direct_res["downloadUrl"])
|
|
598
|
+
|
|
599
|
+
if (
|
|
600
|
+
isinstance(cf_res, dict)
|
|
601
|
+
and cf_res.get("success")
|
|
602
|
+
and isinstance(cf_res.get("downloadUrl"), str)
|
|
603
|
+
):
|
|
604
|
+
_add_stream("Dotflix (Cloudflare)", cf_res["downloadUrl"])
|
|
605
|
+
|
|
606
|
+
proxy_url = _extract_server_action_field(proxy_raw, "downloadUrl")
|
|
607
|
+
if proxy_url:
|
|
608
|
+
_add_stream("Dotflix Proxy", proxy_url)
|
|
609
|
+
|
|
610
|
+
drive_url = _extract_server_action_field(drive_raw, "driveUrl")
|
|
611
|
+
if drive_url:
|
|
612
|
+
worker_url = self._resolve_dotflix_worker(drive_url)
|
|
613
|
+
if worker_url:
|
|
614
|
+
_add_stream("Dotflix Worker", worker_url)
|
|
615
|
+
|
|
616
|
+
if not proxy_url and not drive_url:
|
|
617
|
+
resolved = self._resolve_dotflix_actions_from_page(link, headers)
|
|
618
|
+
retry_needed = False
|
|
619
|
+
if resolved.get("proxyAction") and resolved["proxyAction"] != proxy_action:
|
|
620
|
+
proxy_action = resolved["proxyAction"]
|
|
621
|
+
self.kv.set("dotflix_proxy_action", proxy_action)
|
|
622
|
+
retry_needed = True
|
|
623
|
+
if resolved.get("driveAction") and resolved["driveAction"] != drive_action:
|
|
624
|
+
drive_action = resolved["driveAction"]
|
|
625
|
+
self.kv.set("dotflix_drive_action", drive_action)
|
|
626
|
+
retry_needed = True
|
|
627
|
+
|
|
628
|
+
share_data = resolved.get("initialShareData")
|
|
629
|
+
if isinstance(share_data, dict):
|
|
630
|
+
pd_link = share_data.get("pixeldrainLink")
|
|
631
|
+
if isinstance(pd_link, str) and pd_link:
|
|
632
|
+
pd_m = _PD_ID_RE.search(pd_link)
|
|
633
|
+
if pd_m:
|
|
634
|
+
_add_stream(
|
|
635
|
+
"Dotflix (PixelDrain)",
|
|
636
|
+
f"https://pixeldrain.com/api/file/{pd_m.group(1)}?download",
|
|
637
|
+
)
|
|
638
|
+
|
|
639
|
+
if retry_needed:
|
|
640
|
+
with ThreadPoolExecutor(max_workers=2) as pool:
|
|
641
|
+
f_p2 = pool.submit(_safe_action, proxy_action)
|
|
642
|
+
f_d2 = pool.submit(_safe_action, drive_action)
|
|
643
|
+
p2_url = _extract_server_action_field(f_p2.result(), "downloadUrl")
|
|
644
|
+
d2_url = _extract_server_action_field(f_d2.result(), "driveUrl")
|
|
645
|
+
if p2_url:
|
|
646
|
+
_add_stream("Dotflix Proxy", p2_url)
|
|
647
|
+
if d2_url:
|
|
648
|
+
w2 = self._resolve_dotflix_worker(d2_url)
|
|
649
|
+
if w2:
|
|
650
|
+
_add_stream("Dotflix Worker", w2)
|
|
651
|
+
|
|
652
|
+
if not streams:
|
|
653
|
+
raise RuntimeError("Dotflix did not return a direct or proxy download URL")
|
|
654
|
+
|
|
655
|
+
return _sort_streams()
|
|
656
|
+
|
|
657
|
+
def _extract_download_streams(
|
|
658
|
+
self,
|
|
659
|
+
link: str,
|
|
660
|
+
headers: dict[str, str],
|
|
661
|
+
is_download: bool = False,
|
|
662
|
+
) -> list[dict[str, Any]]:
|
|
663
|
+
if _get_dotflix_sharing_code(link):
|
|
664
|
+
return self._extract_dotflix_stream(link, headers, is_download=is_download)
|
|
665
|
+
if _is_hubcloud_url(link):
|
|
666
|
+
return hubcloud_extractor(
|
|
667
|
+
link,
|
|
668
|
+
session=self.session,
|
|
669
|
+
is_download=is_download,
|
|
670
|
+
provider_value="eonMovies",
|
|
671
|
+
kv_store=self.kv,
|
|
672
|
+
)
|
|
673
|
+
return []
|
|
674
|
+
|
|
675
|
+
def get_stream(
|
|
676
|
+
self,
|
|
677
|
+
url: str,
|
|
678
|
+
is_download: bool = False,
|
|
679
|
+
media_type: str = "movie",
|
|
680
|
+
) -> list[dict[str, Any]]:
|
|
681
|
+
headers = dict(self.session.headers)
|
|
682
|
+
visited: set[str] = set()
|
|
683
|
+
|
|
684
|
+
def _resolve(
|
|
685
|
+
link: str, depth: int, quality: str | None = None
|
|
686
|
+
) -> list[dict[str, Any]]:
|
|
687
|
+
if depth > 5 or link in visited:
|
|
688
|
+
return []
|
|
689
|
+
visited.add(link)
|
|
690
|
+
|
|
691
|
+
if _get_dotflix_sharing_code(link) or _is_hubcloud_url(link):
|
|
692
|
+
return _add_quality(
|
|
693
|
+
self._extract_download_streams(link, headers, is_download=is_download),
|
|
694
|
+
quality,
|
|
695
|
+
)
|
|
696
|
+
|
|
697
|
+
page_data, page_url = self._follow_download_link(link, headers)
|
|
698
|
+
if _get_dotflix_sharing_code(page_url) or _is_hubcloud_url(page_url):
|
|
699
|
+
return _add_quality(
|
|
700
|
+
self._extract_download_streams(page_url, headers, is_download=is_download),
|
|
701
|
+
quality,
|
|
702
|
+
)
|
|
703
|
+
|
|
704
|
+
if page_url != link and page_url in visited:
|
|
705
|
+
return []
|
|
706
|
+
visited.add(page_url)
|
|
707
|
+
|
|
708
|
+
doc: Node = parse_html(page_data)
|
|
709
|
+
title_node = doc.select_one("title")
|
|
710
|
+
page_quality = quality or _get_stream_quality(
|
|
711
|
+
title_node.text() if title_node else ""
|
|
712
|
+
)
|
|
713
|
+
|
|
714
|
+
download_links: list[tuple[str, str | None]] = []
|
|
715
|
+
for anchor in doc.select(".dl-row a[href*='/dl/'], a.dl-btn-host[href*='/dl/']"):
|
|
716
|
+
href = anchor.attr("href")
|
|
717
|
+
if not href:
|
|
718
|
+
continue
|
|
719
|
+
row = anchor.closest(".dl-row")
|
|
720
|
+
label = ""
|
|
721
|
+
if row:
|
|
722
|
+
rn = row.select_one(".dl-row-name")
|
|
723
|
+
label = row.attr("data-dlname") or (rn.text().strip() if rn else "")
|
|
724
|
+
download_links.append(
|
|
725
|
+
(urljoin(page_url, href), _get_stream_quality(label) or page_quality)
|
|
726
|
+
)
|
|
727
|
+
|
|
728
|
+
if not download_links:
|
|
729
|
+
raise RuntimeError(
|
|
730
|
+
f"EonMovies has no supported download mirrors: {page_url}"
|
|
731
|
+
)
|
|
732
|
+
|
|
733
|
+
streams: list[dict[str, Any]] = []
|
|
734
|
+
last_err: Exception | None = None
|
|
735
|
+
for dl_url, dl_qual in download_links:
|
|
736
|
+
try:
|
|
737
|
+
streams.extend(_resolve(dl_url, depth + 1, dl_qual))
|
|
738
|
+
except Exception as err:
|
|
739
|
+
last_err = err
|
|
740
|
+
if not streams and last_err is not None:
|
|
741
|
+
raise last_err
|
|
742
|
+
return streams
|
|
743
|
+
|
|
744
|
+
all_streams = _resolve(url, 0)
|
|
745
|
+
deduped: list[dict[str, Any]] = []
|
|
746
|
+
seen: set[str] = set()
|
|
747
|
+
for s in all_streams:
|
|
748
|
+
s_link = str(s.get("link") or "")
|
|
749
|
+
if s_link and s_link not in seen:
|
|
750
|
+
seen.add(s_link)
|
|
751
|
+
deduped.append(s)
|
|
752
|
+
return deduped
|