<?php
$supported_services = [
    'patreon',
    'fanbox',
    'fantia',
    'boosty',
    'dlsite',
    'gumroad',
    'subscribestar'
];
if (empty($_GET["id"]) or !in_array($_GET["service"], $supported_services)) {
?>
<html>
    <head>
        <title>Kemono.party Artist to RSS</title>
    </head>
    <body>
        <form method="get">
            <label for="id">
                Kemono Party artist ID: 
            </label>
            <input 
                type="text" 
                id="id" 
                name="id" 
                required 
                spellcheck="false"
            >
            <br>
            <label for="service">
                Service: 
            </label>
            <select 
                name="service" 
                id="service"
                required 
            >
                <option value="">---</option>
                <option value="patreon">Patreon</option>
                <option value="fanbox">Fanbox</option>
                <option value="fantia">Fantia</option>
                <option value="boosty">Boosty</option>
                <option value="dlsite">DLSite</option>
                <option value="gumroad">Gumroad</option>
                <option value="subscribestar">Subscribestar</option>
            </select>
            <br>
            <input type="submit" value="Build RSS feed">
        </form>
    </body>
</html>

<?php
} else {
    header('Content-Type: application/rss+xml');
    $artistId = $_GET["id"];
    $service = $_GET["service"];
    $rawResponse = file_get_contents('https://kemono.party/api/' . $service . '/user/' . $artistId . '/');
    $responseJson = json_decode($rawResponse, true);
?>
<rss version="2.0">
<channel>
    <title></title>
    <description></description>
    <link>https://kemono.party/<?php echo $service; ?>/user/<?php echo $artistId; ?></link>
    <docs>https://www.rssboard.org/rss-2-0</docs>
    <?php foreach ($responseJson as $entry) { ?>
    <item>
        <title><?php echo $entry["title"]; ?></title>
        <description><![CDATA[<?php echo $entry["content"]; ?>]]></description>
        <link>https://kemono.party/<?php echo $service; ?>/user/<?php echo $artistId; ?>/post/<?php echo $entry["id"]; ?></link>
        <pubDate><?php echo $entry["published"]?></pubDate>
        <guid><?php echo $service; ?>-<?php echo $artistId; ?>-<?php echo $entry["id"]; ?></guid>
    </item>
    <?php } ?>
</channel>
</rss>
<?php } ?>
Edit

Pub: 22 Sep 2023 00:35 UTC

Views: 358