pub / yt2rss

Transforms a youtube channel into a podcast RSS feed to insert into a podcatcher
git clone https://src.jayvii.de/pub/yt2rss.git
Home | Log | Files | Exports | Refs | Submodules | README | LICENSE | RSS

commit 2a128ada261858d78abcc10d9f87598d6a59e803
parent 068d73cf8dcd7b6cb680d02bea641fbc4d5ca7bb
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date:   Sat, 20 Apr 2024 15:19:03 +0200

implement authentication system

Diffstat:
Mindex.php | 41+++++++++++++++++++++++++++++++++++------
1 file changed, 35 insertions(+), 6 deletions(-)

diff --git a/index.php b/index.php @@ -84,7 +84,12 @@ if (!is_null($_GET["channel"]) && $auth) { $rss_xml = $rss_xml . "<itunes:image href=\"https://i4.ytimg.com/vi/" . $video_id . "/hqdefault.jpg\"/>\n"; $rss_xml = $rss_xml . "<atom:link href=\"https://" . - $_SERVER["SERVER_NAME"] . "/?channel=" . basename($_GET["channel"]) . "\"" . + $_SERVER["SERVER_NAME"] . + "/?channel=" . basename($_GET["channel"]); + if (!is_null($auth_key)) { + $rss_xml = $rss_xml . "&amp;auth=" . $auth_key; + } + $rss_xml = $rss_xml . "\"" . " rel=\"self\" type=\"application/rss+xml\"/>\n"; // Add media items @@ -135,7 +140,12 @@ if (!is_null($_GET["channel"]) && $auth) { $rss_xml = $rss_xml . "<itunes:image href=\"https://i1.ytimg.com/vi/" . $video_id . "/hqdefault.jpg\"/>\n"; $rss_xml = $rss_xml . "<enclosure url=\"https://" . - $_SERVER["SERVER_NAME"] . "/?video=" . $video_id . "\"". + $_SERVER["SERVER_NAME"] . + "/?video=" . $video_id; + if (!is_null($auth_key)) { + $rss_xml = $rss_xml . "&amp;auth=" . $auth_key; + } + $rss_xml = $rss_xml . "\"". " type=\"" . $video_ftype . "\" length=\"" . $video_size . "\"/>\n"; $rss_xml = $rss_xml . "<itunes:duration>" . $video_duration . "</itunes:duration>\n"; @@ -186,17 +196,36 @@ if (!is_null($_GET["channel"]) && $auth) { echo "<html><head><title>yt2rss</title></head><body>"; echo "<h1>yt2rss</h1>"; echo "<p><a href=\"https://codeberg.org/jayvii/yt2rss\">Learn more</a></p>"; + + // Usage Info echo "<p>Usage:</p>"; echo "<ul>"; echo "<li>https://" . $_SERVER["SERVER_NAME"] . "/?channel=UCt_Y3j8CpXx366et1RaHACA</li>"; echo "<li>https://" . $_SERVER["SERVER_NAME"] . "/?video=TV8tEq56vHI</li>"; echo "</ul>"; + echo "<p>Videos can be included or excluded based on title-matches:</p>"; + echo "<ul>"; + echo "<li>Include only videos whose title contain \"vlog time\":" . PHP_EOL . "https://" . $_SERVER["SERVER_NAME"] . + "/?channel=UCt_Y3j8CpXx366et1RaHACA&include=vlog%20time</li>"; + echo "<li>Exclude all videos whose title contain \"vlog time\":" . PHP_EOL . "https://" . $_SERVER["SERVER_NAME"] . "/?channel=UCt_Y3j8CpXx366et1RaHACA&exclude=vlog%20time</li>"; + echo "</ul>"; + + // Authentification if (!is_null($auth_key)) { - echo "<p>This Service requires an authnetification key." . - "If you have one, add it to the request URLs with " . - "\"&amp;auth=MY_KEY\". " . - "If you do not have one (yet), please contact the server admin."; + echo "<p>This Service requires an authentification key. " . + "If you have one, add it to the request URLs with:</p>"; + echo "<ul>"; + echo "<li>https://" . $_SERVER["SERVER_NAME"] . + "/?auth=MY_KEY&channel=UCt_Y3j8CpXx366et1RaHACA</li>"; + echo "<li>https://" . $_SERVER["SERVER_NAME"] . "/?auth=MY_KEY&video=TV8tEq56vHI</li>"; + echo "</ul>"; + echo "<p>If you do not have an authentification key, please contact the server admin.</p>"; + if ($auth) { + echo "<p style='color:white;background-color:green;'>You are authenticated :)</p>"; + } else { + echo "<p style='color:white;background-color:red;'>You are NOT authenticated :(</p>"; + } } echo "</body></html>"; }