ben-xo / dir2cast

Turn a directory of MP3s into a podcast - automatically.
http://www.ben-xo.com/dir2cast
BSD 3-Clause "New" or "Revised" License
152 stars 20 forks source link
automatic folder itunes mp3 mp3-files php podcast podcast-generator podcasting podcasts rss rss-feed rss-feed-generator rss-generator

Testing dir2cast

dir2cast by Ben XO v1.38 (2023-01-05)

https://github.com/ben-xo/dir2cast/

INTRODUCTION

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:

QUICK HOW TO GUIDES

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!

REQUIREMENTS

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/ .

INSTALLATION

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.

  1. Edit dir2cast.ini to your taste.
  2. Upload dir2cast.php and dir2cast.ini to the web server.
  3. Upload getID3 to a folder called 'getID3'. (You can download getID3 from the same place as dir2cast.)
  4. Upload a media file to the same folder as dir2cast.php
  5. Go to the URL for dir2cast.php- e.g. http://example.com/dir2cast.php
  6. This is your podcast! Check it's valid at https://podba.se/validate/ You may need to edit dir2cast.ini some more to get the text you want. The generated feed is cached. It will regenerate if you add a new media file, but if you want to force a regeneration delete the files from the "temp" folder that is created.

UNDERSTANDING HOW THE CACHING WORKS

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.

Notes:

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 each individual folder.

Assuming the following:

  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).
  2. Upload these additional dir2cast.ini files to the 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 .

"PRETTY" URLS FOR YOUR PODCASTS

If Your Web Server is Apache

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...

If Your Web Server is NGINX

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

TESTING

To run the unit tests:

  1. make sure you have xdebug installed. (pecl install xdebug)
  2. make sure you have composer installed. (brew install composer # (or similar))
  3. cd test && composer install
  4. ./run.sh

COPYRIGHT & LICENSE

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.

HISTORY

See CHANGELOG.txt