Skip to content
This repository was archived by the owner on May 2, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions viu_media/core/downloader/yt_dlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def download(self, params: DownloadParams) -> DownloadResult:
sub_paths = []
merged_path = None

logger.debug(f"Starting download for URL: {params.url}")
logger.debug(f"Using Headers: {params.headers}")

if TORRENT_REGEX.match(params.url):
from .torrents import download_torrent_with_webtorrent_cli

Expand Down
21 changes: 20 additions & 1 deletion viu_media/libs/provider/anime/animepahe/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
ANIMEPAHE = "animepahe.si"
ANIMEPAHE_BASE = f"https://{ANIMEPAHE}"
ANIMEPAHE_ENDPOINT = f"{ANIMEPAHE_BASE}/api"
CDN_PROVIDER = "kwik.cx"
CDN_PROVIDER_BASE = f"https://{CDN_PROVIDER}"

SERVERS_AVAILABLE = ["kwik"]
REQUEST_HEADERS = {
Expand All @@ -25,13 +27,30 @@
"Accept-Encoding": "Utf-8",
"DNT": "1",
"Connection": "keep-alive",
"Referer": "https://animepahe.si/",
"Referer": ANIMEPAHE_BASE + '/',
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string concatenation pattern using + operator is inconsistent with the f-string style used elsewhere in this file. Consider using f-strings for consistency: "Referer": f"{ANIMEPAHE_BASE}/"

Copilot uses AI. Check for mistakes.
"Upgrade-Insecure-Requests": "1",
"Sec-Fetch-Dest": "iframe",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "cross-site",
"Priority": "u=4",
"TE": "trailers",
}

STREAM_HEADERS = {
# "Host": "vault-16.owocdn.top", # This will have to be the actual host of the stream (behind Kwik)
"Accept": "*/*",
"Accept-Language": "en-US,en;q=0.5",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Origin": CDN_PROVIDER_BASE,
"Sec-GPC": "1",
"Connection": "keep-alive",
"Referer": CDN_PROVIDER_BASE + '/',
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string concatenation pattern using + operator is inconsistent with the f-string style used elsewhere in this file. Consider using f-strings for consistency: "Referer": f"{CDN_PROVIDER_BASE}/"

Suggested change
"Referer": CDN_PROVIDER_BASE + '/',
"Referer": f"{CDN_PROVIDER_BASE}/",

Copilot uses AI. Check for mistakes.
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "cross-site",
"TE": "trailers",
}


JUICY_STREAM_REGEX = re.compile(r"source='(.*)';")
KWIK_RE = re.compile(r"Player\|(.+?)'")
3 changes: 2 additions & 1 deletion viu_media/libs/provider/anime/animepahe/mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def map_to_server(
episode: AnimeEpisodeInfo,
translation_type: str,
stream_links: list[tuple[str, str]],
headers: dict[str, str],
) -> Server:
links = [
EpisodeStream(
Expand All @@ -97,4 +98,4 @@ def map_to_server(
)
for link in stream_links
]
return Server(name="kwik", links=links, episode_title=episode.title)
return Server(name="kwik", links=links, episode_title=episode.title, headers=headers)
12 changes: 11 additions & 1 deletion viu_media/libs/provider/anime/animepahe/provider.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
from functools import lru_cache
from typing import Iterator, Optional
from urllib.parse import urlparse

from ..base import BaseAnimeProvider
from ..params import AnimeParams, EpisodeStreamsParams, SearchParams
Expand All @@ -9,9 +10,11 @@
from .constants import (
ANIMEPAHE_BASE,
ANIMEPAHE_ENDPOINT,
CDN_PROVIDER,
JUICY_STREAM_REGEX,
REQUEST_HEADERS,
SERVER_HEADERS,
STREAM_HEADERS,
)
from .extractor import process_animepahe_embed_page
from .mappers import map_to_anime_result, map_to_search_results, map_to_server
Expand Down Expand Up @@ -132,6 +135,7 @@ def episode_streams(self, params: EpisodeStreamsParams) -> Iterator[Server] | No
quality = None
translation_type = None
stream_links = []
stream_host = None

# TODO: better document the scraping process
for res_dict in res_dicts:
Expand Down Expand Up @@ -170,13 +174,19 @@ def episode_streams(self, params: EpisodeStreamsParams) -> Iterator[Server] | No
continue
logger.debug(f"Found juicy stream: {juicy_stream.group(1)}")
juicy_stream = juicy_stream.group(1)
stream_host = urlparse(juicy_stream).hostname
quality = res_dict["resolution"]
logger.debug(f"Found quality: {quality}")
translation_type = data_audio
stream_links.append((quality, juicy_stream))

if translation_type and stream_links:
yield map_to_server(episode, translation_type, stream_links)
headers = {
"User-Agent": self.client.headers["User-Agent"],
"Host": stream_host or CDN_PROVIDER,
**STREAM_HEADERS
}
yield map_to_server(episode, translation_type, stream_links, headers=headers)

@lru_cache()
def _get_episode_info(
Expand Down
Loading