22
33from KekikStream .Core import ExtractorBase , ExtractResult , Subtitle , HTMLHelper
44from Kekik .Sifreleme import Packer
5+ from contextlib import suppress
56import re
67
78class VidHide (ExtractorBase ):
@@ -17,7 +18,7 @@ class VidHide(ExtractorBase):
1718 "kinoger.be" ,
1819 "smoothpre.com" ,
1920 "dhtpre.com" ,
20- "peytonepre.com"
21+ "peytonepre.com" ,
2122 ]
2223
2324 def can_handle_url (self , url : str ) -> bool :
@@ -37,69 +38,70 @@ def get_embed_url(self, url: str) -> str:
3738
3839 async def extract (self , url : str , referer : str = None ) -> ExtractResult :
3940 base_url = self .get_base_url (url )
40- self .httpx .headers .update ({
41- "Referer" : referer or base_url ,
42- "Origin" : base_url ,
43- })
44-
41+ name = "EarnVids" if any (x in base_url for x in ["smoothpre.com" , "dhtpre.com" , "peytonepre.com" ]) else self .name
42+
43+ # Kotlin Headers
44+ headers = {
45+ "Sec-Fetch-Dest" : "empty" ,
46+ "Sec-Fetch-Mode" : "cors" ,
47+ "Sec-Fetch-Site" : "cross-site" ,
48+ "Origin" : f"{ base_url } /" ,
49+ "Referer" : referer or f"{ base_url } /" ,
50+ }
51+
4552 embed_url = self .get_embed_url (url )
46- istek = await self .httpx .get (embed_url , follow_redirects = True )
53+ istek = await self .httpx .get (embed_url , headers = headers , follow_redirects = True )
4754 text = istek .text
4855
4956 # Silinmiş dosya kontrolü
50- if "File is no longer available" in text or "File Not Found" in text :
51- raise ValueError (f"VidHide : Video silinmiş. { url } " )
57+ if any ( x in text for x in [ "File is no longer available" , "File Not Found" , "Video silinmiş" ]) :
58+ raise ValueError (f"{ name } : Video silinmiş. { url } " )
5259
5360 # JS Redirect Kontrolü (OneUpload vb.)
5461 if js_redirect := HTMLHelper (text ).regex_first (r"window\.location\.replace\(['\"]([^'\"]+)['\"]\)" ) or \
5562 HTMLHelper (text ).regex_first (r"window\.location\.href\s*=\s*['\"]([^'\"]+)['\"]" ):
56- # Redirect url'i al
5763 target_url = js_redirect
58- # Bazen path relative olabilir ama genelde full url
5964 if not target_url .startswith ("http" ):
60- # urljoin gerekebilir ama şimdilik doğrudan deneyelim veya fix_url
61- target_url = self .fix_url (target_url ) # fix_url base'e göre düzeltebilir mi? ExtractorBase.fix_url genelde şema ekler.
62- pass
65+ target_url = self .fix_url (target_url )
6366
64- # Yeniden istek at
6567 istek = await self .httpx .get (target_url , headers = {"Referer" : embed_url }, follow_redirects = True )
6668 text = istek .text
6769
6870 sel = HTMLHelper (text )
6971
7072 unpacked = ""
71- # Eval script bul (regex ile daha sağlam)
73+ # Eval script bul
7274 if eval_match := sel .regex_first (r'(eval\s*\(\s*function[\s\S]+?)<\/script>' ):
73- try :
75+ with suppress ( Exception ) :
7476 unpacked = Packer .unpack (eval_match )
7577 if "var links" in unpacked :
7678 unpacked = unpacked .split ("var links" )[1 ]
77- except :
78- pass
7979
8080 content = unpacked or text
81-
82- # Regex: Kotlin mantığı (: "url")
83- # Ayrıca sources: [...] mantığını da ekle
84- m3u8_url = HTMLHelper (content ).regex_first (r'sources:\s*\[\s*\{\s*file:\s*"([^"]+)"' )
85-
86- if not m3u8_url :
87- # Genel arama (hls:, file: vb.)
88- # Kotlin Regex: :\s*"(.*?m3u8.*?)"
89- match = HTMLHelper (content ).regex_first (r':\s*["\']([^"\']+\.m3u8[^"\']*)["\']' )
90- if match :
91- m3u8_url = match
92-
93- if not m3u8_url :
94- # Son şans: herhangi bir m3u8 linki
95- m3u8_url = HTMLHelper (content ).regex_first (r'["\']([^"\']+\.m3u8[^"\']*)["\']' )
96-
97- if not m3u8_url :
98- raise ValueError (f"VidHide: Video URL bulunamadı. { url } " )
99-
100- return ExtractResult (
101- name = self .name ,
102- url = self .fix_url (m3u8_url ),
103- referer = f"{ base_url } /" ,
104- user_agent = self .httpx .headers .get ("User-Agent" , "" )
105- )
81+
82+ # Kotlin Exact Regex: :\s*"(.*?m3u8.*?)"
83+ m3u8_matches = re .findall (r':\s*["\']([^"\']+\.m3u8[^"\']*)["\']' , content )
84+
85+ results = []
86+ for m3u8_url in m3u8_matches :
87+ results .append (ExtractResult (
88+ name = name ,
89+ url = self .fix_url (m3u8_url ),
90+ referer = f"{ base_url } /" ,
91+ user_agent = self .httpx .headers .get ("User-Agent" , "" )
92+ ))
93+
94+ if not results :
95+ # Fallback for non-m3u8 or different patterns
96+ if m3u8_url := sel .regex_first (r'sources:\s*\[\s*\{\s*file:\s*"([^"]+)"' ):
97+ results .append (ExtractResult (
98+ name = name ,
99+ url = self .fix_url (m3u8_url ),
100+ referer = f"{ base_url } /" ,
101+ user_agent = self .httpx .headers .get ("User-Agent" , "" )
102+ ))
103+
104+ if not results :
105+ raise ValueError (f"{ name } : Video URL bulunamadı. { url } " )
106+
107+ return results [0 ] if len (results ) == 1 else results
0 commit comments