Scheduled ripping of radio streams with streamripper

Moderator: Forum moderators

Post Reply
User avatar
amethyst
Posts: 2421
Joined: Tue Dec 22, 2020 6:35 am
Has thanked: 57 times
Been thanked: 506 times

Scheduled ripping of radio streams with streamripper

Post by amethyst »

Recording of radio streams is easy with a utility like YRadio but in most cases these GUI utilities do not have an option for scheduled recordings. With scheduled I mean starting to record a specific stream at a certain time and ending it at a specific time. We are focusing on streamripper which has the capability to rip a stream directly as incoming and at the same quality. Unfortunately streamripper's native options do not work for me, ie. stopping the recording after a certain time or after a certain size (in MB's). So. I made a little script that works the easiest for me. In ROX, go to a location where you want to create and run your script from > right-click in a space in the chosen directory and choose New and then Script from the menu. Here is an example of how your script may look like (let's call the script 'stream'). Note that the sleep command can be used to "time" the recording. In this script the process will be killed (stopped) after 30 minutes. So to schedule the running of your script use your task scheduler (like pSchedule) and use the PathofYourScript (eg, /mnt/home/stream) as the command. Note that the cd command in the script will ensure that the output file will also be saved in the parent directory your script is run from.

Code: Select all

cd DirectoryOfYourScript  #eg. /mnt/home 
streamripper LinkOfYourRadioStream
sleep 30m
killall streamripper

exit  
Last edited by amethyst on Mon Jan 09, 2023 2:04 am, edited 1 time in total.
User avatar
Trapster
Posts: 184
Joined: Sat Aug 01, 2020 7:44 pm
Has thanked: 1 time
Been thanked: 55 times

Re: Scheduled recording of radio streams with streamripper

Post by Trapster »

Nice.
You could also start it with Pschedule and then Kill it with Pschedule 30 min later

Streamripper (in focalpup32) has the options -l for length in seconds or -M for total size (mb).
Also has the option -d for destination directory.

Code: Select all

# streamripper -help
Usage: streamripper URL [OPTIONS]
Opts: -h             - Print this listing
      -v             - Print version info and quit
      -a [file]      - Rip to single file, default name is timestamped
      -A             - Don't write individual tracks
      -d dir         - The destination directory
      -D pattern     - Write files using specified pattern
      -s             - Don't create a directory for each stream
      -r [[ip:]port] - Create relay server on base ip:port, default port 8000
      -R #connect    - Max connections to relay, default 1, -R 0 is no limit
      -L file        - Create a relay playlist file
      -z             - Don't scan for free ports if base port is not avail
      -p url         - Use HTTP proxy server at <url>
      -o (always|never|larger|version)    - When to write tracks in complete
      -t             - Don't overwrite tracks in incomplete
      -c             - Don't auto-reconnect
      -l seconds     - Number of seconds to run, otherwise runs forever
      -M megabytes   - Stop ripping after this many megabytes
      -q [start]     - Add sequence number to output file
      -u useragent   - Use a different UserAgent than "Streamripper"
      -w rulefile    - Parse metadata using rules in file.
      -m timeout     - Number of seconds before force-closing stalled conn
      -k count       - Leave <count> tracks in incomplete
      -I interface   - Rip from specified interface (e.g. eth0)
      -T             - Truncate duplicated tracks in incomplete
      -E command     - Run external command to fetch metadata
      --quiet        - Don't print ripping status to console
      --stderr       - Print ripping status to stderr (old behavior)
      --debug        - Save debugging trace
ID3 opts (mp3/aac/nsv):  [The default behavior is adding ID3V2.3 only]
      -i                           - Don't add any ID3 tags to output file
      --with-id3v1                 - Add ID3V1 tags to output file
      --without-id3v2              - Don't add ID3V2 tags to output file
Splitpoint opts (mp3 only):
      --xs-none                    - Don't search for silence
      --xs-offset=num              - Shift relative to metadata (msec)
      --xs-padding=num:num         - Add extra to prev:next track (msec)
      --xs-search-window=num:num   - Search window relative to metadata (msec)
      --xs-silence-length=num      - Expected length of silence (msec)
      --xs2                        - Use new algorithm for silence detection
Codeset opts:
      --codeset-filesys=codeset    - Specify codeset for the file system
      --codeset-id3=codeset        - Specify codeset for id3 tags
      --codeset-metadata=codeset   - Specify codeset for metadata
      --codeset-relay=codeset      - Specify codeset for the relay stream
User avatar
amethyst
Posts: 2421
Joined: Tue Dec 22, 2020 6:35 am
Has thanked: 57 times
Been thanked: 506 times

Re: Scheduled recording of radio streams with streamripper

Post by amethyst »

Trapster wrote: Sun Jan 08, 2023 3:10 pm

Nice.
You could also start it with Pschedule and then Kill it with Pschedule 30 min later

Streamripper (in focalpup32) has the options -l for length in seconds or -M for total size (mb).
Also has the option -d for destination directory.

Code: Select all

# streamripper -help
Usage: streamripper URL [OPTIONS]
Opts: -h             - Print this listing
      -v             - Print version info and quit
      -a [file]      - Rip to single file, default name is timestamped
      -A             - Don't write individual tracks
      -d dir         - The destination directory
      -D pattern     - Write files using specified pattern
      -s             - Don't create a directory for each stream
      -r [[ip:]port] - Create relay server on base ip:port, default port 8000
      -R #connect    - Max connections to relay, default 1, -R 0 is no limit
      -L file        - Create a relay playlist file
      -z             - Don't scan for free ports if base port is not avail
      -p url         - Use HTTP proxy server at <url>
      -o (always|never|larger|version)    - When to write tracks in complete
      -t             - Don't overwrite tracks in incomplete
      -c             - Don't auto-reconnect
      -l seconds     - Number of seconds to run, otherwise runs forever
      -M megabytes   - Stop ripping after this many megabytes
      -q [start]     - Add sequence number to output file
      -u useragent   - Use a different UserAgent than "Streamripper"
      -w rulefile    - Parse metadata using rules in file.
      -m timeout     - Number of seconds before force-closing stalled conn
      -k count       - Leave <count> tracks in incomplete
      -I interface   - Rip from specified interface (e.g. eth0)
      -T             - Truncate duplicated tracks in incomplete
      -E command     - Run external command to fetch metadata
      --quiet        - Don't print ripping status to console
      --stderr       - Print ripping status to stderr (old behavior)
      --debug        - Save debugging trace
ID3 opts (mp3/aac/nsv):  [The default behavior is adding ID3V2.3 only]
      -i                           - Don't add any ID3 tags to output file
      --with-id3v1                 - Add ID3V1 tags to output file
      --without-id3v2              - Don't add ID3V2 tags to output file
Splitpoint opts (mp3 only):
      --xs-none                    - Don't search for silence
      --xs-offset=num              - Shift relative to metadata (msec)
      --xs-padding=num:num         - Add extra to prev:next track (msec)
      --xs-search-window=num:num   - Search window relative to metadata (msec)
      --xs-silence-length=num      - Expected length of silence (msec)
      --xs2                        - Use new algorithm for silence detection
Codeset opts:
      --codeset-filesys=codeset    - Specify codeset for the file system
      --codeset-id3=codeset        - Specify codeset for id3 tags
      --codeset-metadata=codeset   - Specify codeset for metadata
      --codeset-relay=codeset      - Specify codeset for the relay stream

Yes but that will require another schedule for killing. The -l, -M and -d options unfortunately does not work for me as mentioned which is a pity...

don570
Posts: 699
Joined: Sat Nov 21, 2020 4:43 pm
Has thanked: 5 times
Been thanked: 118 times

Re: Scheduled recording of radio streams with streamripper

Post by don570 »

Baconrecorder records sound at a given time (approx plus minus 15 secs)
however the sound has to be already playing.
So an internet radio station would have to be turned on using pschedule.
viewtopic.php?t=6797
_____________________________________

User avatar
amethyst
Posts: 2421
Joined: Tue Dec 22, 2020 6:35 am
Has thanked: 57 times
Been thanked: 506 times

Re: Scheduled recording of radio streams with streamripper

Post by amethyst »

don570 wrote: Sun Jan 08, 2023 7:25 pm

Baconrecorder records sound at a given time (approx plus minus 15 secs)
however the sound has to be already playing.
So an internet radio station would have to be turned on using pschedule.
viewtopic.php?t=6797
_____________________________________

Yes but this thread is about direct ripping of the stream with streamripper and not general sound capture from the soundcard. Just the other day I was actually trying to get the ALSA settings sorted for capture of sound on my laptop. I eventually figured out that stereo mix AND loopback mixing had to be enabled.

don570
Posts: 699
Joined: Sat Nov 21, 2020 4:43 pm
Has thanked: 5 times
Been thanked: 118 times

Re: Scheduled ripping of radio streams with streamripper

Post by don570 »

Recently discovered that mpg123 app an stream a mp3 file (at least in console window)

Code: Select all

mpg123  <  file.mp3

Http Support
In addition to reading MPEG audio streams from ordinary files and from the standard input, mpg123 supports retrieval of MPEG audio files or playlists via the HTTP protocol, which is used in the World Wide Web (WWW). Such files are specified using a so-called URL, which starts with ''http://''. When a file with that prefix is encountered, mpg123 attempts to open an HTTP connection to the server in order to retrieve that file to decode and play it.
It is often useful to retrieve files through a WWW cache or so-called proxy. To accomplish this, mpg123 examines the environment for variables named MP3_HTTP_PROXY, http_proxy and HTTP_PROXY, in this order. The value of the first one that is set will be used as proxy specification. To override this, you can use the -p command line option (see the ''OPTIONS'' section). Specifying -p none will enforce contacting the server directly without using any proxy, even if one of the above environment variables is set.

Note that, in order to play MPEG audio files from a WWW server, it is necessary that the connection to that server is fast enough. For example, a 128 kbit/s MPEG file requires the network connection to be at least 128 kbit/s (16 kbyte/s) plus protocol overhead. If you suffer from short network outages, you should try the -b option (buffer) to bypass such outages. If your network connection is generally not fast enough to retrieve MPEG audio files in realtime, you can first download the files to your local harddisk (e.g. using wget(1)) and then play them from there.

User avatar
Trapster
Posts: 184
Joined: Sat Aug 01, 2020 7:44 pm
Has thanked: 1 time
Been thanked: 55 times

Re: Scheduled ripping of radio streams with streamripper

Post by Trapster »

I do not recall a program that does timed events.
Yes, I have seen alarm clocks and other "scheduling" programs but none that would start, run for 30 min AND stop a program.

I was bored and curious about this so I created "Pevent". A little program that starts, runs at a chosen duration, then quits.

I am a hack and may or may not know what I'm doing :)
Try it and give some feedback.
This was made and tested on focalpup32.

Image

Attachments
Pevent-0.1.pet
(3.75 KiB) Downloaded 43 times
Post Reply

Return to “Sounds”