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

Can you tell me.. What the error.. I tried lots of ways but I filed. #4

Open
jihadkhan opened this issue Jan 6, 2024 · 0 comments
Open

Comments

@jihadkhan
Copy link

Boss do you have code for html web or PHP website? I tried lots of ways but I filed.

here is my code: can you check my code please .. if there have any issue can you fix for me? please boss..

 <div class="container mt-5">
  <h1>Toffee Channels</h1>
  <div id="my-video" class="mt-5"></div>
  <div id="channelGrid" class="row"></div>
</div>

<script src="//jwpsrv.com/library/O4mPlqeTEeK_viIACpYGxA.js"></script>
<script>
  document.addEventListener('DOMContentLoaded', function() {
    async function fetchHeadersAndCookies() {
      try {
        const response = await fetch('https://raw.githubusercontent.com/Jeshan-akand/Toffee-Channels-Link-Headers/main/toffee_channel_data.json');
        const data = await response.json();
        return data;
      } catch (error) {
        console.error('Error fetching headers and cookies:', error);
        return {};
      }
    }

    async function displayChannels(channels) {
      const channelGrid = document.getElementById('channelGrid');
      channels.forEach(channel => {
        const channelItem = document.createElement('div');
        channelItem.className = 'col-3';

        const channelLogo = document.createElement('img');
        channelLogo.src = channel.logo;
        channelLogo.alt = channel.name + ' Logo';
        channelLogo.className = 'channel-logo';
        channelItem.appendChild(channelLogo);

        const channelLink = document.createElement('a');
        channelLink.href = '#';
        channelLink.textContent = channel.name;
        channelLink.addEventListener('click', async function(event) {
          event.preventDefault();

          const videoLink = channel.link;
          const { headers, cookie } = await fetchHeadersAndCookies();

          playVideo(videoLink, headers, cookie);
        });
        channelItem.appendChild(document.createElement('br'));
        channelItem.appendChild(channelLink);

        channelGrid.appendChild(channelItem);
      });
    }

    function playVideo(videoLink, headers, cookie, logo) {
      jwplayer('my-video').setup({
        file: videoLink,
        width: '100%',
        height: 450,
        autostart: false,
        image: logo,
        primary: 'html5',
        hlshtml: true,
        skin: {
          name: 'roundster',
          active: '#FF0000',
          inactive: '#CCCCCC',
          background: '#FFFFFF'
        },
        headers: {
          ...headers,
          'Host': 'bldcmprod-cdn.toffeelive.com',
          'Cookie': cookie // Set the retrieved cookies
        }
      });
    }

    fetch('https://raw.githubusercontent.com/Jeshan-akand/Toffee-Channels-Link-Headers/main/toffee_channel_data.json')
      .then(response => response.json())
      .then(data => displayChannels(data.channels))
      .catch(error => console.error('Error fetching data:', error));
  });
</script>
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