Last active
November 22, 2016 08:27
-
-
Save ryanfitton/6260286 to your computer and use it in GitHub Desktop.
A PHP cronjob to download podcasts via a PHP script. More info here: http://ryanfitton.co.uk/blog/php-cron-job-to-download-podcasts/
This file contains 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
5 5 * * * php /var/www/Scripts/twit-get.php |
This file contains 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 | |
$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); | |
} | |
?> |
This file contains 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
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