-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from luiscarlospando/twitch-live
Agregar notificación Twitch Live (vía Twitch API)
- Loading branch information
Showing
10 changed files
with
104 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Show/Hide Mode 7 Grand Prix Livestream | ||
let DateTime = luxon.DateTime; // Initialization | ||
let dt = DateTime.now().setZone("America/Mexico_City"); | ||
let dayOfTheWeek = dt.weekday; | ||
let time = dt.toFormat('HH'); | ||
|
||
const m7gpLivestreamAlert = document.getElementById("m7gp-livestream-alert"); | ||
const m7gpLivestream = document.getElementById("m7gp-livestream"); | ||
const btnM7GP = document.getElementById("btn-m7gp"); | ||
|
||
const luisCarlosPandoLivestream = document.getElementById("luiscarlospando-livestream"); | ||
const luisCarlosPandoChat = document.getElementById("luiscarlospando-chat"); | ||
const btnLuisCarlosPando = document.getElementById("btn-luiscarlospando"); | ||
|
||
// Twitch badges | ||
const badgeTwitchMijo = document.getElementById("badge-twitch-mijo"); | ||
const badgeTwitchSkynet = document.getElementById("badge-twitch-skynet"); | ||
|
||
// Display livestream and livestream alert only on Thursday nights | ||
if (dayOfTheWeek == 4 && (time >= 21 && time < 23)) { | ||
if (m7gpLivestream && btnM7GP && luisCarlosPandoLivestream && luisCarlosPandoChat && btnLuisCarlosPando) { | ||
m7gpLivestream.style.display = "block"; | ||
btnM7GP.style.display = "inline-block"; | ||
badgeTwitchSkynet.style.display = "inline-block"; | ||
|
||
luisCarlosPandoLivestream.style.display = "none"; | ||
luisCarlosPandoChat.style.display = "none"; | ||
btnLuisCarlosPando.style.display = "none"; | ||
badgeTwitchMijo.style.display = "none"; | ||
} | ||
|
||
m7gpLivestreamAlert.style.display = "block"; | ||
} else { | ||
if (m7gpLivestream && btnM7GP) { | ||
m7gpLivestream.style.display = "none"; | ||
btnM7GP.style.display = "none"; | ||
badgeTwitchSkynet.style.display = "none"; | ||
} | ||
|
||
m7gpLivestreamAlert.style.display = "none"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Function to fetch live status from Twitch API | ||
function checkLiveStatus() { | ||
const clientId = 'vfumpr4f4psz8fm5k2bs0zupvrtgge'; // Replace with your Twitch Client ID | ||
const channelName = 'mijodido'; // Replace with your Twitch Channel Name | ||
const twitchLivestreamAlert = document.getElementById("twitch-livestream-alert"); | ||
|
||
fetch(`https://api.twitch.tv/helix/streams?user_login=${channelName}`, { | ||
headers: { | ||
'Client-ID': clientId, | ||
'Authorization': 'Bearer 17dobh8sk5k9jk7zhpy6epl2b0klbz' // Replace with your Twitch Access Token | ||
} | ||
}) | ||
.then(response => response.json()) | ||
.then(data => { | ||
if (data.data.length > 0) { | ||
twitchLivestreamAlert.style.display = "block"; | ||
} else { | ||
twitchLivestreamAlert.style.display = "none"; | ||
} | ||
}) | ||
.catch(error => console.error('Error fetching live status:', error)); | ||
} | ||
|
||
// Call the function after document is fully loaded | ||
document.addEventListener("DOMContentLoaded", function() { | ||
checkLiveStatus(); | ||
|
||
// Call the function every 1 minute (or adjust the interval as needed) | ||
setInterval(checkLiveStatus, 60000); // 60000 milliseconds = 1 minute | ||
}); | ||
|
||
// Call the function initially | ||
checkLiveStatus(); | ||
|
||
// Call the function every 1 minute (or adjust the interval as needed) | ||
setInterval(checkLiveStatus, 60000); // 60000 milliseconds = 1 minute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38867e4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
luiscarlospando-com – ./
luiscarlospando-com.vercel.app
luiscarlospando-com-luiscarlospando.vercel.app
luiscarlospando-com-git-main-luiscarlospando.vercel.app
www.luiscarlospando.com
luiscarlospando.com