Last active
December 22, 2015 18:19
-
-
Save donatj/6511860 to your computer and use it in GitHub Desktop.
Turn the Penny Arcade DLC page into a *real* podcast.
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 | |
date_default_timezone_set('America/Chicago'); | |
$subject = file_get_contents("http://penny-arcade.com/dlc"); | |
preg_match_all('%<li[ >].*?<h4>(?P<title>.*?)</h4>.*?class="paDLCLink"[^>]href="(?P<file>.*?)".*?</li%si', $subject, $result, PREG_SET_ORDER); | |
header('Content-Type: application/rss+xml'); | |
echo '<?xml version="1.0" encoding="UTF-8"?>'; | |
?> | |
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:media="http://search.yahoo.com/mrss/"> | |
<channel> | |
<title>Penny Arcade Podcast Test</title> | |
<pubDate>Mon, 19 Aug 2013 17:16:00 +0000</pubDate> | |
<lastBuildDate>Thu, 05 Sep 2013 14:56:10 +0000</lastBuildDate> | |
<link>http://penny-arcade.com/dlc</link> | |
<language>en</language> | |
<copyright><![CDATA[Penny Arcade, Jerry Holkins, Mike Krahulik]]></copyright> | |
<description><![CDATA[Penny Arcade Podcast!]]> | |
</description> | |
<image> | |
<url>http://hw1.pa-cdn.com/pa/assets/img/logo_penny_arcade.png</url> | |
<title>Penny Arcade Podcast Test</title> | |
<link> | |
<![CDATA[http://penny-arcade.com/dlc]]></link> | |
</image> | |
<itunes:author>Penny Arcade</itunes:author> | |
<itunes:keywords>comedy,drama</itunes:keywords> | |
<itunes:category text="Comedy" /> | |
<itunes:category text="Arts"> | |
<itunes:category text="Performing Arts" /> | |
</itunes:category> | |
<itunes:image href="http://hw1.pa-cdn.com/pa/assets/img/logo_penny_arcade.png" /> | |
<itunes:explicit>no</itunes:explicit> | |
<itunes:summary><![CDATA[Penny Arcade Podcast!]]> | |
</itunes:summary> | |
<itunes:subtitle><![CDATA[]]></itunes:subtitle> | |
<?php | |
foreach( $result as $row ) { | |
if (preg_match('%\d\d/\d\d/\d{4}%si', $row['title'], $regs)) { | |
$date = $regs[0]; | |
} else { | |
$date = false; | |
} | |
?> | |
<item> | |
<title><?= htmlentities($row['title']) ?></title> | |
<?php if($date) { ?> | |
<pubDate><?= date(DATE_RSS, strtotime($date)) ?></pubDate> | |
<?php } ?> | |
<guid isPermaLink="false"><![CDATA[<?= md5( $row['title'] ) ?>]]></guid> | |
<link><![CDATA[<?= $row['file'] ?>]]></link> | |
<description><![CDATA[<?= htmlentities($row['title']) ?>]]></description> | |
<enclosure type="audio/mpeg" url="<?= $row['file'] ?>" /> | |
<itunes:explicit>yes</itunes:explicit> | |
<itunes:keywords /> | |
</item> | |
<?php | |
} | |
?> | |
</channel> | |
</rss> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment