Skip to content

Instantly share code, notes, and snippets.

@ryanfitton ryanfitton/crontab -e
Last active Nov 22, 2016

Embed
What would you like to do?
A PHP cronjob to download podcasts via a PHP script. More info here: http://ryanfitton.co.uk/blog/php-cron-job-to-download-podcasts/
5 5 * * * php /var/www/Scripts/twit-get.php
<?php
$url = "http://feeds.twit.tv/twit_video_hd";
$cache = "/var/www/Scripts/twit-latest-download.txt";
$path = "/var/www/twit-" . date("j-n-Y") . ".mp4";
$rss = simplexml_load_file($url);
$items = $rss->channel->item;
$link = $items->enclosure["url"];
$latestdownload = file_get_contents($cache);
if ($link == $latestdownload)
{
print "Has already been downloaded. This podcast will not be downloaded until the new one is released.";
}
else
{
$ds = "wget -O ". $path . ' ' . $link;
$foo = system($ds,$output);
print "Podcast downloaded.";
file_put_contents($cache, $link);
}
?>
http://dts.podtrac.com/redirect.mp4/twit.cachefly.net/video/twit/twit0418/twit0418_h264m_1280x720_1872.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.