Jump to content
FoxxMD

[Support] FoxxMD - cron-streamripper

2 posts in this topic Last Reply

Recommended Posts

Application Name: cron-streamripper
Application Site: http://streamripper.sourceforge.net/

Docker Hub: https://hub.docker.com/r/dax333/cron-streamripper

Template Repo: https://github.com/FoxxMD/unraid-docker-templates

 

Overview 

 

streamripper is an open source application for recording streaming audio, usually associated with online radio. streamripper can be use manually from inside the container but this container is mainly setup to be used with the cron scheduler to enable a user to schedule ripping.

 

How To Use

 

  1. Mount a host directory to the container directory /etc/cron.d and create a new, valid cron file named station-cron inside that directory. streamripper can be run directly from the cron file
    1. The template provides /mnt/user/appdata/cron-streamripper/cron as a default host directory
  2. Mount another host directory into the container where output files can be saved
    1. The template provides container directory /home/streamripper/streams mounted to the host directory /mnt/user/appdata/cron-streamripper/streams as a default
  3. The container will automatically check station-cron on startup, happy ripping!

 

Optionally, create executable scripts for simplifying streamripper usage and store these in a mounted host directory, then refer to these in station-cron. A default mount is provided in the template

 

 

For your convenience here are my station-cron and script files for more in depth examples:

 

stream.sh

#!/bin/sh

# A POSIX variable
OPTIND=1         # Reset in case getopts has been used previously in the shell.

# Initialize our own variables:
duration=60
name=""
station=""
url=""
date=$(date)

while getopts "n:d:s:u:" opt; do
    case "$opt" in
    n)
        name=$OPTARG
        ;;
    d)
        duration=$OPTARG
        ;;
    s)
        station=$OPTARG
        ;;
    u)
        url=$OPTARG
        ;;
    :)
        echo "Option -$OPTARG requires an argument." >&2
        exit 1
        ;;
    esac
done

# Timestamping execution in log and stdout for unraid logs
echo "Starting to rip at ${date}"

# output directory will be the name given for station
output_dir=/home/streamripper/streams/${station}

# output filename will be the name given for the stream and the date
output_filename=${name}--%d

# -s => don't create directory for each stream
# -t => Truncate completed tracks in incomplete directory
# -o => always overwrite tracks in complete directory (not an issue since output file always has unique timestamp)
# -a => rip to single file (instead of separating into individual tracks based on silience detection)

streamripper "$url" -d "$output_dir" -l $duration -a "$output_filename" -s -T -o always

# newline for readability in log/stdout
echo ""

 

station-cron

# cron test
# prints "Hello World" to the cron.log file every minute
#* * * * * echo "Hello world" >> /var/log/cron.log 2>&1

# streamripper test
# will output a 40-second long ripped stream to /home/streamripper/streams/wabe every 2 minutes
*/2 * * * * /home/streamripper/programs/stream.sh -n testStream -d 40 -s wabe -u https://pba-ice.wabe.org/wabe.aac

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.