242
Subscribers
No data24 hours
-17 days
+430 days
Posts Archive
242
Cloudflare Worker Script To Get YouTube Stream.
addEventListener('fetch', (event) => {
event.respondWith(
handleRequest(event.request).catch(
(err) => new Response(err.message, { status: 500 })
)
);
});
async function handleRequest(request) {
try {
const { pathname } = new URL(request.url);
let idType, identifier;
if (pathname.startsWith('/live/')) {
idType = 'live';
identifier = pathname.split('/')[2]?.split('.')[0];
} else if (pathname.startsWith('/@')) {
idType = 'handle';
identifier = pathname.split('.')[0].substring(2);
} else if (pathname.startsWith('/channel/')) {
idType = 'channel';
identifier = pathname.split('/')[2]?.split('.')[0];
} else if (pathname.startsWith('/c/')) {
idType = 'customName';
identifier = pathname.split('/')[2]?.split('.')[0];
} else if (pathname.startsWith('/user/')) {
idType = 'user';
identifier = pathname.split('/')[2]?.split('.')[0];
} else {
throw new Error(`Path not found: ${pathname}`);
}
if (identifier) {
const url = `https://www.youtube.com/${getYouTubePath(idType, identifier)}/live`;
const response = await fetch(url, {
cf: {
cacheTtl: 10800,
cacheEverything: true,
},
});
if (response.ok) {
const text = await response.text();
const stream = text.match(/(?<="hlsManifestUrl":").*\.m3u8/g);
if (stream) {
return Response.redirect(stream[0], 302);
} else {
throw new Error(`HLS stream URL not found in the response`);
}
} else {
throw new Error(`YouTube URL (${url}) failed with status: ${response.status}`);
}
} else {
throw new Error(`${capitalize(idType)} ID not found in the URL path`);
}
} catch (err) {
return new Response(err.message, { status: 500 });
}
}
function getYouTubePath(idType, identifier) {
switch (idType) {
case 'live':
return `live/${identifier}`;
case 'handle':
return `@${identifier}`;
case 'channel':
return `channel/${identifier}`;
case 'customName':
return `c/${identifier}`;
case 'user':
return `user/${identifier}`;
default:
return '';
}
}
function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}242
Stupid are those who sell or share my script which they bought from me with their own hard earned money. Big Foolish are you guys only.
242
Super Fast and Reliable Webhosting Service Available
Location: India
Variety of Panels Available
- Direct Admin
- Plesk
- cPanel
Bill Monthly, Quarterly, Yearly at your convenience
We are hosting with multiple providers, so that even if one server is down, we provide you free migration to our another server with compensated days.
What are you waiting for? Try our service now. @undevphp
242
Super Fast and Reliable Webhosting Service Available
Location: India
Variety of Panels Available
- Direct Admin
- Plesk
- cPanel
Bill Monthly, Quarterly, Yearly at your convenience
We are hosting with multiple providers, so that even if one server is down, we provide you free migration to our another server with compensated days.
What are you waiting for? Try our service now. @undevphp
242
JioTV Worldwide Script.
Full Runs on Cloudflare Workers.
Limited Time and Availability Script
Demo
@undevphp
242
JioTV Script Working Worldwide, Can Run On Cloudflare Workers Completely on its ON is available.
242
Super Fast and Reliable Webhosting Service Available
Location: India
Variety of Panels Available
- Direct Admin
- Plesk
- cPanel
Bill Monthly, Quarterly, Yearly at your convenience
We are hosting with multiple providers, so that even if one server is down, we provide you free migration to our another server with compensated days.
What are you waiting for? Try our service now. @undevphp
