diff --git a/README.md b/README.md index 0de694d..e780606 100644 --- a/README.md +++ b/README.md @@ -24,11 +24,11 @@ Features: * supports MP3, MP4, and M4A files -* dir2cast will automatically use the ID3 fields from your files for the Author, +* dir2cast will automatically use the ID3 fields from your files for the Author, Title, etc. ID3v2 is supported, as are the regular tags found in MP4 and M4A files. (Uses getID3, which is bundled with dir2cast.) -* dir2cast will automatically use the cover art embedded in your file as well. +* dir2cast will automatically use the cover art embedded in your file as well. * The generated feed is cached (in the supplied 'temp' folder, or anywhere else that you want) and only updated if something in the directory changes - so @@ -108,7 +108,7 @@ the media content, and of `dir2cast.php` and `dir2cast.ini`. This is to prevent high load if the feed is hammered by clients. * The feed will be updated when a media file that is newer than the cache file appears in the folder, as long as the media file was not updated in the last - 30 seconds (`MIN_FILE_AGE`). This is so that it doesn't accidentally include + 30 seconds (`MIN_FILE_AGE`). This is so that it doesn't accidentally include files which are still being uploaded. * Empty media files are ignored (nobody enjoys listening to them anyway) * The feed will update `dir2cast.php` or `dir2cast.ini` are newer than the cache @@ -133,20 +133,20 @@ TIPS CASTING SEVERAL FOLDERS FROM ONE DIR2CAST.PHP -------------------------------------------------------------------------------- -If you have more than one folder of MP3s that you are casting, you can serve -them all from a single install of dir2cast.php, and customise dir2cast.ini for +If you have more than one folder of MP3s that you are casting, you can serve +them all from a single install of dir2cast.php, and customise dir2cast.ini for each individual folder. Assuming the following: * your web root folder is called `htdocs/` and this maps to http://www.mysite.com/ -* you installed dir2cast to the folder `htdocs/dir2cast` -* you have two podcasts, and the MP3s live in `htdocs/dir2cast/cast1` and +* you installed dir2cast to the folder `htdocs/dir2cast` +* you have two podcasts, and the MP3s live in `htdocs/dir2cast/cast1` and `htdocs/dir2cast/cast2` -Step 1: Make 2 extra copies of `dir2cast.ini` (one for each cast), and then edit - to taste. (Any settings not specified will be taken from the main +Step 1: Make 2 extra copies of `dir2cast.ini` (one for each cast), and then edit + to taste. (Any settings not specified will be taken from the main `dir2cast.ini` - the one that is in the same folder as `dir2cast.php`). -Step 2: Upload these additional dir2cast.ini files to the `htdocs/dir2cast/cast1/` +Step 2: Upload these additional dir2cast.ini files to the `htdocs/dir2cast/cast1/` and `htdocs/dir2cast/cast2/` folders, respectively. The podcast URLs will now be: @@ -172,17 +172,17 @@ From the example above, your podcast URL will be: http://www.mysite.com/dir2cast/cast1/rss -To achieve this, you must configure apache with a rewrite rule such as: +To achieve this, you must configure apache with a rewrite rule such as: RewriteEngine on RewriteRule (.+)/rss$ dir2cast.php?dir=$1 [L] -Put this in your `VHOST` configuration (inside a `` block) or in a +Put this in your `VHOST` configuration (inside a `` block) or in a `.htaccess` file alongside `dir2cast.php` . PLEASE NOTE: just to check that you understand this section... * If you use the `RewriteRule` supplied, `dir2cast.php` must be in the folder above - the MP3 folders. (If this is not the case, you will have to set MP3_BASE in + the MP3 folders. (If this is not the case, you will have to set MP3_BASE in the ini file, and change the rule for your circumstance.) @@ -226,9 +226,9 @@ All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of dir2cast nor the names of its contributors diff --git a/dir2cast.php b/dir2cast.php index 0339e8c..f50308c 100644 --- a/dir2cast.php +++ b/dir2cast.php @@ -1127,18 +1127,18 @@ protected function scan() self::$DEBUG && print("Considering ${filepath}…\n"); $item_count = $this->addItem($filepath); } - + self::$DEBUG && print("$item_count items added.\n"); - + if(self::$EMPTY_PODCAST_IS_ERROR && 0 == $item_count) throw new Exception("No Items found in {$this->source_dir}"); - + $this->scanned = true; $this->post_scan(); $this->sort(); } } - + /** * Adds file to ->unsorted_items, and updates ->max_mtime, if it is of a supported type * @@ -1223,7 +1223,7 @@ protected function pre_generate() foreach($this->items as $the_item) $the_item->addHelper($helper); } - + protected function sort() { krsort($this->unsorted_items); // newest first $this->items = array(); @@ -1241,9 +1241,9 @@ protected function sort() { unset($this->unsorted_items); } - + protected function pre_scan() { } - + protected function post_scan() { } } @@ -1339,7 +1339,7 @@ public function renew() { touch($this->temp_file); // renew cache file life expectancy } - + public function uncache() { if($this->isCached()) @@ -1348,7 +1348,7 @@ public function uncache() $this->serve_from_cache = false; } } - + public function generate() { if($this->serve_from_cache) @@ -1375,10 +1375,10 @@ public function generate() file_put_contents($this->temp_file, $output); // save cached copy $this->serve_from_cache = true; } - + return $output; } - + public function isCached() { return file_exists($this->temp_file) && filesize($this->temp_file); @@ -1580,7 +1580,7 @@ public static function bootstrap(array $SERVER, array $GET, array $argv) if(isset($cli_options['help'])) { print "Usage: php dir2cast.php [--help] [--media-dir=MP3_DIR] [--media-url=MP3_URL] [--output=OUTPUT_FILE]\n"; - // extra debugging / test harness options: + // extra debugging / test harness options: // [--dont-uncache] // [--min-file-age=MIN_FILE_AGE] // [--debug] diff --git a/test/AgeDirTest.php b/test/AgeDirTest.php index f03d2f7..ac6e11b 100644 --- a/test/AgeDirTest.php +++ b/test/AgeDirTest.php @@ -29,4 +29,4 @@ public function tearDown(): void { chdir('..'); } -} \ No newline at end of file +} diff --git a/test/CachingTest.php b/test/CachingTest.php index 35b5212..7c0ce90 100644 --- a/test/CachingTest.php +++ b/test/CachingTest.php @@ -119,7 +119,7 @@ public function test_default_empty_podcast_doesnt_regenerate_before_MIN_CACHE_TI ); $this->assertEquals(0, preg_match('/empty\.mp3/', $new_content)); - } + } public function test_default_empty_podcast_regenerates_after_MIN_CACHE_TIME_with_a_change(): void {