gemhltv/gemhltv_news

46 lines
1.3 KiB
Plaintext
Raw Permalink Normal View History

2021-04-06 19:40:04 +00:00
#!/usr/bin/php
<?php
2021-04-06 23:45:58 +00:00
# its in php because I got lazy and just stripped down news.php
# cool language tho it gets too much hate
2021-04-07 04:02:26 +00:00
$LOGO_FILE = "/var/gemini-data/logos/gemhltv_news";
# ^^^^^^^^ path to file containing the text to be displayed at the top of the
# page
2021-04-06 19:40:04 +00:00
2021-04-08 00:55:01 +00:00
$READER_LINK = dirname(__PATH__) . "/reader";
2021-04-07 04:02:26 +00:00
# ^^^^^^^^^^ uri path to an instance of reader.php
2021-04-06 19:40:04 +00:00
# the default is relative, and assumes you have one in the same directory as
# this script
$feed_title = "";
$node_description = "";
$feed = new XMLReader;
$feed->open("https://hltv.org/news.rss.php");
$feed->read();
echo "```\n";
2021-04-07 04:02:26 +00:00
echo file_get_contents($LOGO_FILE);
2021-04-06 19:40:04 +00:00
echo "```\n";
while ($feed->read()) {
if ( $feed->name === "item") {
$children = $feed->expand();
foreach ($children->childNodes as $child) {
if ( $child->nodeType === XML_TEXT_NODE ) { continue; }
if ( $child->tagName === "title" ) {
echo "\n## " . $child->nodeValue . "\n";
}
if ($child->tagName === "description") {
$story_description = $child->nodeValue;
}
if ($child->tagName === "link") {
$link = $READER_LINK . "?" . urlencode($child->nodeValue);
echo "=> " . $link . " " . $story_description . "\n";
}
}
}
}
$feed->close();