Skip to content

Instantly share code, notes, and snippets.

View spinitron's full-sized avatar
💭

Tom and Eva spinitron

💭
View GitHub Profile
@spinitron
spinitron / shoutcast-stream-title.php
Last active April 6, 2021 02:32
Extract and display StreamTitle from a media stream using the Shoutcast Metadata Protocol.
<?php
/*
* Extract and display StreamTitle from a media stream using the Shoutcast Metadata Protocol.
* Thank you, Scott McIntyre! http://www.smackfu.com/stuff/programming/shoutcast.html
*
* Copyright 2019 by Tom Worster
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
*

Create a report for a PRO, e.g. BMI, ASCAP

Search for the spins you need to report to the PRO

Search settings for BMI report

  1. Navigate to Report: Search & chart
  2. Search for: Spins
  3. Set the date range for the report you need, For example 3
  4. months
<?php
/*
* Reverse proxy to terminate HTTP and forward a "Now playing" update to an RDS via UDP.
*
* Use this to push metadata to an RDS encoder. Run the script on an HTTPS server that can be
* reached from the Internet, e.g. in your DMZ or on a hardened server, that can itself reach
* the RDS encoder over a secure private LAN, e.g. on a different network interface from the
* web server.
*
@spinitron
spinitron / music-schema.md
Last active November 16, 2018 16:47
Music metadata in Spinitron v1 and v2

Spinitron music metadata

What happened to the music database browser?

Spinitron v1 stored music data and playlists in a database that separates entities into tables of artists, spins, disks, and labels (see terminology below). Another table called appearances connected them in the sense: an artist has appearances on one or more disks, a disk has appearances of one or more artist, and an appearance (of an artist on a disk) can feature in one or more spins. The design was partly motivated by the theory of database normalization (I'd give a link if I could find a good one). Here's a simplified diagram of this schema.

v1 schema simplified

The idea was that a relational database of a station's music library would emerge as its staff use Spinitron. As DJs enter spins into playlists, Spinitron would automatically manage the artists, disks and labels and their relations. This would allow users to search and brow

@spinitron
spinitron / template-variables.md
Created October 29, 2018 21:05
Spinitron template variables
Variable Description
%now% Current time in W3C form, e.g. 2010-04-15T13:42:32-05:00
%now[format]% Current time formatted using the php date() function, e.g. %now[g:ia]%
%an% Artist
%sn% Song name
%sc% Song composer
%sp% Spin timestamp in W3C form, e.g. 2010-04-15T13:42:32-05:00
%sp\[format]% Spin timestamp formatted using the php date() function, e.g. %sp[g:ia]%
%se% Spin note
@spinitron
spinitron / Trim-overlap-in-NPR-playlist-logs.md
Last active December 12, 2018 21:05
Trim overlap in NPR playlist logs for SoundExchange Reporting

Trim playlist log overlap in NPR SoundExchange reports

If your station's SoundExchange reports are processed by NPR then you send them, among other things, a Playlist Log conforming to NPR's specification.

NPR playlist logs have one row per spin and six columns:

Title  |  Artist  |  Album  |  Label  |  Start Time  |  End time

Spinitron does not have an end time field and instead has duration. When we prepare an NPR playlist log, we calculate end time for each spin by adding its duration to its start time.

@spinitron
spinitron / Metadata-push-Default-and-Max-Duration.md
Last active September 12, 2018 19:50
Metadata push: Default and Max Duration

Metadata push: Default and Max Duration

This article details Spinitron's timing of metadata push events and cancellation policy, in which the Default Duration and Max Duration configurations play their part.

Spinitron's metadata push feature sends now-playing song updates to things such as stream servers, RDS encoders and the like. We assume that the receiver of a push message updates its display to users when it receives the message. So the timing of when Spinitron sends the message is important.

If Spinitron has advance knowledge of a spin, it schedules to send its push messages at the spin's timestamp. But if is told about the spin late, which can easily happen with manual playlist entry, then it will either push the message immediately, if the information is not too old, or not at all.

Spinitron's rules for pushing spins

@spinitron
spinitron / Spinitron v2 API backwards compatibility.md
Last active January 4, 2019 12:58
Spinitron v2 API suplemental endpoint for backwards compatibility

Spinitron v2 API backwards compatibility

This endpoint is suplemental to the Spinitron v2 API and provides an alternative to the POST /spins enpoint for compatibility with applications that need to present spin metadata as query parameters in the request URL.

Base URL

https://spinitron.com/api

Endpoint

@spinitron
spinitron / Playlists, Shows, Schedules, Calendar.md
Created March 29, 2018 20:18
Spinitron's concept of shows, playlists, and schedules, and differences between v1 and v2

Shows in the future and playlists in the past

This is a core concept in Spinitron and in v2 it controls how some features work.

To discuss v2's features, how they work, and how they perhaps should change, we need to define terms.

Spinitron's basic ontology (v1 and v2)

  • A show defines a radio program. It represents the plans for the program, which include its
    • descriptive stuff (title, image etc.)