Skip to content

Commit

Permalink
Whitespace fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-xo committed Dec 29, 2021
1 parent 697c692 commit 4e4cd27
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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 `<Location>` block) or in a
Put this in your `VHOST` configuration (inside a `<Location>` 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.)


Expand Down Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions dir2cast.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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();
Expand All @@ -1241,9 +1241,9 @@ protected function sort() {

unset($this->unsorted_items);
}

protected function pre_scan() { }

protected function post_scan() { }
}

Expand Down Expand Up @@ -1339,7 +1339,7 @@ public function renew()
{
touch($this->temp_file); // renew cache file life expectancy
}

public function uncache()
{
if($this->isCached())
Expand All @@ -1348,7 +1348,7 @@ public function uncache()
$this->serve_from_cache = false;
}
}

public function generate()
{
if($this->serve_from_cache)
Expand All @@ -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);
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion test/AgeDirTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ public function tearDown(): void
{
chdir('..');
}
}
}
2 changes: 1 addition & 1 deletion test/CachingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 4e4cd27

Please sign in to comment.