Sir tv
export default{async fetch(request,env,ctx){
const referer=request.headers.get("Referer")||"";
const origin=request.headers.get("Origin")||"";
const allowedDomain="123tv.fun";
if(!referer.includes(allowedDomain)&&!origin.includes(allowedDomain))return new Response("Forbidden",{status:403});
const requestUrl=new URL(request.url);
const pathname=requestUrl.pathname;
const cache=caches.default;
const segmentMatch=pathname.match(/^\/([^\/]+)\/(\d+)\.ts$/);
if(segmentMatch){
const channelName=segmentMatch[1];
const segmentNumber=segmentMatch[2];
const mappingUrl=requestUrl.origin+"/mapping/"+encodeURIComponent(channelName)+"/"+segmentNumber+".ts";
const mapping=await cache.match(new Request(mappingUrl));
if(!mapping)return new Response("Segment mapping not found",{status:404});
const originalUrl=mapping.headers.get("X-Original-URL");
if(!originalUrl)return new Response("Original URL not found",{status:404});
const segmentCacheUrl=requestUrl.origin+"/segment-cache/"+encodeURIComponent(channelName)+"/"+segmentNumber+".ts";
const segmentCacheKey=new Request(segmentCacheUrl);
const cachedSegment=await cache.match(segmentCacheKey);
if(cachedSegment)return cachedSegment;
const res=await fetch(originalUrl,{headers:{
"Referer":"https://912acsss8af382.yasirtv.com",
"Origin":"https://912acsss8af382.yasirtv.com",
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36"
}});
const data=new Uint8Array(await res.arrayBuffer());
let start=-1;
for(let i=0;i