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,1089 @@
1
+ """Pure-Python implementation of the Vega 'aniDream' provider."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import math
7
+ import re
8
+ import time
9
+ from concurrent.futures import ThreadPoolExecutor
10
+ from typing import Any
11
+ from urllib.parse import quote, urljoin
12
+
13
+ from .common import COMMON_HEADERS, BaseProvider, get_base_url, throw_provider_error
14
+
15
+ _DEFAULT_BASE_URL = "https://anidream.to"
16
+ _FLIXCLOUD_BASE_URL = "https://flixcloud.cc"
17
+ _DEFAULT_USER_AGENT = (
18
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
19
+ "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
20
+ )
21
+
22
+ _SERVER_FNS = {
23
+ "HOME": "03002968e86885bf64557e9fb459d6bb0d98fea020c558136eb9de8f45bb88ea",
24
+ "TRENDING": "769b1066a89e7c2e96b77880d3599750e0dda45a77a2a2cceb036c2f51621453",
25
+ "NEW_EPISODES": "5ced21715baaf026c35a78606e27cd072ff1fc628ad7627c9fe1bce74a2d3333",
26
+ "RELEASES": "16f5ac63d067ae5829f4620e30502fcc0843ef786cf98a644531ccf5f1aac149",
27
+ "BROWSE": "106b82f7a2b5783e3a3aed32e330e18e28a5006cded7804c38ebc41464230772",
28
+ "FACETS": "7dd851f9f94b2ba5d7b440193467da2d51e23e56e6b8cd5aceca6b64b1c0f780",
29
+ "INFO": "505b30ac55cdb92c6321f682548d2934b45f693f37b62f9b91007a836ebda9f9",
30
+ "EPISODES": "33c4f1e3d3bb451ddccfbb87aeb0d7e52f86a1c8954c61f38d31ea4527593190",
31
+ "LOGO": "93a33c99c618cb82056a1920881e278e55fd392abd5d120d5a5fd0920c021cac",
32
+ "PLAYBACK": "5ebed94ee2be52c6280fe2b832298a7f8a78c1dc67d7f28b42231743b2ebde1a",
33
+ }
34
+
35
+ _PAGE_LIMIT = 20
36
+
37
+ _SKIP_TYPES = {
38
+ "intro",
39
+ "op",
40
+ "mixed-op",
41
+ "outro",
42
+ "ed",
43
+ "mixed-ed",
44
+ "recap",
45
+ "prologue",
46
+ "preview",
47
+ }
48
+
49
+
50
+ # ---------------------------------------------------------------------------
51
+ # Seroval serialization / deserialization
52
+ # ---------------------------------------------------------------------------
53
+
54
+ _SER_ESC = {
55
+ '"': '\\"',
56
+ "\\": "\\\\",
57
+ "\n": "\\n",
58
+ "\r": "\\r",
59
+ "\b": "\\b",
60
+ "\t": "\\t",
61
+ "\f": "\\f",
62
+ "<": "\\x3C",
63
+ "\u2028": "\\u2028",
64
+ "\u2029": "\\u2029",
65
+ }
66
+
67
+
68
+ def _serialize_string(s: str) -> str:
69
+ if not any(ch in _SER_ESC for ch in s):
70
+ return s
71
+ return "".join(_SER_ESC.get(ch, ch) for ch in s)
72
+
73
+
74
+ def _deserialize_string(s: str) -> str:
75
+ if "\\" not in s:
76
+ return s
77
+ out: list[str] = []
78
+ i = 0
79
+ n = len(s)
80
+ simple = {"\\": "\\", '"': '"', "n": "\n", "r": "\r", "b": "\b", "t": "\t", "f": "\f"}
81
+ while i < n:
82
+ idx = s.find("\\", i)
83
+ if idx == -1 or idx >= n - 1:
84
+ out.append(s[i:])
85
+ break
86
+ out.append(s[i:idx])
87
+ nxt = s[idx + 1]
88
+ if nxt in simple:
89
+ out.append(simple[nxt])
90
+ i = idx + 2
91
+ elif nxt == "x" and s.startswith("3C", idx + 2):
92
+ out.append("<")
93
+ i = idx + 4
94
+ elif nxt == "u" and s.startswith("2028", idx + 2):
95
+ out.append("\u2028")
96
+ i = idx + 6
97
+ elif nxt == "u" and s.startswith("2029", idx + 2):
98
+ out.append("\u2029")
99
+ i = idx + 6
100
+ else:
101
+ out.append("\\")
102
+ i = idx + 1
103
+ return "".join(out)
104
+
105
+
106
+ def _encode_seroval(value: Any) -> str:
107
+ next_id = 0
108
+
109
+ def serialize(val: Any) -> Any:
110
+ nonlocal next_id
111
+ if val is None:
112
+ return {"t": 2, "s": 0}
113
+ if isinstance(val, bool):
114
+ return {"t": 2, "s": 2 if val else 3}
115
+ if isinstance(val, (int, float)):
116
+ if math.isnan(val):
117
+ return {"t": 2, "s": 4}
118
+ if val == float("inf"):
119
+ return {"t": 2, "s": 5}
120
+ if val == float("-inf"):
121
+ return {"t": 2, "s": 6}
122
+ return {"t": 0, "s": val}
123
+ if isinstance(val, str):
124
+ return {"t": 1, "s": _serialize_string(val)}
125
+ if isinstance(val, (list, tuple)):
126
+ obj_id = next_id
127
+ next_id += 1
128
+ return {"t": 9, "i": obj_id, "a": [serialize(v) for v in val]}
129
+ if isinstance(val, dict):
130
+ obj_id = next_id
131
+ next_id += 1
132
+ keys: list[str] = []
133
+ values: list[Any] = []
134
+ for k, v in val.items():
135
+ keys.append(_serialize_string(str(k)))
136
+ values.append(serialize(v))
137
+ return {"t": 10, "i": obj_id, "p": {"k": keys, "v": values}}
138
+ return {"t": 2, "s": 1}
139
+
140
+ return json.dumps({"t": serialize(value), "f": 127, "m": []}, separators=(",", ":"))
141
+
142
+
143
+ def _decode_seroval(payload: Any) -> Any:
144
+ refs: dict[int, Any] = {}
145
+
146
+ def deserialize(node: Any) -> Any:
147
+ if not isinstance(node, dict):
148
+ return node
149
+ t = node.get("t")
150
+ if t == 0:
151
+ return node.get("s")
152
+ if t == 1:
153
+ s = node.get("s")
154
+ return _deserialize_string(s) if isinstance(s, str) else s
155
+ if t == 2:
156
+ s = node.get("s")
157
+ return {
158
+ 0: None,
159
+ 1: None,
160
+ 2: True,
161
+ 3: False,
162
+ 4: float("nan"),
163
+ 5: float("inf"),
164
+ 6: float("-inf"),
165
+ 7: 0,
166
+ }.get(s)
167
+ if t == 4:
168
+ return refs.get(node.get("i"))
169
+ if t == 5:
170
+ val = node.get("s")
171
+ if node.get("i") is not None:
172
+ refs[node["i"]] = val
173
+ return val
174
+ if t == 7:
175
+ items: list[Any] = []
176
+ if node.get("i") is not None:
177
+ refs[node["i"]] = items
178
+ for item in node.get("a") or []:
179
+ items.append(deserialize(item))
180
+ return items
181
+ if t == 8:
182
+ mp: dict[Any, Any] = {}
183
+ if node.get("i") is not None:
184
+ refs[node["i"]] = mp
185
+ e = node.get("e") or {}
186
+ for k_node, v_node in zip(e.get("k") or [], e.get("v") or []):
187
+ mp[deserialize(k_node)] = deserialize(v_node)
188
+ return mp
189
+ if t == 9:
190
+ arr: list[Any] = []
191
+ if node.get("i") is not None:
192
+ refs[node["i"]] = arr
193
+ for item in node.get("a") or []:
194
+ arr.append(deserialize(item))
195
+ return arr
196
+ if t in (10, 11):
197
+ obj: dict[str, Any] = {}
198
+ if node.get("i") is not None:
199
+ refs[node["i"]] = obj
200
+ p = node.get("p") or {}
201
+ for k, v_node in zip(p.get("k") or [], p.get("v") or []):
202
+ key = _deserialize_string(k) if isinstance(k, str) else str(k)
203
+ obj[key] = deserialize(v_node)
204
+ return obj
205
+ return None
206
+
207
+ root = payload.get("t") if isinstance(payload, dict) and isinstance(payload.get("t"), dict) else payload
208
+ return deserialize(root)
209
+
210
+
211
+ # ---------------------------------------------------------------------------
212
+ # Helpers
213
+ # ---------------------------------------------------------------------------
214
+
215
+
216
+ def _extract_media_title(title: Any) -> str:
217
+ if not title:
218
+ return ""
219
+ if isinstance(title, str):
220
+ return title.strip()
221
+ if isinstance(title, dict):
222
+ return str(title.get("english") or title.get("romaji") or title.get("native") or "").strip()
223
+ return ""
224
+
225
+
226
+ def _extract_media_poster(media: Any) -> str:
227
+ if not isinstance(media, dict):
228
+ return ""
229
+ cover = media.get("cover_image") or {}
230
+ if not isinstance(cover, dict):
231
+ return ""
232
+ return str(cover.get("large") or cover.get("medium") or cover.get("small") or "")
233
+
234
+
235
+ def _extract_media_image(media: Any) -> str:
236
+ if not isinstance(media, dict):
237
+ return ""
238
+ return _extract_media_poster(media) or str(
239
+ media.get("banner_image") or media.get("backdrop_image") or ""
240
+ )
241
+
242
+
243
+ def _extract_media_backdrop(media: Any) -> str:
244
+ if not isinstance(media, dict):
245
+ return ""
246
+ return str(
247
+ media.get("backdrop_image") or media.get("banner_image") or _extract_media_image(media)
248
+ )
249
+
250
+
251
+ def _clean_synopsis(raw: Any) -> str:
252
+ if not isinstance(raw, str) or not raw:
253
+ return ""
254
+ text = re.sub(r"<br\s*/?>", "\n", raw, flags=re.I)
255
+ text = re.sub(r"</?[^>]+>", "", text)
256
+ for ent, rep in (
257
+ ("&quot;", '"'),
258
+ ("&#39;", "'"),
259
+ ("&amp;", "&"),
260
+ ("&lt;", "<"),
261
+ ("&gt;", ">"),
262
+ ):
263
+ text = text.replace(ent, rep)
264
+ return re.sub(r"\n{3,}", "\n\n", text).strip()
265
+
266
+
267
+ def _parse_anime_id(link: str) -> int:
268
+ raw = str(link or "").strip()
269
+ if raw.isdigit():
270
+ return int(raw)
271
+ for pattern in (r"/anime/(\d+)", r"[?&]id=(\d+)", r"(\d+)(?:[/?#].*)?$"):
272
+ m = re.search(pattern, raw, re.I)
273
+ if m:
274
+ return int(m.group(1))
275
+ raise ValueError(f"Invalid AniDream anime link: {link}")
276
+
277
+
278
+ def _parse_watch_url(link: str) -> tuple[int, float | int, bool]:
279
+ raw = str(link or "").strip()
280
+ if raw.startswith("{"):
281
+ try:
282
+ parsed = json.loads(raw)
283
+ aid = int(parsed.get("anilistId") or parsed.get("id") or 0)
284
+ ep = float(parsed.get("episode") or parsed.get("n") or 1)
285
+ if aid > 0:
286
+ ep_val: float | int = int(ep) if ep.is_integer() else ep
287
+ return aid, (ep_val if ep > 0 else 1), bool(parsed.get("hasDub") or parsed.get("dub"))
288
+ except Exception:
289
+ pass
290
+
291
+ m_id = re.search(r"[?&]id=(\d+)", raw, re.I)
292
+ m_ep = re.search(r"[?&]n=(\d+(?:\.\d+)?)", raw, re.I)
293
+ if m_id:
294
+ m_dub = re.search(r"[?&]dub=([^&#]+)", raw, re.I)
295
+ ep_f = float(m_ep.group(1)) if m_ep else 1.0
296
+ ep_val = int(ep_f) if ep_f.is_integer() else ep_f
297
+ has_dub = bool(m_dub and m_dub.group(1) in ("1", "true"))
298
+ return int(m_id.group(1)), ep_val, has_dub
299
+
300
+ m_colon = re.match(r"^(\d+):(\d+(?:\.\d+)?)$", raw)
301
+ if m_colon:
302
+ ep_f = float(m_colon.group(2))
303
+ return int(m_colon.group(1)), (int(ep_f) if ep_f.is_integer() else ep_f), False
304
+
305
+ return _parse_anime_id(raw), 1, False
306
+
307
+
308
+ def _map_episodes_to_links(
309
+ episodes: list[Any], base_url: str, anime_id: int, is_movie: bool = False
310
+ ) -> list[dict[str, Any]]:
311
+ if not isinstance(episodes, list):
312
+ return []
313
+ valid = [ep for ep in episodes if isinstance(ep, dict) and isinstance(ep.get("number"), (int, float))]
314
+ valid.sort(key=lambda e: e["number"])
315
+ out: list[dict[str, Any]] = []
316
+ clean_base = base_url.rstrip("/")
317
+ for ep in valid:
318
+ num = ep["number"]
319
+ ep_title = _extract_media_title(ep.get("title"))
320
+ if is_movie and len(valid) == 1:
321
+ title = ep_title or "Movie"
322
+ elif ep_title:
323
+ title = f"Episode {num}: {ep_title}"
324
+ else:
325
+ title = f"Episode {num}"
326
+ dub_q = "&dub=1" if ep.get("has_dub") else ""
327
+ entry: dict[str, Any] = {
328
+ "title": title,
329
+ "link": f"{clean_base}/watch?id={anime_id}&n={num}{dub_q}",
330
+ "type": "movie" if is_movie else "series",
331
+ }
332
+ if ep.get("thumbnail"):
333
+ entry["image"] = ep["thumbnail"]
334
+ out.append(entry)
335
+ return out
336
+
337
+
338
+ def _map_subtitle_type(raw_type: str | None, uri: str) -> str:
339
+ norm = str(raw_type or "").lower()
340
+ clean = uri.lower()
341
+ if norm == "vtt" or ".vtt" in clean:
342
+ return "text/vtt"
343
+ if norm == "ttml" or ".ttml" in clean:
344
+ return "application/ttml+xml"
345
+ if norm in ("ass", "ssa") or ".ass" in clean or ".ssa" in clean:
346
+ return "text/x-ssa"
347
+ return "application/x-subrip"
348
+
349
+
350
+ def _map_subtitles(raw_subs: Any) -> list[dict[str, Any]] | None:
351
+ if not isinstance(raw_subs, list) or not raw_subs:
352
+ return None
353
+ tracks: list[dict[str, Any]] = []
354
+ seen: set[str] = set()
355
+ for sub in raw_subs:
356
+ if not isinstance(sub, dict):
357
+ continue
358
+ uri = str(sub.get("url") or "").strip()
359
+ if not uri or uri in seen:
360
+ continue
361
+ seen.add(uri)
362
+ tracks.append(
363
+ {
364
+ "title": str(sub.get("label") or sub.get("language") or "Subtitle").strip(),
365
+ "language": str(sub.get("language") or "und").strip(),
366
+ "type": _map_subtitle_type(sub.get("type"), uri),
367
+ "uri": uri,
368
+ }
369
+ )
370
+ if not tracks:
371
+ return None
372
+ rank = {"application/x-subrip": 0, "text/vtt": 1}
373
+ tracks.sort(key=lambda t: rank.get(t["type"], 2))
374
+ return tracks
375
+
376
+
377
+ def _map_chapters_to_skip(chapters: Any) -> list[dict[str, Any]] | None:
378
+ if not isinstance(chapters, list) or not chapters:
379
+ return None
380
+ intervals: list[dict[str, Any]] = []
381
+ for ch in chapters:
382
+ if not isinstance(ch, dict):
383
+ continue
384
+ ch_type = str(ch.get("type") or "").lower()
385
+ if ch_type not in _SKIP_TYPES:
386
+ continue
387
+ try:
388
+ start = float(ch.get("start"))
389
+ end = float(ch.get("end"))
390
+ except (TypeError, ValueError):
391
+ continue
392
+ if not (math.isfinite(start) and math.isfinite(end) and end > start):
393
+ continue
394
+ if ch_type in ("outro", "ed", "mixed-ed"):
395
+ default_title = "Credits"
396
+ elif ch_type == "recap":
397
+ default_title = "Recap"
398
+ elif ch_type == "preview":
399
+ default_title = "Preview"
400
+ elif ch_type == "prologue":
401
+ default_title = "Prologue"
402
+ else:
403
+ default_title = "Intro"
404
+ intervals.append(
405
+ {
406
+ "title": ch.get("title") or default_title,
407
+ "from": round(start, 2),
408
+ "to": round(end, 2),
409
+ }
410
+ )
411
+ return intervals or None
412
+
413
+
414
+ def _format_audio_label(audio: str | None, is_dub: bool) -> str:
415
+ if audio == "dual":
416
+ return " (Dual Audio)"
417
+ if is_dub or audio in ("dub", "english"):
418
+ return " (Dub)"
419
+ return " (Sub)"
420
+
421
+
422
+ def _decode_flixcloud_devalue(data: Any) -> dict[str, str]:
423
+ nodes = data.get("nodes") if isinstance(data, dict) else None
424
+ if not isinstance(nodes, list):
425
+ nodes = []
426
+ data_node = next(
427
+ (
428
+ n
429
+ for n in nodes
430
+ if isinstance(n, dict)
431
+ and isinstance(n.get("data"), list)
432
+ and n["data"]
433
+ and isinstance(n["data"][0], dict)
434
+ and "video" in n["data"][0]
435
+ and "download" in n["data"][0]
436
+ ),
437
+ None,
438
+ )
439
+ if not data_node:
440
+ raise ValueError("FlixCloud metadata payload is missing video/download nodes")
441
+
442
+ arr = data_node["data"]
443
+ root = arr[0]
444
+ video = arr[root["video"]] if isinstance(root["video"], int) else root["video"]
445
+ download = arr[root["download"]] if isinstance(root["download"], int) else root["download"]
446
+
447
+ def pick(ref: Any) -> Any:
448
+ return arr[ref] if isinstance(ref, int) else ref
449
+
450
+ file_id = str(pick((video or {}).get("fileId")) or "").strip()
451
+ filename = str(pick((video or {}).get("filename")) or "").strip()
452
+ raw_res = pick((video or {}).get("resolution"))
453
+ resolution = str(raw_res).strip() if raw_res else ""
454
+ raw_sz = pick((video or {}).get("sizeHuman"))
455
+ size_human = str(raw_sz).strip() if raw_sz else ""
456
+ base = str(pick((download or {}).get("base")) or "").strip().rstrip("/")
457
+ token = str(pick((download or {}).get("token")) or "").strip()
458
+
459
+ if not file_id or not base or not token:
460
+ raise ValueError("FlixCloud metadata is incomplete (missing fileId, base, or token)")
461
+
462
+ return {
463
+ "fileId": file_id,
464
+ "filename": filename,
465
+ "resolution": resolution,
466
+ "sizeHuman": size_human,
467
+ "base": base,
468
+ "token": token,
469
+ }
470
+
471
+
472
+ def _extract_rate_limit_message(data: Any) -> str | None:
473
+ if not data:
474
+ return None
475
+ if isinstance(data, bytes):
476
+ data = data.decode("utf-8", errors="replace")
477
+ if isinstance(data, str):
478
+ try:
479
+ parsed = json.loads(data)
480
+ if isinstance(parsed, dict) and isinstance(parsed.get("error"), str):
481
+ return parsed["error"]
482
+ except Exception:
483
+ if data.strip():
484
+ return data.strip()
485
+ return None
486
+ if isinstance(data, dict) and isinstance(data.get("error"), str):
487
+ return data["error"]
488
+ return None
489
+
490
+
491
+ class AniDreamClient(BaseProvider):
492
+ """Pure-Python implementation of the Vega 'aniDream' provider."""
493
+
494
+ name = "aniDream"
495
+ catalog = [
496
+ {"title": "New Episodes", "filter": "releases:all"},
497
+ {"title": "Trending Now", "filter": "sort:trending"},
498
+ {"title": "Latest Updates", "filter": "sort:latest"},
499
+ {"title": "Popular Anime", "filter": "sort:popularity"},
500
+ {"title": "Top Rated", "filter": "sort:score"},
501
+ {"title": "This Season", "filter": "home:this_season"},
502
+ {"title": "Top This Week", "filter": "home:top_week"},
503
+ ]
504
+ genres = [
505
+ {"title": "Action", "filter": "genre:Action"},
506
+ {"title": "Adventure", "filter": "genre:Adventure"},
507
+ {"title": "Comedy", "filter": "genre:Comedy"},
508
+ {"title": "Drama", "filter": "genre:Drama"},
509
+ {"title": "Ecchi", "filter": "genre:Ecchi"},
510
+ {"title": "Fantasy", "filter": "genre:Fantasy"},
511
+ {"title": "Horror", "filter": "genre:Horror"},
512
+ {"title": "Mahou Shoujo", "filter": "genre:Mahou Shoujo"},
513
+ {"title": "Mecha", "filter": "genre:Mecha"},
514
+ {"title": "Music", "filter": "genre:Music"},
515
+ {"title": "Mystery", "filter": "genre:Mystery"},
516
+ {"title": "Psychological", "filter": "genre:Psychological"},
517
+ {"title": "Romance", "filter": "genre:Romance"},
518
+ {"title": "Sci-Fi", "filter": "genre:Sci-Fi"},
519
+ {"title": "Slice of Life", "filter": "genre:Slice of Life"},
520
+ {"title": "Sports", "filter": "genre:Sports"},
521
+ {"title": "Supernatural", "filter": "genre:Supernatural"},
522
+ {"title": "Thriller", "filter": "genre:Thriller"},
523
+ ]
524
+
525
+ def _resolve_base_url(self) -> str:
526
+ try:
527
+ resolved = get_base_url("aniDream", session=self.session)
528
+ if resolved and re.match(r"^https?://", resolved.strip(), re.I):
529
+ return resolved.strip().rstrip("/")
530
+ except Exception:
531
+ pass
532
+ return _DEFAULT_BASE_URL
533
+
534
+ def _call_server_fn(
535
+ self,
536
+ fn_hash: str,
537
+ data: dict[str, Any],
538
+ *,
539
+ base_url: str | None = None,
540
+ referer: str | None = None,
541
+ timeout: int = 15,
542
+ ) -> Any:
543
+ base = (base_url or self._resolve_base_url()).rstrip("/")
544
+ payload = _encode_seroval({"data": data})
545
+ url = f"{base}/_serverFn/{fn_hash}?payload={quote(payload, safe='')}"
546
+ raw = self.fetch_json(
547
+ url,
548
+ headers={
549
+ **COMMON_HEADERS,
550
+ "Origin": base,
551
+ "Referer": referer or f"{base}/",
552
+ "x-tsr-serverFn": "true",
553
+ "Accept": "application/json",
554
+ "User-Agent": COMMON_HEADERS.get("User-Agent") or _DEFAULT_USER_AGENT,
555
+ },
556
+ timeout=timeout,
557
+ )
558
+ decoded = _decode_seroval(raw)
559
+ if isinstance(decoded, dict) and decoded.get("error"):
560
+ err = decoded["error"]
561
+ msg = err if isinstance(err, str) else (err.get("message") if isinstance(err, dict) else json.dumps(err))
562
+ raise RuntimeError(msg)
563
+ if isinstance(decoded, dict) and "result" in decoded:
564
+ return decoded["result"]
565
+ return decoded
566
+
567
+ def _map_media_to_posts(self, items: Any, base_url: str) -> list[dict[str, str]]:
568
+ if not isinstance(items, list):
569
+ return []
570
+ seen_ids: set[int] = set()
571
+ posts: list[dict[str, str]] = []
572
+ clean_base = base_url.rstrip("/")
573
+ for item in items:
574
+ if not isinstance(item, dict):
575
+ continue
576
+ media = item.get("card") or item
577
+ try:
578
+ aid = int(item.get("animeId") or (media.get("id") if isinstance(media, dict) else 0) or 0)
579
+ except (TypeError, ValueError):
580
+ continue
581
+ if aid <= 0 or aid in seen_ids:
582
+ continue
583
+ title = _extract_media_title(media.get("title") if isinstance(media, dict) else None)
584
+ image = _extract_media_image(media)
585
+ if not title or not image:
586
+ continue
587
+ seen_ids.add(aid)
588
+ posts.append({"title": title, "link": f"{clean_base}/anime/{aid}", "image": image})
589
+ return posts
590
+
591
+ def get_posts(self, filter_path: str = "", page: int = 1) -> list[dict[str, str]]:
592
+ try:
593
+ base_url = self._resolve_base_url()
594
+ clean_filter = str(filter_path or "").strip()
595
+
596
+ if clean_filter.startswith("releases:"):
597
+ audio = clean_filter[len("releases:") :] or "all"
598
+ res = self._call_server_fn(
599
+ _SERVER_FNS["RELEASES"],
600
+ {"isAdult": False, "audio": audio, "page": page},
601
+ base_url=base_url,
602
+ )
603
+ return self._map_media_to_posts((res or {}).get("releases") or [], base_url)
604
+
605
+ if clean_filter.startswith("home:"):
606
+ if page > 1:
607
+ return []
608
+ key = clean_filter[len("home:") :]
609
+ res = self._call_server_fn(
610
+ _SERVER_FNS["HOME"],
611
+ {"lang": "en", "isAdult": False},
612
+ base_url=base_url,
613
+ ) or {}
614
+ if key == "this_season":
615
+ lst = res.get("this_season")
616
+ elif key == "top_week":
617
+ lst = (res.get("anime_top") or {}).get("week")
618
+ elif key == "popular":
619
+ lst = res.get("popular_anime")
620
+ else:
621
+ lst = res.get("new_anime")
622
+ return self._map_media_to_posts(lst or [], base_url)
623
+
624
+ if clean_filter.startswith("genre:"):
625
+ genre = clean_filter[len("genre:") :].strip()
626
+ params: dict[str, Any] = {
627
+ "type": "ANIME",
628
+ "available": True,
629
+ "sort": "popularity",
630
+ "isAdult": False,
631
+ "page": page,
632
+ "limit": _PAGE_LIMIT,
633
+ }
634
+ if genre:
635
+ params["genres"] = [genre]
636
+ res = self._call_server_fn(
637
+ _SERVER_FNS["BROWSE"],
638
+ params,
639
+ base_url=base_url,
640
+ referer=f"{base_url}/browse",
641
+ )
642
+ return self._map_media_to_posts((res or {}).get("items") or [], base_url)
643
+
644
+ sort = (
645
+ (clean_filter[len("sort:") :] or "trending")
646
+ if clean_filter.startswith("sort:")
647
+ else "trending"
648
+ )
649
+ res = self._call_server_fn(
650
+ _SERVER_FNS["BROWSE"],
651
+ {
652
+ "type": "ANIME",
653
+ "available": True,
654
+ "sort": sort,
655
+ "isAdult": False,
656
+ "page": page,
657
+ "limit": _PAGE_LIMIT,
658
+ },
659
+ base_url=base_url,
660
+ referer=f"{base_url}/browse",
661
+ )
662
+ return self._map_media_to_posts((res or {}).get("items") or [], base_url)
663
+ except Exception as err:
664
+ throw_provider_error("AniDream", "posts", err)
665
+ return []
666
+
667
+ def get_search_posts(self, query: str, page: int = 1) -> list[dict[str, str]]:
668
+ try:
669
+ q = str(query or "").strip()
670
+ if not q:
671
+ return []
672
+ base_url = self._resolve_base_url()
673
+ res = self._call_server_fn(
674
+ _SERVER_FNS["BROWSE"],
675
+ {
676
+ "type": "ANIME",
677
+ "q": q,
678
+ "available": True,
679
+ "isAdult": False,
680
+ "page": page,
681
+ "limit": _PAGE_LIMIT,
682
+ },
683
+ base_url=base_url,
684
+ referer=f"{base_url}/browse",
685
+ )
686
+ return self._map_media_to_posts((res or {}).get("items") or [], base_url)
687
+ except Exception as err:
688
+ throw_provider_error("AniDream", "search", err)
689
+ return []
690
+
691
+ def get_meta(self, link: str) -> dict[str, Any]:
692
+ try:
693
+ base_url = self._resolve_base_url()
694
+ anime_id = _parse_anime_id(link)
695
+ referer = f"{base_url.rstrip('/')}/anime/{anime_id}"
696
+
697
+ def _fetch_info() -> Any:
698
+ return self._call_server_fn(
699
+ _SERVER_FNS["INFO"],
700
+ {"id": anime_id, "type": "ANIME", "watchOrder": False},
701
+ base_url=base_url,
702
+ referer=referer,
703
+ )
704
+
705
+ def _fetch_eps() -> Any:
706
+ try:
707
+ return self._call_server_fn(
708
+ _SERVER_FNS["EPISODES"],
709
+ {"id": anime_id},
710
+ base_url=base_url,
711
+ referer=referer,
712
+ )
713
+ except Exception:
714
+ return []
715
+
716
+ def _fetch_logo() -> Any:
717
+ try:
718
+ return self._call_server_fn(
719
+ _SERVER_FNS["LOGO"],
720
+ {"id": anime_id, "type": "ANIME", "lang": "en"},
721
+ base_url=base_url,
722
+ referer=referer,
723
+ )
724
+ except Exception:
725
+ return None
726
+
727
+ with ThreadPoolExecutor(max_workers=3) as pool:
728
+ f_info = pool.submit(_fetch_info)
729
+ f_eps = pool.submit(_fetch_eps)
730
+ f_logo = pool.submit(_fetch_logo)
731
+ info = f_info.result()
732
+ episodes = f_eps.result()
733
+ logo_res = f_logo.result()
734
+
735
+ if not isinstance(info, dict) or not info.get("id"):
736
+ raise ValueError(f"Anime {anime_id} not found")
737
+
738
+ title = _extract_media_title(info.get("title")) or f"Anime {anime_id}"
739
+ is_movie = info.get("format") == "MOVIE"
740
+ poster = _extract_media_poster(info) or None
741
+ image = _extract_media_backdrop(info) or poster or ""
742
+ raw_logo = (
743
+ (info.get("logo_image").strip() if isinstance(info.get("logo_image"), str) else "")
744
+ or (
745
+ logo_res.get("logo").strip()
746
+ if isinstance(logo_res, dict) and isinstance(logo_res.get("logo"), str)
747
+ else ""
748
+ )
749
+ )
750
+ synopsis = _clean_synopsis(info.get("description"))
751
+ avg_score = info.get("average_score")
752
+ rating = (
753
+ f"{avg_score / 10:.1f}"
754
+ if isinstance(avg_score, (int, float)) and avg_score > 0
755
+ else None
756
+ )
757
+
758
+ raw_tags = [
759
+ "TV Series" if info.get("format") == "TV" else info.get("format"),
760
+ info.get("status"),
761
+ *(info.get("genres") if isinstance(info.get("genres"), list) else []),
762
+ ]
763
+ tags = [t for t in raw_tags if isinstance(t, str) and t.strip()]
764
+
765
+ direct_links = _map_episodes_to_links(
766
+ episodes or [], base_url=base_url, anime_id=anime_id, is_movie=is_movie
767
+ )
768
+ link_list = [{"title": title, "directLinks": direct_links}] if direct_links else []
769
+
770
+ result: dict[str, Any] = {
771
+ "title": title,
772
+ "image": image,
773
+ "synopsis": synopsis,
774
+ "imdbId": "",
775
+ "type": "movie" if is_movie else "series",
776
+ "linkList": link_list,
777
+ "webUrl": referer,
778
+ }
779
+ if poster:
780
+ result["poster"] = poster
781
+ if raw_logo:
782
+ result["logo"] = raw_logo
783
+ if info.get("tmdb_id"):
784
+ result["tmdbId"] = str(info["tmdb_id"])
785
+ if tags:
786
+ result["tags"] = tags
787
+ if rating:
788
+ result["rating"] = rating
789
+ return result
790
+ except Exception as err:
791
+ throw_provider_error("AniDream", "metadata", err)
792
+ return {}
793
+
794
+ def get_episodes(
795
+ self,
796
+ url: str,
797
+ imdb_id: str = "",
798
+ season: int | None = None,
799
+ ) -> list[dict[str, Any]]:
800
+ try:
801
+ base_url = self._resolve_base_url()
802
+ anime_id = _parse_anime_id(url)
803
+ episodes = self._call_server_fn(
804
+ _SERVER_FNS["EPISODES"],
805
+ {"id": anime_id},
806
+ base_url=base_url,
807
+ referer=f"{base_url.rstrip('/')}/anime/{anime_id}",
808
+ )
809
+ return _map_episodes_to_links(episodes or [], base_url=base_url, anime_id=anime_id)
810
+ except Exception as err:
811
+ throw_provider_error("AniDream", "episodes", err)
812
+ return []
813
+
814
+ def _wait_for_flixcloud_progress(self, prog_url: str, user_agent: str) -> None:
815
+ headers = {
816
+ "Accept": "text/event-stream",
817
+ "Origin": _FLIXCLOUD_BASE_URL,
818
+ "Referer": f"{_FLIXCLOUD_BASE_URL}/",
819
+ "User-Agent": user_agent,
820
+ }
821
+ with self.session.get(prog_url, headers=headers, stream=True, timeout=60) as resp:
822
+ if resp.status_code == 429:
823
+ raise RuntimeError(
824
+ _extract_rate_limit_message(resp.text)
825
+ or "FlixCloud rate limit reached. Please try again shortly."
826
+ )
827
+ if not (200 <= resp.status_code < 300):
828
+ raise RuntimeError(f"FlixCloud progress failed with HTTP {resp.status_code}")
829
+
830
+ last_event: dict[str, Any] | None = None
831
+ for raw_line in resp.iter_lines(decode_unicode=True):
832
+ if not raw_line:
833
+ continue
834
+ line = raw_line.strip()
835
+ if not line.startswith("data:"):
836
+ continue
837
+ json_part = line[5:].strip()
838
+ if not json_part:
839
+ continue
840
+ try:
841
+ parsed = json.loads(json_part)
842
+ except Exception:
843
+ continue
844
+ if isinstance(parsed, dict):
845
+ last_event = parsed
846
+ if parsed.get("status") == "ready":
847
+ return
848
+ if parsed.get("status") == "failed":
849
+ raise RuntimeError(
850
+ parsed.get("error") or "FlixCloud download preparation failed"
851
+ )
852
+
853
+ if last_event and last_event.get("status") == "ready":
854
+ return
855
+ if last_event and last_event.get("status") == "failed":
856
+ raise RuntimeError(
857
+ last_event.get("error") or "FlixCloud download preparation failed"
858
+ )
859
+ raise RuntimeError("FlixCloud progress stream did not reach ready state")
860
+
861
+ def _resolve_final_mkv_url(self, dl_url: str, base: str, user_agent: str) -> str:
862
+ base_headers = {
863
+ "Origin": _FLIXCLOUD_BASE_URL,
864
+ "Referer": f"{_FLIXCLOUD_BASE_URL}/",
865
+ "User-Agent": user_agent,
866
+ }
867
+
868
+ def _extract_redirect(resp: Any) -> str | None:
869
+ loc = resp.headers.get("location") or resp.headers.get("Location")
870
+ if 300 <= resp.status_code < 400 and isinstance(loc, str) and loc.strip():
871
+ return urljoin(dl_url, loc.strip())
872
+ if (
873
+ 200 <= resp.status_code < 300
874
+ and resp.url
875
+ and resp.url != dl_url
876
+ and not resp.url.startswith(f"{base}/download/")
877
+ ):
878
+ return resp.url
879
+ return None
880
+
881
+ resp = self.session.head(
882
+ dl_url, headers=base_headers, allow_redirects=False, timeout=20
883
+ )
884
+ if resp.status_code in (405, 501):
885
+ resp = self.session.get(
886
+ dl_url,
887
+ headers={**base_headers, "Range": "bytes=0-0"},
888
+ allow_redirects=False,
889
+ timeout=20,
890
+ )
891
+
892
+ if resp.status_code == 429:
893
+ raise RuntimeError(
894
+ _extract_rate_limit_message(resp.content)
895
+ or "FlixCloud rate limit reached. Please try again shortly."
896
+ )
897
+
898
+ target = _extract_redirect(resp)
899
+ if target:
900
+ return target
901
+
902
+ if resp.status_code == 202:
903
+ time.sleep(2.0)
904
+ retry = self.session.head(
905
+ dl_url, headers=base_headers, allow_redirects=False, timeout=20
906
+ )
907
+ if retry.status_code == 429:
908
+ raise RuntimeError(
909
+ _extract_rate_limit_message(retry.content)
910
+ or "FlixCloud rate limit reached. Please try again shortly."
911
+ )
912
+ target = _extract_redirect(retry)
913
+ if target:
914
+ return target
915
+
916
+ raise RuntimeError(
917
+ f"FlixCloud did not return an MKV redirect URL (HTTP {resp.status_code})"
918
+ )
919
+
920
+ def _resolve_flixcloud_mkv(self, file_code: str) -> dict[str, Any]:
921
+ clean_code = str(file_code or "").strip()
922
+ if not re.match(r"^[A-Za-z0-9_-]{1,64}$", clean_code):
923
+ raise ValueError(f"Invalid FlixCloud file code: {file_code}")
924
+
925
+ user_agent = COMMON_HEADERS.get("User-Agent") or _DEFAULT_USER_AGENT
926
+ payload = self.fetch_json(
927
+ f"{_FLIXCLOUD_BASE_URL}/d/{clean_code}/__data.json",
928
+ headers={
929
+ **COMMON_HEADERS,
930
+ "Referer": f"{_FLIXCLOUD_BASE_URL}/d/{clean_code}",
931
+ "Accept": "application/json",
932
+ "User-Agent": user_agent,
933
+ },
934
+ timeout=15,
935
+ )
936
+ meta = _decode_flixcloud_devalue(payload)
937
+ encoded_token = quote(meta["token"], safe="")
938
+ prog_url = f"{meta['base']}/download/{meta['fileId']}/progress?token={encoded_token}"
939
+ dl_url = f"{meta['base']}/download/{meta['fileId']}?token={encoded_token}"
940
+
941
+ self._wait_for_flixcloud_progress(prog_url, user_agent)
942
+ mkv_url = self._resolve_final_mkv_url(dl_url, meta["base"], user_agent)
943
+
944
+ m_q = re.search(r"(2160|1080|720|480|360)", meta.get("resolution") or "")
945
+ return {
946
+ "url": mkv_url,
947
+ "filename": meta["filename"],
948
+ "quality": m_q.group(1) if m_q else None,
949
+ "sizeHuman": meta.get("sizeHuman") or None,
950
+ }
951
+
952
+ def get_stream(
953
+ self,
954
+ url: str,
955
+ is_download: bool = False,
956
+ media_type: str = "movie",
957
+ ) -> list[dict[str, Any]]:
958
+ try:
959
+ base_url = self._resolve_base_url()
960
+ anilist_id, episode, has_dub = _parse_watch_url(url)
961
+ referer = f"{base_url.rstrip('/')}/watch?id={anilist_id}&n={episode}"
962
+
963
+ def fetch_pb(dub: bool, server: int) -> dict[str, Any] | None:
964
+ try:
965
+ pb = self._call_server_fn(
966
+ _SERVER_FNS["PLAYBACK"],
967
+ {
968
+ "anilistId": anilist_id,
969
+ "episode": episode,
970
+ "dub": bool(dub),
971
+ "server": server,
972
+ },
973
+ base_url=base_url,
974
+ referer=referer,
975
+ )
976
+ if isinstance(pb, dict) and pb.get("ok") and pb.get("data"):
977
+ return {"dub": dub, "server": server, "pb": pb}
978
+ except Exception:
979
+ pass
980
+ return None
981
+
982
+ with ThreadPoolExecutor(max_workers=2) as pool:
983
+ sub_results = [
984
+ r for r in pool.map(lambda s: fetch_pb(False, s), (1, 2)) if r is not None
985
+ ]
986
+
987
+ has_dual = any(
988
+ (r["pb"]["data"].get("audio") == "dual")
989
+ or ("dual" in (r["pb"]["data"].get("audios") or []))
990
+ for r in sub_results
991
+ )
992
+ has_sep_dub = not has_dual and (
993
+ has_dub
994
+ or any(
995
+ any(a in ("dub", "english") for a in (r["pb"]["data"].get("audios") or []))
996
+ for r in sub_results
997
+ )
998
+ )
999
+
1000
+ dub_results: list[dict[str, Any]] = []
1001
+ if has_sep_dub:
1002
+ with ThreadPoolExecutor(max_workers=2) as pool:
1003
+ dub_results = [
1004
+ r for r in pool.map(lambda s: fetch_pb(True, s), (1, 2)) if r is not None
1005
+ ]
1006
+
1007
+ all_results = [*sub_results, *dub_results]
1008
+ if not all_results:
1009
+ raise RuntimeError(
1010
+ f"No playback sources found for AniList {anilist_id} episode {episode}"
1011
+ )
1012
+
1013
+ streams: list[dict[str, Any]] = []
1014
+ seen_urls: set[str] = set()
1015
+ stream_headers = {
1016
+ "Referer": f"{base_url}/",
1017
+ "Origin": base_url,
1018
+ "User-Agent": COMMON_HEADERS.get("User-Agent") or _DEFAULT_USER_AGENT,
1019
+ }
1020
+
1021
+ if not is_download:
1022
+ for entry in all_results:
1023
+ data = entry["pb"]["data"]
1024
+ stream_url = str(data.get("streamUrl") or "").strip()
1025
+ if not stream_url or stream_url in seen_urls:
1026
+ continue
1027
+ seen_urls.add(stream_url)
1028
+ subtitles = _map_subtitles(data.get("subtitles"))
1029
+ skip = _map_chapters_to_skip(data.get("chapters"))
1030
+ audio_label = _format_audio_label(data.get("audio"), entry["dub"])
1031
+ st: dict[str, Any] = {
1032
+ "server": f"Server {entry['server']}{audio_label}",
1033
+ "link": stream_url,
1034
+ "type": "m3u8",
1035
+ "headers": stream_headers,
1036
+ }
1037
+ if subtitles:
1038
+ st["subtitles"] = subtitles
1039
+ if skip:
1040
+ st["skip"] = skip
1041
+ streams.append(st)
1042
+
1043
+ seen_codes: set[str] = set()
1044
+ download_targets: list[dict[str, Any]] = []
1045
+ for entry in all_results:
1046
+ data = entry["pb"]["data"]
1047
+ file_code = str(data.get("fileCode") or "").strip()
1048
+ if not file_code or file_code in seen_codes:
1049
+ continue
1050
+ seen_codes.add(file_code)
1051
+ download_targets.append(
1052
+ {
1053
+ "fileCode": file_code,
1054
+ "audioLabel": _format_audio_label(data.get("audio"), entry["dub"]),
1055
+ "skip": _map_chapters_to_skip(data.get("chapters")),
1056
+ }
1057
+ )
1058
+
1059
+ if is_download and not download_targets:
1060
+ raise RuntimeError("No FlixCloud download codes available for this episode")
1061
+
1062
+ resolved_streams: list[dict[str, Any]] = []
1063
+ last_error: Exception | None = None
1064
+ for target in download_targets:
1065
+ try:
1066
+ mkv = self._resolve_flixcloud_mkv(target["fileCode"])
1067
+ size_str = f" ({mkv['sizeHuman']})" if mkv.get("sizeHuman") else ""
1068
+ st = {
1069
+ "server": f"FlixCloud MKV{size_str}{target['audioLabel']}",
1070
+ "link": mkv["url"],
1071
+ "type": "mkv",
1072
+ }
1073
+ if mkv.get("quality"):
1074
+ st["quality"] = mkv["quality"]
1075
+ if mkv.get("sizeHuman"):
1076
+ st["tag"] = mkv["sizeHuman"]
1077
+ if target.get("skip"):
1078
+ st["skip"] = target["skip"]
1079
+ resolved_streams.append(st)
1080
+ except Exception as err:
1081
+ last_error = err
1082
+
1083
+ if not streams and not resolved_streams and last_error is not None:
1084
+ raise last_error
1085
+
1086
+ return [*streams, *resolved_streams]
1087
+ except Exception as err:
1088
+ throw_provider_error("AniDream", "stream", err)
1089
+ return []