https://github.com/ben-xo/dir2cast/
Hello!
dir2cast is designed to turn a directory of MP3s into a podcast - automatically. Perfect for, say, radio shows - upload the MP3s to a folder, and use dir2cast.php as your PodCast URL.
Features:
For 99% of things, NO CONFIGURATION IS NECESSARY. All you have to do is upload dir2cast to your web server, then start uploading media files, and it will pick up most of the podcast text straight from the tags in the file (such as the artist, title and comment tags.)
supports MP3, MP4, M4A and M4B files
dir2cast will automatically use the ID3 fields from your files for the Author, Title, etc. ID3v2 is supported, as are the usual tags found in MP4 / M4A / M4B files. (Uses getID3, which is bundled with dir2cast.)
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 the feed will load fast and put minimal strain on your web server. It only regenerates the feed when a new episode is uploaded.
Comprehensive support for iTunes podcast tags.
iTunes 'image' supported: just drop a file called itunes_image.jpg in the same folder as your media files.
RSS Description, iTunes Subtitle and iTunes Summary can be set by dropping files named description.txt, itunes_subtitle.txt and itunes_summary.txt in the same folder as dir2cast.php - but they are not required. (You can also set these in the config).
You can set a per-file iTunes Summary by creating a text file with the same name as the media file (e.g. for file.mp3, create file.txt).
Here are links to a couple of guides on how to set up a podcast, using dir2cast. Thanks to the people who wrote these guides!
dir2cast requires PHP 5.3 minimum. It requires the XML extension to be enabled.
It has been tested up to PHP 8. Please file a bug if you find any PHP version specific problems: https://github.com/ben-xo/dir2cast/issues
dir2cast makes use of getID3 by James Heinrich & Allan Hansen, although it does not require the whole thing. A cut down version of getID3 is supplied at https://github.com/ben-xo/dir2cast/. You will need to download this and install it with dir2cast.php. The full version of getID3 is available at http://getid3.sourceforge.net/ .
Please note: the config file will make more sense if you read all of this README
before trying the installation instructions.
dir2cast is quite flexible but the general idea is that you add cover art and tags to your media files (mp3, mp4, m4a and m4b currently supported) and then the podcast that it generates uses the tags from your files.
dir2cast.ini
to your taste.dir2cast.php
and dir2cast.ini
to the web server.getID3
to a folder called 'getID3
'. (You can download getID3 from
the same place as dir2cast.)dir2cast.php
dir2cast.php
- e.g. http://example.com/dir2cast.phptemp
" folder that is created.dir2cast caches the feed so that it only has to renegerate the content when
something changes. It does this by looking at the file-modification times of
the media content, and of dir2cast.php
and dir2cast.ini
.
MIN_CACHE_TIME
)
This is to prevent high load if the feed is hammered by clients.MIN_FILE_AGE
). This is so that it doesn't accidentally include
files which are still being uploaded.dir2cast.php
or dir2cast.ini
are newer
than the cache file as a convenience when upgrading.Notes:
touch
to update the modification
time of a file.?force=<password>
URL (see dir2cast.ini
FORCE_PASSWORD
)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:
htdocs/
and this maps to http://www.mysite.com/htdocs/dir2cast
htdocs/dir2cast/cast1
and
htdocs/dir2cast/cast2
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
).htdocs/dir2cast/cast1/
and htdocs/dir2cast/cast2/
folders, respectively.The podcast URLs will now be:
http://www.mysite.com/dir2cast/dir2cast.php?dir=cast1 and http://www.mysite.com/dir2cast/dir2cast.php?dir=cast2 .
I assume you already have PHP working with Apache.
This hint requires your web server to be Apache with 'mod_rewrite
' enabled.
From the example above, your podcast URL will be:
http://www.mysite.com/dir2cast/dir2cast.php?dir=cast1
...but much nicer would be something along the lines of
http://www.mysite.com/dir2cast/cast1/rss
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
.htaccess
file alongside dir2cast.php
.
PLEASE NOTE: just to check that you understand this section...
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 ini file, and change the rule for your circumstance.)I assume you already have PHP working on NGINX
From the example above, your podcast URL would be:
http://www.mysite.com/dir2cast/dir2cast.php?dir=cast1
Add some configuration like the following to your sites conf
location = /dir2cast/rss {
rewrite ^(/dir2cast)/rss $1/dir2cast.php last;
}
This assumes the URL you want is /dir2cast/rss, and that the URL of dir2cast.php is /dir2cast/dir2cast.php
To run the unit tests:
pecl install xdebug
)brew install composer # (or similar)
)cd test && composer install
./run.sh
Copyright (c) 2008-2021, Ben XO (me@ben-xo.com).
The software is released under the BSD License.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
See CHANGELOG.txt