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.
Files changed (84) hide show
  1. vega_cli/__init__.py +1 -0
  2. vega_cli/__main__.py +6 -0
  3. vega_cli/cli.py +247 -0
  4. vega_cli/config.py +99 -0
  5. vega_cli/display.py +138 -0
  6. vega_cli/html.py +540 -0
  7. vega_cli/interactive.py +220 -0
  8. vega_cli/player.py +82 -0
  9. vega_cli/providers/__init__.py +13 -0
  10. vega_cli/providers/ani_dream.py +1089 -0
  11. vega_cli/providers/anikoto.py +820 -0
  12. vega_cli/providers/animesalt.py +649 -0
  13. vega_cli/providers/animesub.py +1374 -0
  14. vega_cli/providers/animeworld.py +504 -0
  15. vega_cli/providers/auto_embed.py +479 -0
  16. vega_cli/providers/castle.py +497 -0
  17. vega_cli/providers/cncverse.py +873 -0
  18. vega_cli/providers/common/__init__.py +51 -0
  19. vega_cli/providers/common/aes.py +152 -0
  20. vega_cli/providers/common/aniskip.py +186 -0
  21. vega_cli/providers/common/base_url.py +102 -0
  22. vega_cli/providers/common/cinemeta.py +231 -0
  23. vega_cli/providers/common/errors.py +25 -0
  24. vega_cli/providers/common/extractors/__init__.py +23 -0
  25. vega_cli/providers/common/extractors/abbasy.py +247 -0
  26. vega_cli/providers/common/extractors/buzzheavier.py +72 -0
  27. vega_cli/providers/common/extractors/cinejoy.py +33 -0
  28. vega_cli/providers/common/extractors/gdflix.py +170 -0
  29. vega_cli/providers/common/extractors/gofile.py +167 -0
  30. vega_cli/providers/common/extractors/hubcloud.py +277 -0
  31. vega_cli/providers/common/extractors/movy.py +349 -0
  32. vega_cli/providers/common/extractors/st111477.py +139 -0
  33. vega_cli/providers/common/extractors/transferit.py +53 -0
  34. vega_cli/providers/common/extractors/vegadrive.py +161 -0
  35. vega_cli/providers/common/extractors/vidstuck.py +379 -0
  36. vega_cli/providers/common/extractors/zcloud.py +158 -0
  37. vega_cli/providers/common/extractors/zypter.py +72 -0
  38. vega_cli/providers/common/headers.py +25 -0
  39. vega_cli/providers/common/http.py +121 -0
  40. vega_cli/providers/common/net_mirror.py +1494 -0
  41. vega_cli/providers/common/theintrodb.py +112 -0
  42. vega_cli/providers/common/unpack.py +54 -0
  43. vega_cli/providers/disney_mirror.py +31 -0
  44. vega_cli/providers/dramacool.py +297 -0
  45. vega_cli/providers/drive.py +695 -0
  46. vega_cli/providers/durbin_live.py +354 -0
  47. vega_cli/providers/eon_movies.py +752 -0
  48. vega_cli/providers/extraflix.py +701 -0
  49. vega_cli/providers/four_khdhub.py +307 -0
  50. vega_cli/providers/goku_hd.py +336 -0
  51. vega_cli/providers/hdhub4u.py +665 -0
  52. vega_cli/providers/internet_archive.py +552 -0
  53. vega_cli/providers/kartoons.py +642 -0
  54. vega_cli/providers/kartoons2.py +395 -0
  55. vega_cli/providers/katmovies.py +816 -0
  56. vega_cli/providers/kick_ass_anime.py +445 -0
  57. vega_cli/providers/kiss_kh.py +490 -0
  58. vega_cli/providers/live_tg_tv.py +540 -0
  59. vega_cli/providers/lux_movies.py +650 -0
  60. vega_cli/providers/mod.py +676 -0
  61. vega_cli/providers/movie_box_web.py +921 -0
  62. vega_cli/providers/movielinkdb.py +734 -0
  63. vega_cli/providers/movies4u.py +580 -0
  64. vega_cli/providers/moviezwap.py +199 -0
  65. vega_cli/providers/mxplayer.py +470 -0
  66. vega_cli/providers/netflix_mirror.py +32 -0
  67. vega_cli/providers/one_cinevood.py +596 -0
  68. vega_cli/providers/prime_mirror.py +31 -0
  69. vega_cli/providers/rareanimes.py +676 -0
  70. vega_cli/providers/registry.py +124 -0
  71. vega_cli/providers/showbox.py +245 -0
  72. vega_cli/providers/topmovies.py +707 -0
  73. vega_cli/providers/torrentio.py +398 -0
  74. vega_cli/providers/uhd.py +483 -0
  75. vega_cli/providers/vega.py +891 -0
  76. vega_cli/providers/youtube.py +566 -0
  77. vega_cli/providers/zeefliz.py +563 -0
  78. vega_cli/store.py +45 -0
  79. vega_cli/utils.py +90 -0
  80. vega_cli-0.1.0.dist-info/METADATA +8 -0
  81. vega_cli-0.1.0.dist-info/RECORD +84 -0
  82. vega_cli-0.1.0.dist-info/WHEEL +5 -0
  83. vega_cli-0.1.0.dist-info/entry_points.txt +2 -0
  84. vega_cli-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,891 @@
1
+ """Pure-Python Vega provider."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import re
7
+ from typing import Any
8
+ from urllib.parse import quote_plus, unquote, urljoin
9
+
10
+ from ..html import Node, parse_html
11
+ from ..utils import format_season_title, to_relative_path
12
+ from .common import (
13
+ BaseProvider,
14
+ add_cinemeta_context,
15
+ apply_cinemeta_meta,
16
+ enrich_cinemeta_episodes,
17
+ enrich_episodes_with_skip_timings,
18
+ get_base_url,
19
+ get_cinemeta_meta,
20
+ get_cinemeta_season,
21
+ read_cinemeta_context,
22
+ throw_provider_error,
23
+ )
24
+ from .common.extractors import hubcloud_extractor, vegadrive_extractor
25
+
26
+ _VEGA_HEADERS: dict[str, str] = {
27
+ "Accept": (
28
+ "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,"
29
+ "image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"
30
+ ),
31
+ "Cache-Control": "no-store",
32
+ "Accept-Language": "en-US,en;q=0.9",
33
+ "DNT": "1",
34
+ "sec-ch-ua": '"Not_A Brand";v="8", "Chromium";v="120", "Microsoft Edge";v="120"',
35
+ "sec-ch-ua-mobile": "?0",
36
+ "sec-ch-ua-platform": '"Windows"',
37
+ "Sec-Fetch-Dest": "document",
38
+ "Sec-Fetch-Mode": "navigate",
39
+ "Sec-Fetch-Site": "none",
40
+ "Sec-Fetch-User": "?1",
41
+ "Cookie": (
42
+ "xla=s4t; _ga=GA1.1.1081149560.1756378968; "
43
+ "_ga_BLZGKYN5PF=GS2.1.s1756378968$o1$g1$t1756378984$j44$l0$h0"
44
+ ),
45
+ "Upgrade-Insecure-Requests": "1",
46
+ "User-Agent": (
47
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
48
+ "(KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"
49
+ ),
50
+ }
51
+
52
+ _EPISODE_HEADERS: dict[str, str] = {
53
+ "Cookie": (
54
+ "ext_name=ojplmecpdpgccookcobabopnaifgidhf; "
55
+ "cf_clearance=6yZYfXQxBgjaD1eacR5zZCz7njssbxjtSZZCElTOGk0-1764836255-1.2.1.1-"
56
+ "bzHvDcDRLp6AAYo7qvGVzJ6Gk6zaqAepuGiGhAWCGYL.ZDpw5yI4TkUIXDgAnEhGCZ9J5X2_Oagz"
57
+ "geMHZrd8rzeyAFQXj0dmYMErcfII7_Rhq5kZ4kAtS0tl9PtaNKKd2m4taIufySXCCstl3iNLMODT"
58
+ "jbsW_KZi8U8DauOdGSAhBd1DCGxvLlAOM.snfkhb0yQiVJcLW8Bv9IeKQac0ar_TKkV6QexqNZYiy"
59
+ "RXnE7E; xla=s4t"
60
+ ),
61
+ "User-Agent": (
62
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
63
+ "(KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0"
64
+ ),
65
+ }
66
+
67
+ _NOISE_SELECTORS = (
68
+ "#comments, .comments-area, #respond, .comments, .related-posts, "
69
+ "footer, script, style, .sidebar, .widget"
70
+ )
71
+
72
+
73
+ def _is_ignored_node(node: Node) -> bool:
74
+ return node.closest(_NOISE_SELECTORS) is not None
75
+
76
+
77
+ class VegaClient(BaseProvider):
78
+ """Pure-Python client for the VegaMovies provider."""
79
+
80
+ name: str = "vega"
81
+ catalog: list[dict[str, str]] = [
82
+ {"title": "New", "filter": ""},
83
+ {"title": "Netflix", "filter": "web-series/netflix"},
84
+ {"title": "Amazon Prime", "filter": "web-series/amazon-prime-video"},
85
+ {"title": "Apple TV+", "filter": "web-series/apple-tv"},
86
+ ]
87
+ genres: list[dict[str, str]] = [
88
+ {"title": "Action", "filter": "category/movies-by-genres/action"},
89
+ {"title": "Adventure", "filter": "category/movies-by-genres/adventure"},
90
+ {"title": "Animation", "filter": "category/movies-by-genres/animation"},
91
+ {"title": "Biography", "filter": "category/movies-by-genres/biography"},
92
+ {"title": "Comedy", "filter": "category/movies-by-genres/comedy"},
93
+ {"title": "Crime", "filter": "category/movies-by-genres/crime"},
94
+ {"title": "Documentary", "filter": "category/movies-by-genres/documentary"},
95
+ {"title": "Drama", "filter": "category/movies-by-genres/drama"},
96
+ {"title": "Family", "filter": "category/movies-by-genres/family"},
97
+ {"title": "Fantasy", "filter": "category/movies-by-genres/fantasy"},
98
+ {"title": "History", "filter": "category/movies-by-genres/history"},
99
+ {"title": "Horror", "filter": "category/movies-by-genres/horror"},
100
+ {"title": "Music", "filter": "category/movies-by-genres/music"},
101
+ {"title": "Mystery", "filter": "category/movies-by-genres/mystery"},
102
+ {"title": "Romance", "filter": "category/movies-by-genres/romance"},
103
+ {"title": "Sci-Fi", "filter": "category/movies-by-genres/sci-fi"},
104
+ {"title": "Sport", "filter": "category/movies-by-genres/sport"},
105
+ {"title": "Thriller", "filter": "category/movies-by-genres/thriller"},
106
+ {"title": "War", "filter": "category/movies-by-genres/war"},
107
+ {"title": "Western", "filter": "category/movies-by-genres/western"},
108
+ ]
109
+ settings_schema: list[dict[str, Any]] = [
110
+ {
111
+ "key": "vega_quickDownload",
112
+ "type": "toggle",
113
+ "label": "Quick Download",
114
+ "description": (
115
+ "Automatically download the preferred server in 1-click without "
116
+ "showing server selection"
117
+ ),
118
+ "defaultValue": True,
119
+ },
120
+ {
121
+ "key": "vega_preferredDownloadServer",
122
+ "type": "select",
123
+ "label": "Preferred Download Server",
124
+ "description": "Server to prioritize for 1-click quick download",
125
+ "options": [
126
+ {"label": "Auto (Best Available)", "value": "auto"},
127
+ {"label": "CF Worker (Fastest)", "value": "cf worker"},
128
+ {"label": "CF Storage (R2 Direct)", "value": "cf storage"},
129
+ {"label": "GDrive (Google Direct)", "value": "gdrive"},
130
+ {"label": "Pixeldrain", "value": "pixeldrain"},
131
+ {"label": "FastDl", "value": "fastdl"},
132
+ {"label": "HubCdn", "value": "hubcdn"},
133
+ ],
134
+ "defaultValue": "auto",
135
+ },
136
+ {
137
+ "key": "vega_skipTimings",
138
+ "type": "toggle",
139
+ "label": "Skip Timings",
140
+ "description": (
141
+ "Automatically fetch intro and recap skip timestamps from "
142
+ "TheIntroDB for verified episodes"
143
+ ),
144
+ "defaultValue": True,
145
+ },
146
+ ]
147
+
148
+ def _base_url(self) -> str:
149
+ return get_base_url("Vega").rstrip("/")
150
+
151
+ def get_posts(self, filter_path: str = "", page: int = 1) -> list[dict[str, str]]:
152
+ base_url = self._base_url()
153
+ url = (
154
+ f"{base_url}/{filter_path}/page/{page}/"
155
+ if filter_path
156
+ else f"{base_url}/page/{page}/"
157
+ )
158
+ try:
159
+ html = self.fetch_text(
160
+ url,
161
+ headers={**_VEGA_HEADERS, "Referer": base_url},
162
+ )
163
+ doc = parse_html(html)
164
+ posts: list[dict[str, str]] = []
165
+ seen: set[int] = set()
166
+ for container in doc.select(
167
+ ".blog-items, .post-list, #archive-container, .movies-grid"
168
+ ):
169
+ for el in container.children_elements():
170
+ if id(el) in seen:
171
+ continue
172
+ if not el.matches("article, .entry-list-item, a"):
173
+ continue
174
+ seen.add(id(el))
175
+
176
+ anchor = el.select_one("a")
177
+ href = (anchor.attr("href") if anchor else "") or el.attr("href")
178
+ if not href:
179
+ continue
180
+
181
+ score_el = el.select_one(".imdb-score, .rating, [class*='score']")
182
+ score_m = re.search(r"(\d+(?:\.\d+)?)", score_el.text()) if score_el else None
183
+ meta_rating = el.select_one('meta[itemprop="ratingValue"]')
184
+ rating = (
185
+ score_m.group(1)
186
+ if score_m
187
+ else (meta_rating.attr("content").strip() if meta_rating else "")
188
+ )
189
+ tag = f"{rating}★" if rating else ""
190
+
191
+ entry_title_el = el.select_one(".entry-title, .poster-title")
192
+ entry_title_raw = (
193
+ entry_title_el.text().replace("Download", "")
194
+ if entry_title_el
195
+ else ""
196
+ )
197
+ title_m = re.search(
198
+ r"^(.*?)\s*\((\d{4})\)|^(.*?)\s*\((Season \d+)\)",
199
+ entry_title_raw,
200
+ )
201
+ post_title_el = el.select_one(".post-title, .poster-title")
202
+ title = (
203
+ title_m.group(0)
204
+ if title_m
205
+ else (
206
+ (anchor.attr("title") if anchor else "").replace("Download", "")
207
+ or (
208
+ post_title_el.text().replace("Download", "")
209
+ if post_title_el
210
+ else ""
211
+ )
212
+ )
213
+ ).strip()
214
+
215
+ img = (anchor.select_one("img") if anchor else None) or el.select_one("img")
216
+ image = ""
217
+ if img:
218
+ image = (
219
+ img.attr("data-lazy-src")
220
+ or img.attr("data-src")
221
+ or img.attr("src")
222
+ )
223
+ if image.startswith("//"):
224
+ image = "https:" + image
225
+
226
+ post: dict[str, str] = {
227
+ "title": title,
228
+ "link": to_relative_path(base_url, href),
229
+ "image": image,
230
+ }
231
+ if tag:
232
+ post["tag"] = tag
233
+ posts.append(post)
234
+ return posts
235
+ except Exception as err:
236
+ throw_provider_error("Vega", "posts", err)
237
+ return []
238
+
239
+ def get_search_posts(self, query: str, page: int = 1) -> list[dict[str, str]]:
240
+ base_url = self._base_url()
241
+ url = f"{base_url}/search.php?q={quote_plus(query)}&page={page}"
242
+ try:
243
+ data = self.fetch_json(
244
+ url,
245
+ headers={**_VEGA_HEADERS, "Referer": base_url},
246
+ )
247
+ posts: list[dict[str, str]] = []
248
+ for hit in (data or {}).get("hits") or []:
249
+ doc_item = hit.get("document") or {}
250
+ permalink = doc_item.get("permalink") or ""
251
+ if not permalink:
252
+ continue
253
+ doc_rating = (
254
+ doc_item.get("rating")
255
+ or doc_item.get("imdbRating")
256
+ or doc_item.get("imdb_rating")
257
+ )
258
+ post: dict[str, str] = {
259
+ "title": str(doc_item.get("post_title", "")).replace("Download", "").strip(),
260
+ "link": to_relative_path(base_url, permalink),
261
+ "image": doc_item.get("post_thumbnail") or "",
262
+ }
263
+ if doc_rating:
264
+ post["tag"] = f"{doc_rating}★"
265
+ posts.append(post)
266
+ return posts
267
+ except Exception as err:
268
+ throw_provider_error("Vega", "search posts", err)
269
+ return []
270
+
271
+ def get_meta(self, link: str) -> dict[str, Any]:
272
+ current_base = self._base_url()
273
+ url = urljoin(f"{current_base}/", link)
274
+ base_url = "/".join(url.split("/")[:3])
275
+ html = self.fetch_text(
276
+ url,
277
+ headers={**_VEGA_HEADERS, "Referer": base_url},
278
+ )
279
+ doc = parse_html(html)
280
+ info_container = doc.select_one(
281
+ ".entry-content, .post-content, .post-inner, .page-body"
282
+ )
283
+
284
+ title_el = doc.select_one("h1.post-title")
285
+ title = title_el.text().strip() if title_el else ""
286
+ if not title and info_container:
287
+ for heading in info_container.select("h3"):
288
+ if _is_ignored_node(heading):
289
+ continue
290
+ next_p = heading.next_element_sibling("p")
291
+ if next_p:
292
+ m = re.search(r"Name: (.+)", next_p.text())
293
+ if m:
294
+ title = m.group(1).strip()
295
+ break
296
+
297
+ imdb_id = ""
298
+ imdb_anchor = doc.select_one('a[href*="imdb.com"]')
299
+ if imdb_anchor:
300
+ m = re.search(r"tt\d+", imdb_anchor.attr("href"))
301
+ if m:
302
+ imdb_id = m.group(0)
303
+ if not imdb_id and info_container:
304
+ for heading in info_container.select("h3"):
305
+ if _is_ignored_node(heading):
306
+ continue
307
+ next_p = heading.next_element_sibling("p")
308
+ if next_p:
309
+ a_tag = next_p.select_one("a")
310
+ if a_tag:
311
+ m = re.search(r"tt\d+", a_tag.attr("href"))
312
+ if m:
313
+ imdb_id = m.group(0)
314
+ break
315
+ if not imdb_id:
316
+ m = re.search(r"tt\d+", info_container.text())
317
+ if m:
318
+ imdb_id = m.group(0)
319
+
320
+ clean_text = f"{title} {info_container.text() if info_container else ''}"
321
+ media_type = "movie"
322
+ is_series = False
323
+ if info_container:
324
+ for heading in info_container.select("h3"):
325
+ if _is_ignored_node(heading):
326
+ continue
327
+ next_p = heading.next_element_sibling("p")
328
+ if "Series Info" in heading.text() or (
329
+ next_p and "Series Name" in next_p.text()
330
+ ):
331
+ is_series = True
332
+ break
333
+ if (
334
+ is_series
335
+ or re.search(r"\b(?:web\s*series|tv\s*series)\b", clean_text, re.I)
336
+ or re.search(r"\bseason\s*\d{1,2}\b", title, re.I)
337
+ or re.search(r"\bs\d{1,2}\s*e\d{1,3}\b", title, re.I)
338
+ or (
339
+ re.search(r"\bseason\s*\d{1,2}\b", clean_text, re.I)
340
+ and not re.search(r"\b(?:full\s*movie|movie\s*info)\b", clean_text, re.I)
341
+ )
342
+ ):
343
+ media_type = "series"
344
+
345
+ synopsis = ""
346
+ for h3 in doc.select("h3"):
347
+ h_txt = h3.text()
348
+ if "SYNOPSIS/PLOT" in h_txt or "Plot" in h_txt:
349
+ next_p = h3.next_element_sibling("p")
350
+ if next_p:
351
+ synopsis = next_p.text().strip()
352
+ break
353
+ if not synopsis and info_container:
354
+ for p_el in info_container.select("p"):
355
+ if _is_ignored_node(p_el):
356
+ continue
357
+ sib_h = p_el.next_element_sibling()
358
+ if sib_h and sib_h.tag in ("h3", "h4"):
359
+ sib_p = sib_h.next_element_sibling("p")
360
+ if sib_p:
361
+ synopsis = sib_p.text().strip()
362
+ break
363
+
364
+ image = ""
365
+ if info_container:
366
+ for attr_name, sel in (
367
+ ("data-src", "img[data-src]"),
368
+ ("data-lazy-src", "img[data-lazy-src]"),
369
+ ("data-orig-src", "img[data-orig-src]"),
370
+ ):
371
+ for img in info_container.select(sel):
372
+ if not _is_ignored_node(img):
373
+ image = img.attr(attr_name)
374
+ break
375
+ if image:
376
+ break
377
+ if not image:
378
+ for img in info_container.select("img"):
379
+ if _is_ignored_node(img):
380
+ continue
381
+ src = img.attr("src")
382
+ if (
383
+ src
384
+ and not src.startswith("data:")
385
+ and "logo" not in src
386
+ and "svg" not in src
387
+ and "placeholder" not in src
388
+ and "icon" not in src
389
+ ):
390
+ image = src
391
+ break
392
+ if image.startswith("//"):
393
+ image = "https:" + image
394
+
395
+ hr = info_container.select_one("hr") if info_container else None
396
+ first_button = doc.select_one(
397
+ ".dwd-button, a[href*='nexdrive'], a[href*='vcloud'], "
398
+ "a[href*='fastdl'], a[href*='hubcloud']"
399
+ )
400
+ if first_button:
401
+ container_p = first_button.closest("p")
402
+ if container_p:
403
+ prev = container_p.prev_element_sibling()
404
+ while prev is not None and prev.tag != "hr":
405
+ prev = prev.prev_element_sibling()
406
+ if prev is not None and prev.tag == "hr":
407
+ hr = prev
408
+
409
+ links: list[dict[str, Any]] = []
410
+ seen_hrefs: set[str] = set()
411
+ cur = hr.next_element_sibling() if hr else None
412
+ while cur is not None:
413
+ el = cur
414
+ cur = cur.next_element_sibling()
415
+ if el.tag in ("hr", "style", "script"):
416
+ continue
417
+
418
+ el_text = el.text()
419
+ if el.select_one("a") and (
420
+ "Instant" in el_text
421
+ or "Resumable" in el_text
422
+ or "Download Now" in el_text
423
+ or "Batch/Zip" in el_text
424
+ or el.select_one(".dwd-button, .btn-outline") is not None
425
+ ):
426
+ continue
427
+
428
+ item_title = re.sub(r"\s+", " ", re.sub(r"[\r\n\t]+", " ", el_text)).strip()
429
+ if not item_title:
430
+ continue
431
+ if re.match(r"^[\s\-_=~*•–—:|]+$", item_title):
432
+ continue
433
+
434
+ lower = item_title.lower()
435
+ if (
436
+ "winding up" in lower
437
+ or "thank you" in lower
438
+ or "telegram" in lower
439
+ or "how to download" in lower
440
+ or "join our" in lower
441
+ or lower == "download now"
442
+ ):
443
+ continue
444
+
445
+ q_m = re.search(r"\d+p\b", item_title, re.I)
446
+ quality = q_m.group(0) if q_m else ""
447
+
448
+ if (
449
+ not quality
450
+ and not re.search(r"episodes?\s*[:\d\-]", item_title, re.I)
451
+ and not re.search(r"\[.*(?:mb|gb|e).*\]", item_title, re.I)
452
+ ):
453
+ next_el = el.next_element_sibling()
454
+ if next_el is not None and (
455
+ next_el.tag in ("h1", "h2", "h3", "h4", "h5", "h6", "strong")
456
+ or (next_el.tag == "p" and next_el.select_one("strong") is not None)
457
+ ):
458
+ continue
459
+
460
+ item_title = re.sub(
461
+ r"^[\s•\-*—_:=~|]+|[\s•\-*—_:=~|]+$", "", item_title
462
+ ).strip()
463
+ if not item_title:
464
+ continue
465
+
466
+ next_p = el.next_element_sibling()
467
+ while (
468
+ next_p is not None
469
+ and next_p.tag != "hr"
470
+ and next_p.select_one("a[href]") is None
471
+ ):
472
+ next_p = next_p.next_element_sibling()
473
+
474
+ if next_p is None or next_p.tag == "hr":
475
+ continue
476
+
477
+ btn: Node | None = None
478
+ if media_type == "series":
479
+ btn = next_p.select_one(
480
+ "a:contains('V-Cloud'), a:contains('vcloud'), a[href*='vcloud']"
481
+ )
482
+ if btn is None:
483
+ for a_tag in next_p.select("a"):
484
+ txt = a_tag.text().lower()
485
+ href_l = a_tag.attr("href").lower()
486
+ if (
487
+ "zip" not in txt
488
+ and "batch" not in txt
489
+ and "zip" not in href_l
490
+ and "batch" not in href_l
491
+ ):
492
+ btn = a_tag
493
+ break
494
+ else:
495
+ btn = next_p.select_one(
496
+ "a:contains('V-Cloud'), a:contains('vcloud'), a[href*='vcloud']"
497
+ )
498
+ if btn is None:
499
+ btn = next_p.select_one(
500
+ "a:contains('G-Direct'), a:contains('Direct'), a[href*='fastdl']"
501
+ )
502
+ if btn is None:
503
+ outline = next_p.select_one(".dwd-button, .btn-outline")
504
+ if outline is not None and outline.parent is not None:
505
+ btn = outline.parent
506
+ if btn is None or not btn.attr("href"):
507
+ btn = next_p.select_one("a[href]")
508
+
509
+ if btn is None:
510
+ continue
511
+
512
+ btn_href = btn.attr("href")
513
+ if not btn_href or btn_href in ("/", "#") or btn_href in seen_hrefs:
514
+ continue
515
+ seen_hrefs.add(btn_href)
516
+
517
+ if media_type == "series":
518
+ links.append(
519
+ {
520
+ "title": item_title,
521
+ "episodesLink": btn_href,
522
+ "quality": quality,
523
+ }
524
+ )
525
+ else:
526
+ links.append(
527
+ {
528
+ "title": item_title,
529
+ "directLinks": [
530
+ {"title": "Movie", "link": btn_href, "type": "movie"}
531
+ ],
532
+ "quality": quality,
533
+ }
534
+ )
535
+
536
+ quick_download = self.kv.get("vega_quickDownload", True)
537
+ formatted_links = [
538
+ {**item, "title": format_season_title(item["title"])} for item in links
539
+ ]
540
+ website_info: dict[str, Any] = {
541
+ "title": title,
542
+ "synopsis": synopsis,
543
+ "image": image,
544
+ "imdbId": imdb_id or "",
545
+ "type": media_type,
546
+ "quickDownload": True if quick_download is None else bool(quick_download),
547
+ "linkList": formatted_links,
548
+ "webUrl": url,
549
+ }
550
+
551
+ if not imdb_id:
552
+ return website_info
553
+
554
+ try:
555
+ cinemeta = get_cinemeta_meta(imdb_id, media_type, self.session)
556
+ if cinemeta:
557
+ if media_type == "series" and cinemeta.get("type") == "series":
558
+ updated_list: list[dict[str, Any]] = []
559
+ for item in website_info["linkList"]:
560
+ ep_link = item.get("episodesLink")
561
+ if not ep_link:
562
+ updated_list.append(item)
563
+ continue
564
+ season_num = get_cinemeta_season(item["title"])
565
+ if not season_num:
566
+ updated_list.append(item)
567
+ continue
568
+ updated_list.append(
569
+ {
570
+ **item,
571
+ "episodesLink": add_cinemeta_context(
572
+ urljoin(url, ep_link), imdb_id, season_num
573
+ ),
574
+ }
575
+ )
576
+ website_info["linkList"] = updated_list
577
+ return apply_cinemeta_meta(website_info, cinemeta)
578
+ except Exception:
579
+ pass
580
+ return website_info
581
+
582
+ def get_episodes(
583
+ self,
584
+ url: str,
585
+ imdb_id: str = "",
586
+ season: int | None = None,
587
+ ) -> list[dict[str, Any]]:
588
+ try:
589
+ req_url, ctx_imdb, ctx_season = read_cinemeta_context(url)
590
+ eff_imdb = ctx_imdb or imdb_id
591
+ eff_season = ctx_season if ctx_season is not None else season
592
+
593
+ html = self.fetch_text(req_url, headers=_EPISODE_HEADERS)
594
+ doc = parse_html(html)
595
+ container = doc.select_one(".entry-content, .entry-inner")
596
+ episodes: list[dict[str, Any]] = []
597
+ seen_titles: set[str] = set()
598
+
599
+ if container is not None:
600
+ for el in container.select("h3, h4, h5, p"):
601
+ if el.closest(".unili-content, .code-block-1") is not None:
602
+ continue
603
+ text = el.text().strip()
604
+ if not (
605
+ re.search(r"episodes?\s*[:\d\-]", text, re.I)
606
+ or re.search(r"e\d{1,3}\b", text, re.I)
607
+ or re.match(r"^episode\s*\d+", text, re.I)
608
+ ):
609
+ continue
610
+
611
+ ep_title = re.sub(r"\s+", " ", text).strip()
612
+ ep_title = re.sub(r"^[-:\s]+|[-:\s]+$", "", ep_title)
613
+ ep_title = re.sub(r"^episodes?\s*:\s*", "Episode ", ep_title, flags=re.I)
614
+
615
+ next_p = el.next_element_sibling()
616
+ while (
617
+ next_p is not None
618
+ and next_p.tag != "p"
619
+ and next_p.select_one("a[href]") is None
620
+ ):
621
+ next_p = next_p.next_element_sibling()
622
+
623
+ if next_p is None:
624
+ continue
625
+
626
+ vcloud_el = next_p.select_one("a[href*='vcloud'], a[href*='hubcloud']")
627
+ vegadrive_el = next_p.select_one("a[href*='vegadrive']")
628
+ vcloud_link = vcloud_el.attr("href") if vcloud_el else ""
629
+ vegadrive_link = vegadrive_el.attr("href") if vegadrive_el else ""
630
+
631
+ if vcloud_link and vegadrive_link:
632
+ ep_link = json.dumps(
633
+ {"hubcloud": vcloud_link, "vegadrive": vegadrive_link}
634
+ )
635
+ else:
636
+ fastdl_el = next_p.select_one("a[href*='fastdl']")
637
+ outline_el = next_p.select_one(".btn-outline")
638
+ outline_parent_href = (
639
+ outline_el.parent.attr("href")
640
+ if outline_el is not None and outline_el.parent is not None
641
+ else ""
642
+ )
643
+ first_a = next_p.select_one("a[href]")
644
+ ep_link = (
645
+ vcloud_link
646
+ or vegadrive_link
647
+ or (fastdl_el.attr("href") if fastdl_el else "")
648
+ or outline_parent_href
649
+ or (outline_el.attr("href") if outline_el else "")
650
+ or (first_a.attr("href") if first_a else "")
651
+ or ""
652
+ )
653
+
654
+ if ep_title and ep_link and ep_title not in seen_titles:
655
+ seen_titles.add(ep_title)
656
+ episodes.append({"title": ep_title, "link": ep_link})
657
+
658
+ quick_download = self.kv.get("vega_quickDownload", True)
659
+ qd_val = True if quick_download is None else bool(quick_download)
660
+ skip_timings = self.kv.get("vega_skipTimings", True)
661
+ st_val = True if skip_timings is None else bool(skip_timings)
662
+
663
+ if not eff_imdb or not eff_season:
664
+ return [{**ep, "quickDownload": qd_val} for ep in episodes]
665
+
666
+ enriched = episodes
667
+ try:
668
+ cinemeta = get_cinemeta_meta(eff_imdb, "series", self.session)
669
+ if cinemeta:
670
+ enriched = enrich_cinemeta_episodes(
671
+ episodes, cinemeta.get("videos") or [], eff_season
672
+ )
673
+ except Exception:
674
+ pass
675
+
676
+ if st_val:
677
+ try:
678
+ enriched = enrich_episodes_with_skip_timings(
679
+ enriched, eff_imdb, eff_season, self.session
680
+ )
681
+ except Exception:
682
+ pass
683
+
684
+ return [{**ep, "quickDownload": qd_val} for ep in enriched]
685
+ except Exception as err:
686
+ throw_provider_error("Vega", "episodes", err)
687
+ return []
688
+
689
+ def get_stream(
690
+ self,
691
+ url: str,
692
+ is_download: bool = False,
693
+ media_type: str = "movie",
694
+ ) -> list[dict[str, Any]]:
695
+ try:
696
+ stream_links: list[dict[str, Any]] = []
697
+ seen_links: set[str] = set()
698
+
699
+ def _add_streams(items: list[dict[str, Any]]) -> None:
700
+ for item in items:
701
+ s_link = item.get("link") or ""
702
+ if s_link and s_link not in seen_links:
703
+ seen_links.add(s_link)
704
+ stream_links.append(item)
705
+
706
+ hubcloud_url = url
707
+ vegadrive_url = ""
708
+ if url.startswith("{") and url.endswith("}"):
709
+ try:
710
+ parsed = json.loads(url)
711
+ if parsed.get("hubcloud"):
712
+ hubcloud_url = parsed["hubcloud"]
713
+ if parsed.get("vegadrive"):
714
+ vegadrive_url = parsed["vegadrive"]
715
+ except Exception:
716
+ pass
717
+ elif "vegadrive" in url or "one.vegadrive" in url:
718
+ vegadrive_url = url
719
+ hubcloud_url = ""
720
+
721
+ if vegadrive_url:
722
+ try:
723
+ _add_streams(vegadrive_extractor(vegadrive_url, self.session))
724
+ except Exception:
725
+ pass
726
+
727
+ if not hubcloud_url and stream_links:
728
+ return stream_links
729
+
730
+ link = hubcloud_url
731
+ if "cloud" not in link:
732
+ try:
733
+ referer = "/".join(link.split("/")[:3])
734
+ dotlink_text = self.fetch_text(
735
+ link, headers={"Referer": referer}, timeout=10
736
+ )
737
+ doc = parse_html(dotlink_text)
738
+
739
+ g_direct_el = doc.select_one(
740
+ "a:contains('G-Direct'), a:contains('Instant'), a[href*='fastdl']"
741
+ )
742
+ g_direct_link = g_direct_el.attr("href") if g_direct_el else ""
743
+ if g_direct_link:
744
+ try:
745
+ fastdl_html = self.fetch_text(
746
+ g_direct_link, headers={"Referer": link}, timeout=10
747
+ )
748
+ m = re.search(r"""reurl\s*=\s*["']([^"']+)["']""", fastdl_html)
749
+ if m:
750
+ raw_target = m.group(1)
751
+ target_url = (
752
+ unquote(raw_target.split("link=", 1)[1])
753
+ if "link=" in raw_target
754
+ else raw_target
755
+ )
756
+ if (
757
+ "googleusercontent.com" in target_url
758
+ or target_url.startswith("http")
759
+ ):
760
+ _add_streams(
761
+ [
762
+ {
763
+ "server": "Instant (Google CDN)",
764
+ "link": target_url,
765
+ "type": "mkv",
766
+ }
767
+ ]
768
+ )
769
+ except Exception:
770
+ pass
771
+
772
+ vd_el = doc.select_one(
773
+ "a:contains('Vega Drive'), a[href*='vegadrive']"
774
+ )
775
+ page_vd_link = vd_el.attr("href") if vd_el else ""
776
+ if page_vd_link:
777
+ try:
778
+ _add_streams(vegadrive_extractor(page_vd_link, self.session))
779
+ except Exception:
780
+ pass
781
+
782
+ vcloud_el = doc.select_one(
783
+ "a:contains('V-Cloud'), a[href*='vcloud'], a[href*='hubcloud']"
784
+ )
785
+ vlink = vcloud_el.attr("href") if vcloud_el else ""
786
+ if not vlink:
787
+ m = re.search(
788
+ r'<a\s+href="([^"]*cloud\.[^"]*)"', dotlink_text, re.I
789
+ )
790
+ if m:
791
+ vlink = m.group(1)
792
+ if vlink:
793
+ try:
794
+ _add_streams(
795
+ hubcloud_extractor(
796
+ vlink,
797
+ self.session,
798
+ is_download=is_download,
799
+ provider_value="vega",
800
+ kv_store=self.kv,
801
+ )
802
+ )
803
+ except Exception:
804
+ pass
805
+
806
+ fp_el = doc.select_one(
807
+ '.btn.btn-sm.btn-outline[style*="rgb(252,185,0)"], '
808
+ 'a:contains("Filepress"), a[href*="filepress"], a[href*="filebee"]'
809
+ )
810
+ fp_link = ""
811
+ if fp_el is not None:
812
+ fp_link = fp_el.attr("href") or (
813
+ fp_el.parent.attr("href") if fp_el.parent is not None else ""
814
+ )
815
+ if fp_link:
816
+ try:
817
+ fp_id = fp_link.rstrip("/").split("/")[-1]
818
+ fp_base = "/".join(fp_link.split("/")[:-2])
819
+ token_res = self.fetch_json(
820
+ f"{fp_base}/api/file/downlaod/",
821
+ method="POST",
822
+ json_body={
823
+ "id": fp_id,
824
+ "method": "indexDownlaod",
825
+ "captchaValue": None,
826
+ },
827
+ headers={
828
+ "Content-Type": "application/json",
829
+ "Referer": fp_base,
830
+ },
831
+ timeout=10,
832
+ )
833
+ if isinstance(token_res, dict) and token_res.get("status"):
834
+ fp_token = token_res.get("data")
835
+ stream_res = self.fetch_json(
836
+ f"{fp_base}/api/file/downlaod2/",
837
+ method="POST",
838
+ json_body={
839
+ "id": fp_token,
840
+ "method": "indexDownlaod",
841
+ "captchaValue": None,
842
+ },
843
+ headers={
844
+ "Content-Type": "application/json",
845
+ "Referer": fp_base,
846
+ },
847
+ timeout=10,
848
+ )
849
+ data_list = (
850
+ stream_res.get("data")
851
+ if isinstance(stream_res, dict)
852
+ else None
853
+ )
854
+ if isinstance(data_list, list) and data_list:
855
+ _add_streams(
856
+ [
857
+ {
858
+ "server": "filepress",
859
+ "link": data_list[0],
860
+ "type": "mkv",
861
+ }
862
+ ]
863
+ )
864
+ except Exception:
865
+ pass
866
+ except Exception:
867
+ pass
868
+ else:
869
+ _add_streams(
870
+ hubcloud_extractor(
871
+ link,
872
+ self.session,
873
+ is_download=is_download,
874
+ provider_value="vega",
875
+ kv_store=self.kv,
876
+ )
877
+ )
878
+
879
+ if stream_links:
880
+ return stream_links
881
+
882
+ return hubcloud_extractor(
883
+ link,
884
+ self.session,
885
+ is_download=is_download,
886
+ provider_value="vega",
887
+ kv_store=self.kv,
888
+ )
889
+ except Exception as err:
890
+ throw_provider_error("Vega", "stream", err)
891
+ return []