Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'This is probably easier done in PHP' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
This is probably easier done in PHP
Authored by: altotus on Apr 23, '10 12:04:01PM
You don't need folder actions. A better solution is to make the RSS dynamically based on the contents of a folder that you copy your files into (mind you, it presumes that PHP is available, as it is on a stock Mac). For example, put this PHP file in your sites directory, and create a sub-directory there names "podcast" to put your audio files in:

<?php
    header("Content-type: application/rss+xml");
    print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
    <channel>
        <description>My personal podcast</description>
        <link>http://www.nolink.com</link>
        <title>My Podcasts</title>
        <pubDate><?=@date(DateTime::RFC1123)?></pubDate>
        <?php
            $podcastFiles = scandir("./podcast");
            uasort($podcastFiles, "by_date");
           
            foreach ($podcastFiles as $podcast) {
                if (substr($podcast, 0, 1) == ".") continue;
                
                $url = "http://" . $_SERVER['HTTP_HOST'] .
                       ":" . $_SERVER['SERVER_PORT'] .
                       dirname($_SERVER['REQUEST_URI']) .
                       "/podcast/$podcast";
            ?>
                <item>
                    <title><?=substr($podcast,0,-4)?></title>
                    <enclosure type="audio/mpeg" length="<?=filesize("./podcast/" . $podcast)?>" url="<?=$url?>"/>
                </item>
            <? }
            
            function by_date($a, $b) {
                filemtime("./podcast/$a") - filemtime("./podcast/$b");
            }
        ?>
    </channel>
</rss>


[ Reply to This | # ]