Last active
August 11, 2023 17:26
-
-
Save richardbenson/2228319 to your computer and use it in GitHub Desktop.
Turn Steam screenshots into RSS feed
This file contains hidden or 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
<?php | |
header("Content-Type: application/rss+xml; charset=utf-8"); | |
error_reporting(E_ALL); | |
ini_set("display_errors", 0); | |
define('STEAM_USER', $_GET['u']); | |
define('LIST_URL', "http://steamcommunity.com/id/".STEAM_USER."/screenshots/?appid=0&sort=newestfirst&browsefilter=myfiles&view=grid"); | |
include('extlib/ganon/ganon.php'); | |
$html = file_get_dom(LIST_URL); | |
$rssfeed = '<?xml version="1.0" encoding="utf-8"?>' . "\n"; | |
$rssfeed .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">' . "\n"; | |
$rssfeed .= '<channel>' . "\n"; | |
$rssfeed .= ' <atom:link href="http://richardbenson.co.uk/steam/get-screenshot-feed.php?u='.STEAM_USER.'" rel="self" type="application/rss+xml" />' . "\n"; | |
$rssfeed .= ' <title>Screenshots for '.STEAM_USER.'</title>' . "\n"; | |
$rssfeed .= ' <link>http://steamcommunity.com/id/'.STEAM_USER.'/screenshots/</link>' . "\n"; | |
$rssfeed .= ' <description>Showing screenshots from '.STEAM_USER.'</description>' . "\n"; | |
$rssfeed .= ' <language>en-us</language>' . "\n"; | |
$rssfeed .= ' <copyright>Feed copyright '.STEAM_USER.', images copyright their respective owners</copyright>' . "\n"; | |
//$rssfeed .= '<atom:link href="'.$_SERVER['REQUEST_URI'].'" rel="self" type="application/rss+xml" />'; | |
foreach($html('.profile_media_item') as $element) { | |
$nodes = $element('.imgWallHoverDescription q'); | |
if (count($nodes)>0) $title = $nodes[0]->getInnerText(); | |
else $title = "(untitled)"; | |
$nodes = $element('img'); | |
if (count($nodes)>0) $thumb = $nodes[0]->src; | |
else $thumb = ""; | |
$nodes = $element('div.imgWallItem'); | |
$nodeID = $nodes[0]->id; | |
$itemID = str_replace('imgWallItem_','',$nodeID); | |
$link = "http://steamcommunity.com/sharedfiles/filedetails/?id=" . $itemID; | |
$fullSize = ""; | |
$thumbArray = explode("?", $thumb); | |
parse_str($thumbArray[1], $thumbQSArray); | |
$thumbEncoded = $thumbArray[0] . "?" . http_build_query($thumbQSArray); | |
$rssfeed .= ' <item>' . "\n"; | |
$rssfeed .= ' <title><![CDATA[' . ($title) . ']]></title>' . "\n"; | |
$rssfeed .= ' <description><![CDATA[' . $thumb . ']]></description>' . "\n"; | |
$rssfeed .= ' <link>' . $link . '</link>' . "\n"; | |
$rssfeed .= ' <guid>' . $link . '</guid>' . "\n"; | |
//$rssfeed .= '<pubDate>' . date("D, d M Y H:i:s O", $shot_info["timecreated"]) . '</pubDate>'; | |
$rssfeed .= ' <media:thumbnail url="' . $thumbEncoded . '" />' . "\n"; | |
//$rssfeed .= '<image><url>' . $thumb . '</url></image>'; | |
$rssfeed .= ' </item>' . "\n"; | |
} | |
$rssfeed .= '</channel>' . "\n"; | |
$rssfeed .= '</rss>'; | |
echo $rssfeed; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should sanitize line 7. Never trust data that is coming in.