Skip to content
Permalink
Browse files

Implement recursive folder support.

  • Loading branch information
Isaacs, Ben
Isaacs, Ben committed Feb 22, 2018
1 parent 3be576d commit a94ebed2aa6047d2fc06cf0fdb39bed65a24ff62
Showing with 27 additions and 5 deletions.
  1. +3 −1 README.txt
  2. +3 −0 dir2cast.ini
  3. +21 −4 dir2cast.php
@@ -1,4 +1,4 @@
dir2cast by Ben XO v1.9 (2017-12-27)
dir2cast by Ben XO v1.10 (2018-02-22)
================================================================================

https://github.com/ben-xo/dir2cast/
@@ -151,6 +151,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
HISTORY
================================================================================

1.10 2018-01-21 Added RECURSIVE_DIRECTORY_ITERATOR option for scanning nested
folders. Suggested by ognjiscar
1.9.1 18-01-21 Small PHP7 fix.
1.9 2017-12-27 Merged changes from cbz:
* Upgraded getID3
@@ -42,6 +42,9 @@
; it will fail. If your MP3 URLs are all wrong, try putting this in manually.
;MP3_URL = http://www.example.foo/my_mp3_folder/

; Uncomment this if you want to check in every sub-folder for new files as well.
;RECURSIVE_DIRECTORY_ITERATOR = true



; *** INFORMATION ABOUT YOUR PODCAST - you SHOULD set this how you like it ***
@@ -56,7 +56,7 @@
/* DEFAULTS *********************************************/
// error handler needs these, so let's set them now.
define('VERSION', '1.9.1');
define('VERSION', '1.10');
define('DIR2CAST_HOMEPAGE', 'https://github.com/ben-xo/dir2cast/');
define('GENERATOR', 'dir2cast ' . VERSION . ' by Ben XO (' . DIR2CAST_HOMEPAGE . ')');
@@ -485,16 +485,20 @@ class RSS_File_Item extends RSS_Item {
public function __construct($filename)
{
$this->filename = $filename;
$this->extension =
$this->setLinkFromFilename($filename);
parent::__construct();
}
public function setLinkFromFilename($filename)
{
$url = rtrim(MP3_URL, '/') . '/' . rawurlencode(basename($filename));
$url = rtrim(MP3_URL, '/') . '/' . str_replace('%2F', '/', rawurlencode($this->stripBasePath($filename)));
$this->setLink($url);
}
protected function stripBasePath($filename)
{
return ltrim(substr($filename, strlen(MP3_DIR)), '/');
}
public function getType()
{
@@ -810,7 +814,17 @@ protected function scan()
// scan the dir
$di = new DirectoryIterator($this->source_dir);
if(RECURSIVE_DIRECTORY_ITERATOR)
{
$di = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($this->source_dir),
RecursiveIteratorIterator::SELF_FIRST
);
}
else
{
$di = new DirectoryIterator($this->source_dir);
}
$item_count = 0;
foreach($di as $file)
@@ -1374,6 +1388,9 @@ public static function defaults()
if(!defined('DESCRIPTION_SOURCE'))
define('DESCRIPTION_SOURCE', 'id3');
if(!defined('RECURSIVE_DIRECTORY_ITERATOR'))
define('RECURSIVE_DIRECTORY_ITERATOR', false);
}
public static function load_from_ini($file)

0 comments on commit a94ebed

Please sign in to comment.
You can’t perform that action at this time.