First you'll want to install these packages:
- archivers/unzip - you need this to unzip the getID3 library
Now we'll check out the necessary Drupal modules using CVS. CVS makes it very easy to keep up-to-date on changes made to the modules. It's as simple as running cvs up -dP.
Use the following commands to grab copies. Note that the CVS output is omitted:
$ mkdir /usr/local/www/drupal/sites/all/modules
$ cd /usr/local/www/drupal/sites/all/modules
$ cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -r DRUPAL-5 -d audio contributions/modules/audio
$ cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -r DRUPAL-5 -d views contributions/modules/views
$ cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -r DRUPAL-5 -d station contributions/modules/stationMake the station_archive.module's import directory writable by the web server:
$ chmod g+w station/archive/import/The audio module need the getID3 library to do it's thing so we'll download version 1.7.7 and install that:
$ cd /usr/local/www/drupal/sites/all/modules/audio
$ fetch http://superb-west.dl.sourceforge.net/sourceforge/getid3/getid3-1.7.7.zip
getid3-1.7.7.zip 100% of 368 kB 1178 kBps
$ unzip getid3-1.7.7.zip
Archive: getid3-1.7.7.zip
getID3() v1.7.7
James Heinrich, Allan Hansen
info@getid3.org
http://getid3.sourceforge.net
http://www.getid3.org
inflating: getid3/changelog.txt
creating: getid3/demos/
[ ... snippped ... ]
$ rm getid3-1.7.7.zip
$ rm -r getid3/demosEnable the modules on the admin >> modules page. Make sure to enable the following:
- audio
- audio_getid3
- station
- station_archive
- station_schedule
- taxonomy
- views
- views_rss
Now check the settings for each module.
- Open admin >> settings >> audio >> getid3 and make sure that audio_getid3 found the getID3 library.
- Configure the station module at admin >> settings >> station. If the schedule module is running on another machine, you'll want to set the XML-RPC URL.
Edit /usr/local/www/drupal/sites/all/modules/station/archive/scripts/ripper.inc. Set your web stream's URL, the full path of the import directory, and the full path to the stream ripper executable. If you're using all the paths I've been using you won't have to change a thing.
Test running the ripper script on the command line:
$ cd /usr/local/www/drupal/sites/all/modules/station
$ php archive/scripts/ripper.phpIf you see any error messages you'll need to correct those. If not, it'll grind away ripping the stream for up-to an hour. Let it run for a few minutes then stop it by pressing CTRL+C.
Look in the import directory and make sure you've got an .MP3 file:
$ ls archive/import/
1163188800.cue 1163188800.mp3 CVS readme.txtThere should be a .CUE file in there. Go a head and delete it:
$ rm archive/import/*.cueThe audio files are automatically imported as part of a cron task. Manually run Drupal's cron.php script so we can test the process (make sure to use your URL):
$ fetch -q -o - http://example.com:8080/cron.phpCheck that an audio node was created by visiting Home > > audio.
If that worked out all right it's time to add some cronjobs to run the ripper script automatically.
$ crontab -e -u wwwHere's a sample cronjob that rips every hour of the day:
# rip the sream starting one minute before the hour
59 * * * * /usr/local/bin/php php /usr/local/www/drupal/sites/all/modules/station/archive/scripts/ripper.phpFor more information on cronjobs, consult your man pages. The Wikipedia Crontab article is handy too.
You may also want to review the Drupal handbook pages for the modules we've just installed:
Crazy php question
At the LION we are trying to run streamripper on a different webserver then the drupal installation and archive area. Do you think it is possible to make drupal still recongnize the files if we create a fake link back o the real files using pho, which are on the real server, to the server where the drupal is hosted?
setting up cron job to stop automatically
How can you setup a cron job that will stop the previous ripper.php before it executes the next hour recording?
sample cronjob
NB Make sure you put the time and the command on *one line* ie:
59 * * * * /location/of/php /location/of/ripper.php
I had the location of ripper.php on a _separate_ line, which gave a "bad minute" error when trying to edit the crontab.
Jake