Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPTV plugin update: follow redirects #195

Open
Vintic opened this issue Mar 1, 2024 · 0 comments
Open

IPTV plugin update: follow redirects #195

Vintic opened this issue Mar 1, 2024 · 0 comments

Comments

@Vintic
Copy link

Vintic commented Mar 1, 2024

I have a playlist that requires generating special token, once a day.
So I created a script, that generate this token and replace it in the playlist, then redirect you to newly created playlist.

But IPTV plugin seems doesn't understand this redirect, and don't read it.

Could you update it please.

Here is my script that generates m3u playlist with token

<!DOCTYPE html>
<html lang="en">
    <head>
        <script>
            function generateToken() {
                fetch('https://token.example.com/gettoken.json')
                    .then(response => response.json())
                    .then(data => {
                        const tokenRegex = /token=([^&]*)/;
                        const match = data.variants[0].url.match(tokenRegex);
                        let token = ''
                        if (match && match[1]) {
                            token = match[1];
                        }
                        return token;
                    })
                    .catch(error => console.error('Error:', error));
                return 1;
            }

            function generateM3UContent(token) {
                const m3uContent = `#EXTM3U
#EXTINF:-1 catchup="append" catchup-days="7" catchup-type="flussonic",ch1
http://example.com/ch1/video.m3u8?token=${token}
#EXTINF:-1 catchup="append" catchup-days="7" catchup-type="flussonic",ch2
http://example.com/ch2/video.m3u8?token=${token}
`;

                return m3uContent;
            }

            function useRedirectMethod(content){
                const dataUri = 'data:application/x-mpegURL;charset=utf-8,' + encodeURIComponent(content);

                // Redirect the user to the data URI
                window.location.href = dataUri;
            }
        </script>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Get M3U File</title>
    </head>
    <body>
    <script>
        const new_token = generateToken()
        const new_m3uContent = generateM3UContent(new_token);
        useRedirectMethod(new_m3uContent);
    </script>
    </body>
</html>
@Vintic Vintic changed the title IPTV plugin update: follwo redirects IPTV plugin update: follow redirects Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant