dtankdempse / m3u-playlist-proxy

The M3U Playlist Proxy is a lightweight and effective tool designed to forward essential headers to proxy M3U playlist streams.
GNU General Public License v3.0
29 stars 10 forks source link

Question #8

Open Webx123 opened 19 hours ago

Webx123 commented 19 hours ago

Did daddylive block Vercel too? was working up till last night but today i cant get it to play

dtankdempse commented 18 hours ago

I just tested my Vercel setup with the Daddylive playlist, and it's working. Try clicking on 'Logs' to check for any errors.

Webx123 commented 18 hours ago

it looks like its pulling the mono link but its showing blocked Screenshot_12

dtankdempse commented 17 hours ago

Are you running this from a website and using MPP to proxy the stream? "Mixed Block" can have different meanings, but I notice the URL is set to use the https:// protocol. If you're loading the page over http://, try accessing it over https:// instead, or vice versa, to see if that resolves the issue.

Here's an explanation from AI on what 'Mixed Block' could mean when streaming.

1. Mixed Content Block (HTTP and HTTPS) If a video player on an HTTP page loads an HTTPS stream (or vice versa), it may trigger mixed content warnings or be blocked by browsers as insecure.

2. Mixed Protocols (Different Streaming Protocols) Using multiple protocols, like HLS and DASH, within the same stream can cause playback issues if the player isn’t optimized for switching protocols mid-stream.

3. Network-Level Mixed Blocks Firewalls may block content delivered over unexpected protocols or ports. For instance, mixing HTTP and HTTPS data in one stream could be blocked by some network settings.

4. Mixed Codecs or Bitrates Adaptive streaming that changes codecs or bitrates mid-stream may lead to playback interruptions if players or networks interpret the changes as a potential threat.

Summary "Mixed Block" issues are caused by protocol, content, or network mismatches. To avoid them, use consistent protocols (preferably HTTPS), keep codecs uniform, and test on various networks to prevent blocks or security flags.

Webx123 commented 17 hours ago

no i am using HTTPs for both the proxy and the page thats whats throwing me off its been working day and even was late last night it just started not working this morning

dtankdempse commented 16 hours ago

If you have a web server, I have a PHP script for proxying streams directly from a webpage. I’m not sure what the issue could be. I tested my Vercel URL from a webpage and it’s working on my end.

Webx123 commented 16 hours ago

i do have a webserver where would i find the PHP script ?

dtankdempse commented 16 hours ago

Ok, here you go. Check the Read me file to learn how to use it.

proxy.zip

Webx123 commented 15 hours ago

hmm seems to play fine on VLC player and all using that route but still cant get it to play on a player like Jwplayer or Plyr.js player like it was last night

dtankdempse commented 15 hours ago

Are you getting the same "Mixed Block" error in the console?

Webx123 commented 15 hours ago

yes seems so

dtankdempse commented 15 hours ago

Have you tried running the same code on a different website or locally? It might be an issue with your setup. Try adding your URL to the HTML code below, create a test page, and see if it works.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HLS Stream Test with Plyr</title>
    <link rel="stylesheet" href="https://cdn.plyr.io/3.6.12/plyr.css" />
    <script src="https://cdn.plyr.io/3.6.12/plyr.polyfilled.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
</head>
<body>
    <h1>Test HLS Stream Player with Plyr.js</h1>
    <video id="player" controls></video>

    <script>
        const videoSrc = "http://YOUR_WEB_SERVER_OR_VERCEL_URL?url=https%3A%2F%2Fxyzdddd.mizhls.ru%2Flb%2Fpremium303%2Findex.m3u8%0D&data=UmVmZXJlcj1odHRwczovL2lsb3ZldG9wbGF5Lnh5ei98VXNlci1BZ2VudD1Nb3ppbGxhLzUuMCAoWDExOyBMaW51eCB4ODZfNjQpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIENocm9tZS8xMjkuMC4wLjAgU2FmYXJpLzUzNy4zNnxPcmlnaW49aHR0cHM6Ly9pbG92ZXRvcGxheS54eXo%3D";
        const video = document.getElementById('player');

        if (Hls.isSupported()) {
            const hls = new Hls();
            hls.loadSource(videoSrc);
            hls.attachMedia(video);
            hls.on(Hls.Events.MANIFEST_PARSED, () => {
                video.play();
            });
        } else if (video.canPlayType('application/vnd.apple.mpegurl')) {           
            video.src = videoSrc;
        } else {
            alert("Your browser does not support HLS streaming.");
        }

        const player = new Plyr(video, {
            controls: ['play', 'progress', 'current-time', 'mute', 'volume', 'settings', 'fullscreen'],
            settings: ['quality', 'speed'],
            autoplay: true
        });
    </script>
</body>
</html>
Webx123 commented 15 hours ago

interesting they must have blocked my domain or something i moved it to a Free host like 000Webhost and its playing

Webx123 commented 15 hours ago

it may be because i use cloudflare with my website? so my website ip is proxied but that dont make sense why it wouldnt play using vercel anymore iframed onto my website like i was using it

dtankdempse commented 15 hours ago

Daddylive shouldn’t be able to see your domain when using the Vercel proxy, as all requests are routed through Vercel. The problem may lie with your web server blocking the stream, or something, i'm not sure.

Try using the same code I sent you, but replace the file with this link: https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8 and see if it plays on your webserver.

dtankdempse commented 15 hours ago

it may be because i use cloudflare with my website? so my website ip is proxied but that dont make sense why it wouldnt play using vercel anymore iframed onto my website like i was using it

Right, I'm curious to know what the problem is myself. I'm nerdy that way lol.

Webx123 commented 15 hours ago

i use a good offshore webhost and like i said its been working for days so i dont think my webserver would be doing it esp iframing from vercel or 000 to it? im so confused lol im super curious aswell let me try https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8

Webx123 commented 15 hours ago

that one plays fine

dtankdempse commented 15 hours ago

After your said Cloudflare is involved I asked ChatGPT and it replied:

Yes, if Cloudflare is used with a site and its settings aren’t configured correctly, it can cause mixed content issues, especially when content is proxied or embedded through an iframe. Here are some common Cloudflare settings to check that might help resolve the mixed content block: Key Cloudflare Settings to Check

SSL/TLS Mode: Ensure Cloudflare’s SSL/TLS mode is set to Full or Full (Strict). This will ensure that all traffic between Cloudflare and the origin server is encrypted, which can reduce mixed content warnings.

Automatic HTTPS Rewrites: Enable Automatic HTTPS Rewrites. This will help force all resources loaded on the site (like embedded content) to use HTTPS, even if they’re referenced as HTTP.

Content Security Policy (CSP): If a CSP is set up, make sure it allows resources from Vercel. Sometimes, CSP can block iframed or proxied content by enforcing stricter content sources. Add Vercel’s domains (e.g., vercel.app) as an allowed source if CSP is blocking it.

Cloudflare Firewall: If Cloudflare’s firewall or security rules are enabled, make sure there are no rules blocking Vercel’s IP ranges or specific resources being loaded through Vercel.

Mixed Content Mode in Cloudflare: Cloudflare has an option under SSL/TLS settings called Enable Always Use HTTPS. If this is enabled, it might help ensure that even proxied resources use HTTPS, preventing mixed content blocks.

Summary

Enabling Automatic HTTPS Rewrites and setting SSL/TLS to Full are typically the most helpful steps. Additionally, reviewing any CSP or firewall rules that might limit cross-origin requests will help prevent the mixed content block.

Webx123 commented 15 hours ago

i have auto https turned on tho and thats whats confusing ive changed zero settings and it was working fine until this morning its wild lol if you wanna test tho you can test on my test server https://****/proxytest/hls_proxy.php and you can test any player code here https://****/proxytest/testcode.php

dtankdempse commented 14 hours ago

I tested your server, and I'm getting a 'CORS Missing Allow Origin' error. I'm not sure why this is happening since the headers are included in the proxy script.

Webx123 commented 14 hours ago

yeah its odd because https://**/proxytest/hls_proxy.php?url=https://xyzdddd.mizhls.ru/lb/premium303/index.m3u8 &data=UmVmZXJlcj1odHRwczovL2lsb3ZldG9wbGF5Lnh5ei98VXNlci1BZ2VudD1Nb3ppbGxhLzUuMCAoWDExOyBMaW51eCB4ODZfNjQpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIENocm9tZS8xMjkuMC4wLjAgU2FmYXJpLzUzNy4zNnxPcmlnaW49aHR0cHM6Ly9pbG92ZXRvcGxheS54eXo= plays fine on VLC its just the player wont play it any longer and it shouldnt be a cors issue on my end i do have it blocked so others cant iframe my stuff but im trying to iframe it on my url so it shouldnt be a issue playing on its orgin server..

Webx123 commented 13 hours ago

i fixed it i had to update the php to force use of https:// using

function locateBaseURL() {
    global $userSetHost;
    $protocol = "https://"; // Force HTTPS

    $domain = isset($userSetHost) && !empty($userSetHost) ? $protocol . $userSetHost : $protocol . $_SERVER['HTTP_HOST'];

    $scriptDir = dirname($_SERVER['SCRIPT_NAME']);
    $scriptDir = ($scriptDir === '/' || $scriptDir === '\\') ? '' : trim($scriptDir, '/\\');

    $baseUrl = rtrim($domain, '/') . '/' . $scriptDir;
    $baseUrl = rtrim($baseUrl, '/') . '/'; // Ensure only one trailing slash

    return $baseUrl;
}

works great now thanks man!

Webx123 commented 13 hours ago

thanks man this php script is awesome i was also able to lock it down so people cant use the proxy url and use up resources with

// Allow only specific domains to use this script
$allowedDomains = ['domain1', 'domain2'];

$referer = $_SERVER['HTTP_REFERER'] ?? '';
$isAllowed = false;

// Check if the referer matches one of the allowed domains
foreach ($allowedDomains as $domain) {
    if (strpos($referer, $domain) === 0) {
        $isAllowed = true;
        break;
    }
}

// Deny access if the referer does not match
if (!$isAllowed) {
    http_response_code(403);
    echo 'Access forbidden: This resource can only be used on approved domains.';
    exit;
}
Webx123 commented 12 hours ago

do you have a copy of a php proxy script that works with normal m3u8s? not like

function fetchEncryptionKey($url, $data) {
    if (isset($_GET['key']) && $_GET['key'] === 'true') {

        // Handler for daddylive
        if (strpos($url, 'premium') !== false && strpos($url, 'number') !== false) {
            $url = str_replace('key2.', 'key.', $url);
        }
        $decodedData = base64_decode($data);
        $parts = explode('|', $decodedData);
        $maxRedirects = 5;
        $headers = [];

        foreach ($parts as $headerData) {
            if (strpos($headerData, '=') !== false) {
                list($header, $value) = explode('=', $headerData, 2);
                $headers[] = trim($header) . ": " . trim($value, "'\"");
            }
        }

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_MAXREDIRS, $maxRedirects);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

        $response = curl_exec($ch);
        curl_close($ch);

        $etag = '"' . md5($response) . '"';
        if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) {
            header("HTTP/1.1 304 Not Modified");
            exit;
        }

Ones with Keys like that set for Daddyslive but normal ones like https://35ridevuhmrd.ubuntu-devs.top/AccessLog2/108087_SD/apache.m3u8 ref: https://35ridevuhmrd.ubuntu-devs.top/group2/secure2/?line=108087_SD that just need a Reefer to play but dont need a key

dtankdempse commented 11 hours ago

The script is already set up to handle playlists with or without encryption keys, if present. It should stream the playlist as long as the necessary headers are included in the request. I tested the link you sent me and its working.

http://IP_OR_DOMAIN/hls_proxy.php?url=https%3A%2F%2F35ridevuhmrd.ubuntu-devs.top%2FAccessLog2%2F108087_SD%2Fapache.m3u8&data=UmVmZXJlcj1odHRwczovLzM1cmlkZXZ1aG1yZC51YnVudHUtZGV2cy50b3AvZ3JvdXAyL3NlY3VyZTIvP2xpbmU9MTA4MDg3X1NE

I didn't realize I hardcoded the protocol in the script, thanks for pointing it out. Glad to hear it’s working now.

Webx123 commented 11 hours ago

it hates me lol http://ip_or_domain/hls_proxy.php?url=https%3A%2F%2F35ridevuhmrd.ubuntu-devs.top%2FAccessLog2%2F108087_SD%2Fapache.m3u8&data=UmVmZXJlcj1odHRwczovLzM1cmlkZXZ1aG1yZC51YnVudHUtZGV2cy50b3AvZ3JvdXAyL3NlY3VyZTIvP2xpbmU9MTA4MDg3X1NE dont work for me like there no errors either its odd Screenshot_13 its outputting /hls_proxy.php?url2=https://35ridevuhmrd.ubuntu-devs.top/AccessLog2/apache_20240523120123.ts&data=UmVmZXJlcj1odHRwczovLzM1cmlkZXZ1aG1yZC51YnVudHUtZGV2cy50b3AvZ3JvdXAyL3NlY3VyZTIvP2xpbmU9MTA4MDg3X1NE&type=/index.ts so youd think it would be working

it wont even work in VLC for me with this one

dtankdempse commented 9 hours ago

I'll take a look at the PHP script. I created that script when I first started learning PHP, so I'm sure it has some problems.

Webx123 commented 7 hours ago

Sweet man i appreciate the help