Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
etapic authored May 24, 2024
1 parent 9267dac commit de4730c
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,34 @@
<title>Kick extract</title>
</head>
<body>
<h2>Pre-set Streamers:</h2>
<div id="presetLinks"></div>


<h2>Enter Live Streamer Name:</h2>
<input type="text" id="streamerName" placeholder="e.g., sam">
<button onclick="fetchM3U8()">Get M3U8</button>

<div id="result" style="margin-top: 20px;"></div>

<script>
async function fetchM3U8() {
const streamerName = document.getElementById("streamerName").value;
const apiUrl = `https://kick.com/api/v1/channels/${streamerName}`;

const presetStreamers = ["sam", "suspendas", "kangjoel"];
function createPresetLinks() {
const linksContainer = document.getElementById("presetLinks");
presetStreamers.forEach(name => {
const link = document.createElement("a");
link.href = "#";
link.textContent = name;
link.onclick = () => fetchM3U8(name, true);
linksContainer.appendChild(link);
});
}


async function fetchM3U8(streamerName = null, redirect = false) {
const name = streamerName || document.getElementById("streamerName").value;
const apiUrl = `https://kick.com/api/v1/channels/${name}`;

try {
const response = await fetch(apiUrl);
Expand All @@ -23,11 +40,15 @@ <h2>Enter Live Streamer Name:</h2>
if (data.playback_url) {
const m3u8Url = data.playback_url;

const resultDiv = document.getElementById("result");
resultDiv.innerHTML = `
<p><span id="m3u8UrlDisplay">${m3u8Url}</span></p>
<button onclick="redirectToM3U8('${m3u8Url}')">Redirect</button>
<button onclick="copyToClipboard('${m3u8Url}')">Copy</button>`;
if (redirect) {
redirectToM3U8(m3u8Url);
} else {
const resultDiv = document.getElementById("result");
resultDiv.innerHTML = `
<p>M3U8 URL: <span id="m3u8UrlDisplay">${m3u8Url}</span></p>
<button onclick="redirectToM3U8('${m3u8Url}')">Redirect</button>
<button onclick="copyToClipboard('${m3u8Url}')">Copy</button>`;
}
} else {
document.getElementById("result").textContent = "Stream not found or offline.";
}
Expand All @@ -48,6 +69,8 @@ <h2>Enter Live Streamer Name:</h2>
alert('Failed to copy: ', err);
}
}

createPresetLinks();
</script>

</body>
Expand Down

0 comments on commit de4730c

Please sign in to comment.