Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Instruction Guide Radio stream recorder
#1
Music 
Instructions for a simple radio station recorder for moOde.

29 June 2020 UPDATE: The below instructions have been replaced by a command line install script available on my githib page: https://github.com/TheMetalHead/moOde-Ra...n-Recorder There is also a moOde radio station import script.

It consists of a separate web server to schedule the recording of a radio station. This then updates moOde/mpd with the new recordings that appear in a directory called Recordings in the library. This has been tried on moOde versions 6.4.2 and 6.5.2

           

The following stream formats are supported by the stream ripper: mp3, nsv, aac, and ogg. I have only tried two formats, mp3 is ok, aac had audio interruptions.

The streamripper and radiorecorder software have been written by other people. Their links are given at the bottom.


As always, before installing I recommend that a backup is made of your moOde system. I will not be held responsible for any mistakes. That way if you do not like what you see, you can always go back to your old set up.

Drop into the command line in moOde using ssh. Use Putty or moOde Shellinabox.

Install the dependencies:

    sudo apt update
    sudo apt install streamripper at

Make a directory for the radio recorder in the pi home directory.

    mkdir RadioRecorder

    cd RadioRecorder

Download the file:

    wget https://sourceforge.net/projects/radiore...t/download -O RadioRecorder.tar.gz

Extract:

    tar -x -f RadioRecorder.tar.gz

Remove the downloaded file:

    rm RadioRecorder.tar.gz

Get the full working directory of the radio recorder and note this for the next step:

    pwd

Configure the radio recorder:

    nano res/settings.php

Change the following for your preferences:

    The full working directory of the radio recorder from 'pwd' in the previous step:
        $siteRoot = '/home/pi/RadioRecorder';

    The location of where to store the recordings. This will be different to your system. eg:
        $recordedFilesDestination = '/home/pi/Music/Recordings';

    Adds additional streamripper parameters to each call. This disables writing the stdout output to mail.
        $defaultStreamripperParams = '>/dev/null';

    Change the recording prefix from null to year, month, day:
        $addDatePrefixToFilename = 'Y-m-d';

    Command to be executed after the recording is finished. Here we just update mpd:
        $postCommand = 'mpc update > /dev/null';

    Change the log level to ERROR:
        $logThreshold = 1;

Exit nano.



Make a directory for the recordings in a suitable location. This will be used as the name that will appear in the moOde library panel:

eg    cd /home/pi/Music

    mkdir Recordings

Create a link for moOde to the new recordings directory:

    cd /var/lib/mpd/music

Create the link:

    sudo ln -s /home/pi/Music/Recordings

The link will appear in the moOde library panel as 'Recordings'.

Create a simple web server. Note this is not production grade and should not be visible on the internet:

    sudo nano /etc/rc.local

At the bottom and just before the 'exit 0' statement add the following:

    /usr/bin/php -q -S 192.168.1.123:8080 -t /home/pi/RadioRecorder >/dev/null 2>&1

Note: Change the ip address to your moOde ip address and ensure that the port is above 1024. In this case 8080.

Reboot moOde.



Access the web interface using:

    your-moode-ip:8080

Note: If you use the built in web interface playback function this uses local web browser audio player and not moOde. Also the built in web player cannot play aac files.



Example to rip as one track.

Create the stream to rip:

    Name of stream:                              RockRadio1 - One track
    Uniform Resource Locator (URL):    http://192.99.147.61:8000
    Additional Parameter:                       -k 0 -o always

You may need to add -u "FreeAmp/2.x" to the 'Additional Parameter' when creating the stream to rip.

The above places the recording in the 'Recordings' directory as '2020-06-26-09-06-00 name of recording.mp3'.



Other versions of 'Additional Parameter':

    -u "FreeAmp/2.x" -a -k 0 -o always

Places the recording in the 'Recordings/RockRadio1' directory as 'sr_program_2020_06_26_21_56_01.mp3'.



    -u "FreeAmp/2.x" -a -A -k 0 -o always

Places the recording in the 'Recordings/RockRadio1' directory as 'sr_program_2020_06_26_21_56_01.mp3'.



    -u "FreeAmp/2.x" -A -a "%S - %d" -k 0 -o always
    -u "FreeAmp/2.x" -a "%S - %d" -k 0 -o always

Places the recording in the 'Recordings' directory as 'RockRadio1 - 2020_06_26_22_11_00.mp3'.



Create the recording schedule:

    Stream:                RockRadio1 - One track
    Date:                    Set as required.
    Time:                    Set as required.
    Duration:              Set as required.
    Name of track:      Give it a suitable name. eg The Rock Show.
    Repeating:            Select the days to record from or leave blank for one day.
                                     eg tick Mon to record every monday.



Example to rip into individual tracks.

Create the stream to rip:

    Name of stream:                             RockRadio1 - Rip tracks
    Uniform Resource Locator (URL):   http://192.99.147.61:8000
    Additional Parameter:                        -D "%A - %T" -k 0 -o always



Create the schedule:

    Stream:                RockRadio1 - Rip tracks
    Date:                    Set as required.
    Time:                    Set as required.
    Duration:              Set as required.
    Name of track:      Leave as automatic track detection.
    Repeating:            Select the days to record from or leave blank for one day.
                                     eg tick Mon to record every monday.



'Additional Parameter' options:

-D %d
# Name files with date and time (per exec)
# If -D is used, the options -s and -P will be ignored.

    %S        Stream
    %A        Artist
    %T        Title
    %a        Album
    %D       Date and time (per song)
    %d        Date and time (per execution)
    %q        Sequence number (automatic detection)
    %Nq      Sequence number (starting from number N)
    %%       Percent sign

-a [pattern]
# Sometimes you want the stream recorded to a single (big) file
  without splitting into tracks. The -a option does this. If you use -a without
  including the [pattern], a timestamped filename will automatically be used.

-A
Don´t create individual tracks.
The default mode of operation is to create one file for each track.
But sometimes you don´t want these files.
Using the -A option, the individual files for each track are not created.

-u "FreeAmp/2.x"
# Some stream-servers will not accept the default Streamripper UserAgent,
  the solution is using this parameter with the value "FreeAmp/2.x".



To use via moOde:

    Go to the library panel.
    Select Recordings.



Info:

    https://sourceforge.net/projects/radiorecwebgui/
    http://streamripper.sourceforge.net/faq.php
    http://manpages.org/streamripper
Reply
#2
That's very cool!

All we need to do now is automatically populate its station lists from Moode's radio station database.

In RadioRecorder/res/ there's a file streams.txt, with the format

Station Name;<stream url>;parameters

Should be easy to populate that.

Phil

Reply
#3
If there's more demand for something like this I can pull an MPD based recorder off the shelf that I worked on a few years ago. It can b seamlessly integrated into the WebUI and Library. There would be the classic red "record" button. It's pretty basic compared to what @TheMetalHead put together but it could be useful for users that occasionally want to record some songs or a particular radio program to listen to later :-)

The streamed songs would be encoded as FLAC with the file naming format and tags listed below.

File name format= "Artist - Title.flac"
Genre= "Recordings"
Artist
Album= "Recordings"
Title

What u end up with over time is a big compilation album named "Recordings" containing all the recorded songs.

-Tim
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#4
(06-27-2020, 06:38 PM)philrandal Wrote: That's very cool!

All we need to do now is automatically populate its station lists from Moode's radio station database.

In RadioRecorder/res/ there's a file streams.txt, with the format

Station Name;<stream url>;parameters

Should be easy to populate that.

Phil

Have now added the station import feature from the command line.
It is available on my github page https://github.com/TheMetalHead/moOde-Ra...n-Recorder
It provides two entries per station. One to record as one track, the other to record as individual tracks.
Reply
#5
I can guarantee that some of the stations will not record, namely the acc streams and maybe the m3u8 streams. The mp3 ones should be ok.
Reply
#6
You should check out the MPD recorder plugin. It doesn't matter what the source format is cos it's recording the decoded PCM stream :-)
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#7
Sorry everyone. I dropped a clanger. 'Import-MoOde-Radio-Stations.sh' had a bug that I missed and therefore it would not allow you to record from the station. This has now been fixed.
I have also created an install script. Both of these are available on my github page https://github.com/TheMetalHead/moOde-Ra...n-Recorder
Reply
#8
(06-28-2020, 12:33 AM)Tim Curtis Wrote: You should check out the MPD recorder plugin. It doesn't matter what the source format is cos it's recording the decoded PCM stream :-)

The problem with this scenario I think is that whilst the radio stream is being recorded you cannot have mpd play anything else. ie I want to listen to my music but someone else wants to record either one or more radio shows at the same time.
Reply
#9
It simply records what's currently playing so yes you can listen while recording. As I mentioned earlier, its a basic recorder thats built into MPD and could prolly be useful for the usage scenario where someone just wants to record some songs or a particular program for listening to at a later time.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#10
Hi Tim,

On your instructions below, is there a way not to hard code IP address to start the RadioRecorder web pages?  Also, while http://ip-address:8080 works when accessing the pages from other machines,  accessing from console http://localhost:8080 or http://127.0.01:8080 does not. (I used a backdoor to open another tab on your moode interface.)  


"At the bottom and just before the 'exit 0' statement add the following:

    /usr/bin/php -q -S 192.168.1.123:8080 -t /home/pi/RadioRecorder >/dev/null 2>&1

Note: Change the ip address to your moOde ip address and ensure that the port is above 1024. In this case 8080.

Reboot moOde.



Access the web interface using:

    your-moode-ip:8080

Note: If you use the built in web interface playback function this uses local web browser audio player and not moOde. Also the built in web player cannot play aac files."
Reply


Forum Jump: