pub / tw2html

Checks online status of streams on twitch.tv and lets you watch them
git clone https://src.jayvii.de/pub/tw2html.git
Home | Log | Files | Exports | Refs | README | RSS

commit c12f711075c6a3d8c131c6fe6a84be347b23723f
parent 4da0f2c1af9de7a6b4a2979158ad52f4b58b2b71
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date:   Mon, 21 Oct 2024 17:21:55 +0200

fix: remove unrequired files

Diffstat:
Dlib/build_html.php | 53-----------------------------------------------------
Dlib/load_streams.php | 84-------------------------------------------------------------------------------
Dlib/loadingscreen.php | 43-------------------------------------------
3 files changed, 0 insertions(+), 180 deletions(-)

diff --git a/lib/build_html.php b/lib/build_html.php @@ -1,53 +0,0 @@ -<!-- SPDX-License-Identifier: AGPL-3.0-or-later - SPDX-FileCopyrightText: 2024 JayVii <jayvii[AT]posteo[DOT]de> ---> - -<?php - -// Build "article" section if stream is online -for ($i = 0; $i < sizeof($streams["stream"]); $i++) { - if ($streams["status"][$i] > 0) { - -?> - -<section class="streamlisting" id="stream_<?php echo $streams["stream"][$i]; ?>"> - <h2> - <a href="https://www.twitch.tv/<?php echo $streams["stream"][$i]; ?>"> - <?php echo $streams["stream"][$i] . ": " . $streams["desc"][$i]; ?> - </a> - </h2> - <a - href="#stream_<?php echo $streams["stream"][$i]; ?>" - onclick="toggle_player('<?php echo $streams["stream"][$i]; ?>');" - > - <img - class="preview" - id="img-<?php echo $streams["stream"][$i]; ?>" - src="https://static-cdn.jtvnw.net/previews-ttv/live_user_<?php echo $streams["stream"][$i]; ?>-1280x720.jpg" - loading="lazy" - > - </a> - <details class="button"> - <summary onclick="toggle_chat('<?php echo $streams["stream"][$i]; ?>');"> - Chat - </summary> - <div class="chatwrapper"> - <div id="chat-placeholder-<?php echo $streams["stream"][$i]; ?>"> - </div> - </div> - </details> -</section> - -<?php - - } -} - -// Color of save button -if (implode(",", $streams["stream"]) == $_COOKIE["streams"]) { - $save_col = "#006164"; -} else { - $save_col = "#db4325"; -} - -?> diff --git a/lib/load_streams.php b/lib/load_streams.php @@ -1,84 +0,0 @@ -<!-- SPDX-License-Identifier: AGPL-3.0-or-later - SPDX-FileCopyrightText: 2024 JayVii <jayvii[AT]posteo[DOT]de> ---> - -<?php - -// Check Online Status of streams -for ($i = 0; $i < sizeof($streams["stream"]); $i++) { - - // Fetch Stream Preview Image - $img = file_get_contents( - "https://static-cdn.jtvnw.net/previews-ttv/live_user_" . - $streams["stream"][$i] . - "-853x480.jpg" - ); - - // Check Online-Status via HTTP status code - $http_code = preg_replace( - '/^.*(\d{3}).*/', - '\1', - $http_response_header[0] - ); - - if (!($http_code == "200")) { - - // Stream is not online! - array_push($streams["status"], 0); - $desc = ""; - $game = ""; - - } else { - - // Stream is online! - array_push($streams["status"], 1); - - // Fetch HTML - $html = file_get_contents( - "https://m.twitch.tv/" . $streams["stream"][$i] - ); - $html = str_replace(array("\r", "\n"), "", $html); - - // Parse Game Name - $pattern = '/^.*<p.*?Playing <a.*?>(.*?)<\/a>.*$/'; - $replacement = '\1'; - $game = substr( - strip_tags( - preg_replace( - $pattern, - $replacement, - $html - ) - ), - 0, - 50 - ); - - // Parse Stream Description - $html = preg_replace('/<script.*<\/script>/', '', $html); - $html = explode(">", $html); - $desc_raw = implode("", preg_grep('/name="description"/', $html)); - $pattern = '/^.*content="(.*?)".*$/'; - $replacement = '\1'; - $desc = substr( - strip_tags( - preg_replace( - $pattern, - $replacement, - $desc_raw - ) - ), - 0, - 500 - ); - - } - - // Fill Streams array - array_push($streams["desc"], $desc); - array_push($streams["game"], $game); - array_push($streams["time"], (time() - $time0)); - -} - -?> diff --git a/lib/loadingscreen.php b/lib/loadingscreen.php @@ -1,43 +0,0 @@ -<!-- SPDX-License-Identifier: AGPL-3.0-or-later - SPDX-FileCopyrightText: 2024 JayVii <jayvii[AT]posteo[DOT]de> ---> - -<h1 style="text-align:center;">Please be patient</h1> - -<p style="text-align:center;"> - Loading <?php echo sizeof($streams["stream"]); ?> streams. This may take a - moment. -</p> - -<br> - -<!-- Loading Screen Animation --> -<div class="wrapper-loading"> - <div class="box-wrap"> - <div class="box one"></div> - <div class="box two"></div> - <div class="box three"></div> - <div class="box four"></div> - <div class="box five"></div> - <div class="box six"></div> - </div> -</div> - -<!-- single quotes required, due to serialization --> -<form id="channels" action="/" method="post"> - <input - type="hidden" - id="streams" - name="streams" - value='<?php echo serialize($streams["stream"]); ?>' - > -</form> - -<!-- Form Submitter --> -<script> - setTimeout( - function(){ - document.querySelector("#channels").submit(); - }, - 1); -</script>