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,649 @@
1
+ """Pure-Python implementation of the Vega 'animesalt' provider."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import base64
6
+ import json
7
+ import re
8
+ from concurrent.futures import ThreadPoolExecutor
9
+ from typing import Any
10
+ from urllib.parse import parse_qs, quote, unquote, urljoin, urlparse
11
+
12
+ from ..html import parse_html
13
+ from .common import COMMON_HEADERS, BaseProvider, get_base_url
14
+ from .common.extractors import abbasy_extractor, zypter_extractor
15
+
16
+ _POST_HEADERS = {
17
+ "Referer": "https://www.google.com",
18
+ "User-Agent": (
19
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
20
+ "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
21
+ ),
22
+ "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
23
+ "Accept-Language": "en-US,en;q=0.9",
24
+ "Pragma": "no-cache",
25
+ "Cache-Control": "no-cache",
26
+ }
27
+
28
+ _META_HEADERS = {
29
+ "Accept": (
30
+ "text/html,application/xhtml+xml,application/xml;q=0.9,"
31
+ "image/avif,image/webp,image/apng,*/*;q=0.8,signed-exchange;v=b3;q=0.7"
32
+ ),
33
+ "Cache-Control": "no-store",
34
+ "Accept-Language": "en-US,en;q=0.9",
35
+ "DNT": "1",
36
+ "Cookie": (
37
+ "xla=s4t; _ga=GA1.1.1081149560.1756378968; "
38
+ "_ga_BLZGKYN5PF=GS2.1.s1756378968$o1$g1$t1756378984$j44$l0$h0"
39
+ ),
40
+ "Upgrade-Insecure-Requests": "1",
41
+ "User-Agent": (
42
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
43
+ "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
44
+ ),
45
+ }
46
+
47
+ _EP_HEADERS = {
48
+ "Accept": (
49
+ "text/html,application/xhtml+xml,application/xml;q=0.9,"
50
+ "image/avif,image/webp,image/apng,*/*;q=0.8"
51
+ ),
52
+ "Accept-Language": "en-US,en;q=0.9",
53
+ "User-Agent": (
54
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
55
+ "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
56
+ ),
57
+ }
58
+
59
+ _ZYPTER_HOSTS = ("zephyrix.org", "zephyr", "ravok.buzz", "ravok")
60
+ _ABYSS_MARKERS = ("abyssplayer", "abysssplayer", "dub-player", "/plyr/player.php")
61
+
62
+
63
+ def _make_absolute(url: str, base: str) -> str:
64
+ if not url:
65
+ return ""
66
+ if url.startswith(("http://", "https://")):
67
+ return url
68
+ return urljoin(base, url)
69
+
70
+
71
+ def _decode_base64_utf8(data: str) -> str:
72
+ try:
73
+ padded = data + "=" * (-len(data) % 4)
74
+ return base64.b64decode(padded).decode("utf-8", errors="replace")
75
+ except Exception:
76
+ return ""
77
+
78
+
79
+ class AnimesaltClient(BaseProvider):
80
+ """Pure-Python implementation of the Vega 'animesalt' provider."""
81
+
82
+ name = "animesalt"
83
+ catalog = [
84
+ {"title": "Trending", "filter": ""},
85
+ {"title": "Series", "filter": "series"},
86
+ {"title": "Movies", "filter": "movies"},
87
+ ]
88
+ genres: list[dict[str, str]] = []
89
+ settings_schema = [
90
+ {
91
+ "key": "audio",
92
+ "type": "select",
93
+ "label": "Audio Language",
94
+ "description": "Preferred audio track when multiple are available",
95
+ "options": [
96
+ {"label": "Hindi", "value": "hindi"},
97
+ {"label": "English", "value": "english"},
98
+ {"label": "Tamil", "value": "tamil"},
99
+ {"label": "Telugu", "value": "telugu"},
100
+ {"label": "Japanese", "value": "japanese"},
101
+ {"label": "Dual Audio", "value": "dual"},
102
+ ],
103
+ "defaultValue": "hindi",
104
+ },
105
+ {
106
+ "key": "quality",
107
+ "type": "select",
108
+ "label": "Preferred Quality",
109
+ "options": [
110
+ {"label": "1080p", "value": "1080p"},
111
+ {"label": "720p", "value": "720p"},
112
+ {"label": "480p", "value": "480p"},
113
+ ],
114
+ "defaultValue": "1080p",
115
+ },
116
+ {
117
+ "key": "autoPlay",
118
+ "type": "toggle",
119
+ "label": "Auto Play",
120
+ "defaultValue": True,
121
+ },
122
+ {
123
+ "key": "baseUrl",
124
+ "type": "text",
125
+ "label": "Base URL",
126
+ "description": "Override default domain if it changes",
127
+ "defaultValue": "https://animesalt.in",
128
+ "placeholder": "https://animesalt.in",
129
+ },
130
+ {
131
+ "key": "requestTimeout",
132
+ "type": "number",
133
+ "label": "Request Timeout (ms)",
134
+ "defaultValue": 30000,
135
+ "min": 5000,
136
+ "max": 120000,
137
+ },
138
+ ]
139
+
140
+ def _fetch_posts(
141
+ self, filter_path: str = "", query: str = "", page: int = 1
142
+ ) -> list[dict[str, str]]:
143
+ if page > 1:
144
+ return []
145
+ try:
146
+ base_url = (get_base_url("animesalt", session=self.session) or "https://animesalt.in").rstrip("/")
147
+ url = (
148
+ f"{base_url}/search.php?search={quote(query.strip())}"
149
+ if query.strip()
150
+ else base_url
151
+ )
152
+ doc = self.fetch_html(url, headers=_POST_HEADERS)
153
+
154
+ container = doc.select_one("body") or doc
155
+ if not query:
156
+ if filter_path and re.search(r"series", filter_path, re.I):
157
+ pattern = r"series"
158
+ elif filter_path and re.search(r"movie", filter_path, re.I):
159
+ pattern = r"movie"
160
+ else:
161
+ pattern = r"recent"
162
+ for h2 in doc.select("h2"):
163
+ if re.search(pattern, h2.text(), re.I):
164
+ sec = h2.closest("section")
165
+ if sec:
166
+ container = sec
167
+ break
168
+
169
+ post_selectors = (
170
+ ".anime-blog, article, li.post, .swiper-slide li, "
171
+ ".latest-movies-series-swiper-slide li, ul.post-lst li"
172
+ )
173
+ seen: set[str] = set()
174
+ posts: list[dict[str, str]] = []
175
+ for card in container.select(post_selectors):
176
+ raw_link = ""
177
+ for sel in (
178
+ ".action-overlay a[href]",
179
+ "a.lnk-blk[href]",
180
+ "a[href*='/series/'], a[href*='/movies/']",
181
+ "a[href]",
182
+ ):
183
+ el = card.select_one(sel)
184
+ if el and el.attr("href"):
185
+ raw_link = el.attr("href")
186
+ break
187
+ if not raw_link:
188
+ continue
189
+ link = raw_link if raw_link.startswith("http") else urljoin(f"{base_url}/", raw_link)
190
+ if link in seen:
191
+ continue
192
+
193
+ img_el = card.select_one("img")
194
+ a_els = card.select("a[href]")
195
+ h2_t = card.select_one("h2.entry-title")
196
+ et_t = card.select_one(".entry-title")
197
+ p_t = card.select_one("p[style*='medium']")
198
+ title = (
199
+ (img_el.attr("alt").strip() if img_el else "")
200
+ or (h2_t.text().strip() if h2_t else "")
201
+ or (et_t.text().strip() if et_t else "")
202
+ or (p_t.text().strip() if p_t else "")
203
+ or (a_els[-1].text().strip() if a_els else "")
204
+ )
205
+ title = re.sub(r"^Play Now\s*", "", title, flags=re.I)
206
+ title = re.sub(r"^Image\s+", "", title, flags=re.I).strip()
207
+ if not title:
208
+ continue
209
+
210
+ raw_img = (img_el.attr("data-src") or img_el.attr("src")) if img_el else ""
211
+ image = (
212
+ (raw_img if raw_img.startswith("http") else urljoin(f"{base_url}/", raw_img))
213
+ if raw_img
214
+ else ""
215
+ )
216
+ seen.add(link)
217
+ posts.append({"title": title, "link": link, "image": image})
218
+ return posts
219
+ except Exception:
220
+ return []
221
+
222
+ def get_posts(self, filter_path: str = "", page: int = 1) -> list[dict[str, str]]:
223
+ return self._fetch_posts(filter_path=filter_path, page=page)
224
+
225
+ def get_search_posts(self, query: str, page: int = 1) -> list[dict[str, str]]:
226
+ return self._fetch_posts(query=query, page=page)
227
+
228
+ def get_meta(self, link: str) -> dict[str, Any]:
229
+ empty: dict[str, Any] = {
230
+ "title": "",
231
+ "synopsis": "",
232
+ "image": "",
233
+ "imdbId": "",
234
+ "type": "series",
235
+ "linkList": [],
236
+ }
237
+ try:
238
+ doc = self.fetch_html(link, headers=_META_HEADERS)
239
+ title_el = (
240
+ doc.select_one(".dfxb.alg-cr .entry-title")
241
+ or doc.select_one("h1.entry-title")
242
+ or doc.select_one("h1.post-title")
243
+ or doc.select_one("title")
244
+ )
245
+ title = title_el.text().strip() if title_el else ""
246
+
247
+ img_el = doc.select_one(".dfxb.alg-cr img[alt]") or doc.select_one("figure img")
248
+ image = img_el.attr("src") if img_el else ""
249
+ if image.startswith("//"):
250
+ image = f"https:{image}"
251
+
252
+ syn_el = doc.select_one(".description p") or doc.select_one(".entry-content p")
253
+ synopsis = syn_el.text().strip() if syn_el else ""
254
+
255
+ is_movie = "/movies/" in link or "/movie/" in link
256
+ if is_movie:
257
+ return {
258
+ "title": title,
259
+ "synopsis": synopsis,
260
+ "image": image,
261
+ "imdbId": "",
262
+ "type": "movie",
263
+ "linkList": [
264
+ {
265
+ "title": title or "Play Movie",
266
+ "quality": "Movie",
267
+ "directLinks": [{"title": "Play", "link": link, "type": "movie"}],
268
+ "episodesLink": f"watchanimeworld://movie?url={quote(link, safe='')}",
269
+ }
270
+ ],
271
+ }
272
+
273
+ seasons: set[int] = set()
274
+ for el in doc.select(".season-buttons a.season-btn, .choose-season .aa-cnt li a"):
275
+ ds = el.attr("data-season")
276
+ if ds.isdigit() and int(ds) > 0:
277
+ seasons.add(int(ds))
278
+ for el in doc.select("#episode_by_temp .post.episodes"):
279
+ h2 = el.select_one("h2.entry-title")
280
+ m = re.search(r"(\d+)x(\d+)", h2.text() if h2 else "")
281
+ if m:
282
+ seasons.add(int(m.group(1)))
283
+ for el in doc.select("a[href*='/episode/']"):
284
+ m = re.search(r"(\d+)x(\d+)", el.attr("href"))
285
+ if m:
286
+ seasons.add(int(m.group(1)))
287
+
288
+ sorted_seasons = sorted(seasons)
289
+ link_list: list[dict[str, Any]] = []
290
+ if not sorted_seasons:
291
+ link_list.append(
292
+ {
293
+ "title": title or "Watch",
294
+ "quality": "Series",
295
+ "episodesLink": link,
296
+ "directLinks": [],
297
+ }
298
+ )
299
+ else:
300
+ for s in sorted_seasons:
301
+ link_list.append(
302
+ {
303
+ "title": f"Season {s}",
304
+ "quality": f"S{s}",
305
+ "episodesLink": f"watchanimeworld://season?url={quote(link, safe='')}&season={s}",
306
+ "directLinks": [],
307
+ }
308
+ )
309
+
310
+ return {
311
+ "title": title,
312
+ "synopsis": synopsis,
313
+ "image": image,
314
+ "imdbId": "",
315
+ "type": "series",
316
+ "linkList": link_list,
317
+ }
318
+ except Exception:
319
+ return empty
320
+
321
+ def get_episodes(
322
+ self,
323
+ url: str,
324
+ imdb_id: str = "",
325
+ season: int | None = None,
326
+ ) -> list[dict[str, Any]]:
327
+ page_url = url
328
+ target_season = 0
329
+ is_movie = False
330
+
331
+ if url.startswith("watchanimeworld://movie"):
332
+ qs = parse_qs(urlparse(url).query)
333
+ page_url = unquote(qs.get("url", [""])[0])
334
+ is_movie = True
335
+ elif url.startswith("watchanimeworld://season"):
336
+ qs = parse_qs(urlparse(url).query)
337
+ page_url = unquote(qs.get("url", [""])[0])
338
+ s_val = qs.get("season", ["0"])[0]
339
+ target_season = int(s_val) if s_val.isdigit() else 0
340
+ elif "/movies/" in url or "/movie/" in url:
341
+ is_movie = True
342
+
343
+ if not page_url:
344
+ return []
345
+
346
+ try:
347
+ doc = self.fetch_html(page_url, headers=_EP_HEADERS)
348
+ parsed_page = urlparse(page_url)
349
+ origin = f"{parsed_page.scheme}://{parsed_page.netloc}"
350
+
351
+ if is_movie:
352
+ movie_links: list[dict[str, Any]] = []
353
+ seen_links: set[str] = set()
354
+ for sel in (
355
+ ".server-list li a",
356
+ ".servers-list li a",
357
+ "ul#player-list li a",
358
+ ".mirror",
359
+ ".play-button a",
360
+ ".player-options li a",
361
+ ".options-list li a",
362
+ ):
363
+ for el in doc.select(sel):
364
+ href = el.attr("href") or el.attr("data-url")
365
+ if not href:
366
+ continue
367
+ full = href if href.startswith("http") else urljoin(page_url, href)
368
+ if full == page_url or full.endswith("#") or full in seen_links:
369
+ continue
370
+ seen_links.add(full)
371
+ label = el.text().strip() or el.attr("title").strip() or "Play Movie"
372
+ movie_links.append({"title": label, "link": full})
373
+ if not movie_links:
374
+ movie_links.append({"title": "Play", "link": page_url})
375
+ return movie_links
376
+
377
+ post_el = doc.select_one(
378
+ ".season-buttons a.season-btn[data-post], a.season-btn[data-post]"
379
+ )
380
+ post_id = post_el.attr("data-post") if post_el else ""
381
+ if not post_id:
382
+ art = doc.select_one("article.post")
383
+ if art and art.attr("id"):
384
+ post_id = art.attr("id").replace("post-", "")
385
+
386
+ def extract_ep_info(title_text: str, num_epi_text: str) -> tuple[int, int] | None:
387
+ m = re.search(r"(\d+)x(\d+)", title_text)
388
+ if m:
389
+ return int(m.group(1)), int(m.group(2))
390
+ if num_epi_text.strip().isdigit():
391
+ return (target_season or 1), int(num_epi_text.strip())
392
+ return None
393
+
394
+ episodes: list[dict[str, Any]] = []
395
+
396
+ if post_id and target_season:
397
+ try:
398
+ resp = self.session.get(
399
+ f"{origin}/wp-admin/admin-ajax.php",
400
+ params={
401
+ "action": "action_select_season",
402
+ "season": target_season,
403
+ "post": post_id,
404
+ },
405
+ headers={
406
+ **_EP_HEADERS,
407
+ "Referer": page_url,
408
+ "X-Requested-With": "XMLHttpRequest",
409
+ },
410
+ timeout=self.timeout,
411
+ )
412
+ resp.raise_for_status()
413
+ ajax_html = ""
414
+ try:
415
+ j = resp.json()
416
+ if isinstance(j, dict):
417
+ ajax_html = j.get("data") or j.get("html") or j.get("episodes") or ""
418
+ except Exception:
419
+ ajax_html = resp.text
420
+
421
+ if isinstance(ajax_html, str) and ajax_html.strip():
422
+ a_doc = parse_html(ajax_html)
423
+ for art in a_doc.select("li article.episodes, li article.post.episodes"):
424
+ a_el = art.select_one("a.lnk-blk") or art.select_one("a")
425
+ href = a_el.attr("href") if a_el else ""
426
+ if not href:
427
+ continue
428
+ h2 = art.select_one("h2.entry-title")
429
+ ne = art.select_one(".num-epi")
430
+ info = extract_ep_info(
431
+ h2.text().strip() if h2 else "",
432
+ ne.text().strip() if ne else "",
433
+ )
434
+ if not info:
435
+ continue
436
+ if target_season and info[0] != target_season:
437
+ continue
438
+ episodes.append(
439
+ {
440
+ "title": f"Episode {info[1]}",
441
+ "link": href if href.startswith("http") else urljoin(page_url, href),
442
+ }
443
+ )
444
+ except Exception:
445
+ pass
446
+
447
+ if not episodes:
448
+ for li in doc.select("#episode_by_temp li"):
449
+ art = li.select_one("article.episodes, article.post.episodes")
450
+ if not art:
451
+ continue
452
+ a_el = art.select_one("a.lnk-blk")
453
+ href = a_el.attr("href") if a_el else ""
454
+ if not href:
455
+ continue
456
+ h2 = art.select_one("h2.entry-title")
457
+ ne = art.select_one(".num-epi")
458
+ info = extract_ep_info(
459
+ h2.text().strip() if h2 else "",
460
+ ne.text().strip() if ne else "",
461
+ )
462
+ if not info:
463
+ continue
464
+ if target_season and info[0] != target_season:
465
+ continue
466
+ episodes.append(
467
+ {
468
+ "title": f"Episode {info[1]}",
469
+ "link": href if href.startswith("http") else urljoin(page_url, href),
470
+ }
471
+ )
472
+
473
+ if not episodes:
474
+ for el in doc.select("a[href*='/episode/']"):
475
+ href = el.attr("href")
476
+ if not href:
477
+ continue
478
+ full = href if href.startswith("http") else urljoin(page_url, href)
479
+ m = re.search(r"(\d+)x(\d+)", full, re.I) or re.search(
480
+ r"episode[/-](\d+)", full, re.I
481
+ )
482
+ ep_num, s_num = 0, 1
483
+ if m:
484
+ if m.lastindex and m.lastindex >= 2:
485
+ s_num, ep_num = int(m.group(1)), int(m.group(2))
486
+ else:
487
+ ep_num = int(m.group(1))
488
+ if target_season and s_num and s_num != target_season:
489
+ continue
490
+ label = f"Episode {ep_num}" if ep_num else (el.text().strip() or "Episode")
491
+ episodes.append({"title": label, "link": full})
492
+
493
+ episodes.sort(
494
+ key=lambda e: int(m.group(0)) if (m := re.search(r"\d+", e["title"])) else 0
495
+ )
496
+ seen: set[str] = set()
497
+ unique: list[dict[str, Any]] = []
498
+ for e in episodes:
499
+ if e["link"] not in seen:
500
+ seen.add(e["link"])
501
+ unique.append(e)
502
+ return unique
503
+ except Exception:
504
+ return []
505
+
506
+ def _plyr_wrapper_extractor(self, player_url: str) -> list[dict[str, Any]]:
507
+ options: list[tuple[str, str]] = []
508
+ try:
509
+ data_param = parse_qs(urlparse(player_url).query).get("data", [""])[0]
510
+ if data_param:
511
+ decoded = _decode_base64_utf8(data_param)
512
+ if decoded:
513
+ parsed = json.loads(decoded)
514
+ if isinstance(parsed, list):
515
+ for item in parsed:
516
+ if isinstance(item, dict) and item.get("link"):
517
+ options.append(
518
+ (str(item.get("language") or "").strip(), str(item["link"]).strip())
519
+ )
520
+ except Exception:
521
+ pass
522
+
523
+ if not options:
524
+ try:
525
+ doc = self.fetch_html(player_url, headers=COMMON_HEADERS, timeout=8)
526
+ for el in doc.select(".modal-option"):
527
+ lnk = el.attr("data-link").strip()
528
+ if lnk:
529
+ options.append((el.attr("data-language").strip(), lnk))
530
+ except Exception:
531
+ pass
532
+
533
+ if not options:
534
+ return []
535
+
536
+ def _extract_opt(opt: tuple[str, str]) -> list[dict[str, Any]]:
537
+ lang, lnk = opt
538
+ try:
539
+ res = abbasy_extractor(lnk, session=self.session)
540
+ if lang:
541
+ for s in res:
542
+ s["server"] = f"{lang} • {s.get('server', '')}"
543
+ return res
544
+ except Exception:
545
+ return []
546
+
547
+ merged: list[dict[str, Any]] = []
548
+ with ThreadPoolExecutor(max_workers=min(len(options), 6)) as pool:
549
+ for batch in pool.map(_extract_opt, options):
550
+ merged.extend(batch)
551
+
552
+ seen: set[str] = set()
553
+ return [s for s in merged if s.get("link") and not (s["link"] in seen or seen.add(s["link"]))]
554
+
555
+ def _get_episode_streams(self, url: str) -> list[dict[str, Any]]:
556
+ try:
557
+ doc = self.fetch_html(url, headers=COMMON_HEADERS, timeout=8)
558
+ iframe_urls: list[str] = []
559
+
560
+ def pick(sel: str) -> None:
561
+ for el in doc.select(sel):
562
+ src = el.attr("data-src") or el.attr("src")
563
+ if src:
564
+ abs_url = _make_absolute(src, url)
565
+ if abs_url and abs_url not in iframe_urls:
566
+ iframe_urls.append(abs_url)
567
+
568
+ for sel in (
569
+ ".video-box iframe",
570
+ "#responsiveIframe",
571
+ "section.video iframe",
572
+ ".video-content iframe",
573
+ "#options-0 iframe",
574
+ "#options-1 iframe",
575
+ ".video-player iframe",
576
+ "#aa-options iframe",
577
+ "aside.video-player iframe",
578
+ ):
579
+ pick(sel)
580
+
581
+ if not iframe_urls:
582
+ for el in doc.select("iframe"):
583
+ src = el.attr("data-src") or el.attr("src")
584
+ if src and not re.search(
585
+ r"google|doubleclick|highrevenueformat|adservice|disqus|llvpn",
586
+ src,
587
+ re.I,
588
+ ):
589
+ abs_url = _make_absolute(src, url)
590
+ if abs_url and abs_url not in iframe_urls:
591
+ iframe_urls.append(abs_url)
592
+
593
+ if not iframe_urls:
594
+ return []
595
+
596
+ def _extract_iframe(u: str) -> list[dict[str, Any]]:
597
+ try:
598
+ if "player.php?data=" in u:
599
+ return self._plyr_wrapper_extractor(u)
600
+ if any(h in u for h in _ZYPTER_HOSTS):
601
+ return zypter_extractor(u, session=self.session)
602
+ return abbasy_extractor(u, session=self.session)
603
+ except Exception:
604
+ return []
605
+
606
+ merged: list[dict[str, Any]] = []
607
+ with ThreadPoolExecutor(max_workers=min(len(iframe_urls), 6)) as pool:
608
+ for batch in pool.map(_extract_iframe, iframe_urls):
609
+ merged.extend(batch)
610
+
611
+ if not merged:
612
+ if (
613
+ iframe_urls
614
+ and "/episode/" not in iframe_urls[0]
615
+ and "/movies/" not in iframe_urls[0]
616
+ ):
617
+ return [
618
+ {
619
+ "server": "AnimeSalt (Embed)",
620
+ "link": iframe_urls[0],
621
+ "type": "iframe",
622
+ "headers": {},
623
+ "subtitles": [],
624
+ }
625
+ ]
626
+ return []
627
+
628
+ for s in merged:
629
+ if s.get("server") == "ZephyrFlick":
630
+ s["server"] = "HLS (Multi-Audio)"
631
+ return merged
632
+ except Exception:
633
+ return []
634
+
635
+ def get_stream(
636
+ self,
637
+ url: str,
638
+ is_download: bool = False,
639
+ media_type: str = "movie",
640
+ ) -> list[dict[str, Any]]:
641
+ if any(seg in url for seg in ("/episode/", "/movies/", "/movie/")):
642
+ return self._get_episode_streams(url)
643
+ if "player.php?data=" in url:
644
+ return self._plyr_wrapper_extractor(url)
645
+ if any(h in url for h in _ZYPTER_HOSTS):
646
+ return zypter_extractor(url, session=self.session)
647
+ if any(m in url for m in _ABYSS_MARKERS):
648
+ return abbasy_extractor(url, session=self.session)
649
+ return zypter_extractor(url, session=self.session)