npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

webradio-metadata

v0.1.39

Published

API scraping recipes to get metadata of radio streams

Downloads

46

Readme

Collection of urls and parsing scripts to fetch metadata about what is being broadcast on several webradios. Provides for each radio:

  • an artist
  • a title
  • a cover image (if available)

Code is JS only.

Note that this module gets the information from the radio websites, as most radios have a website indicating what is being broadcast live.

It could have been possible to parse ICY metadata, but it is missing or broken in most situations.

Installation

npm install webradio-metadata

Command-line usage

  • To display the list of compatible radios.
nodejs index.js list
  • To check that the parsing scripts are working correctly. Empty result means success.
nodejs index.js test
  • To get the metadata from a specific radio. If the country or the name of a radio has multiple words, use quotes.
nodejs index.js COUNTRY NAME

Example usages

$ nodejs index.js "France" "France Info"
{"err":null,"data":{"artist":"Le 17 | 20 : Nicolas Teillard","title":"Droit à l'erreur - Guillaume Poitrinal"},"corsEnabled":false}
$ nodejs index.js "France" "Radio Nova"
{"err":null,"data":{"artist":"AL GREEN","title":"LET'S STAY TOGETHER","cover":"https://nova.fr/sites/default/files/CQCT/2017-07/al-green-lets-stay-together-2893.jpeg"},"corsEnabled":true}
  • To get metadata for all supported radios.
  • Output in JSON:
nodejs index.js all-json
  • Output in human readable format:
nodejs index.js all-human

Usage as a module

require("webradio-metadata").getMeta(country, name, function(errors, parsedData, corsEnabled) { ... });
require("webradio-metadata").getAll(function(results) { ... });

Usage in browser

This project uses Node.JS scripts. Code cannot be run in the browser because some of the urls fetched do not have the CORS HTTP header Access-Control-Allow-Origin: *. Ressource loading would be blocked by the browser.

Compatible webradios

  • Belgium - Bel-RTL
  • Belgium - MNM
  • Belgium - Radio 1
  • Belgium - RTBF La Première
  • Belgium - Studio Brussel
  • Belgium - Zen FM
  • Canada - CHMP-FM 98,5 MHz FM, Montréal
  • Canada - CFGL "Rythme Montreal 105.7" Laval, QC
  • Canada - CKOF "104.7 Outaouais" Gatineau, QC
  • Canada - CIME 103.9 St-Jerome, QC
  • Canada - CKOY "107.7 FM Estrie" Sherbrooke, QC
  • Canada - CFGE "Rythme Estrie 93.7 & 98.1" Sherbrooke, QC
  • Canada - CKOB 106.9 Trois-Rivieres, QC
  • Canada - CJEB 100.1 "Rythme 100.1 Mauricie" Trois Rivieres, QC
  • Canada - CFOM "M FM 102.9" Quebec City, QC
  • Canada - CJMF 93.3 "FM93" Quebec City, QC
  • Canada - CKOI 96.9 Montreal, QC
  • Canada - CKBE "The Beat 92.5" Montreal, QC
  • Canada - CISM 89,3 MHz FM Université de Montréal, QC
  • Canada - CHOM 97.7 Montreal, QC
  • France - Alouette
  • France - BFM Business
  • France - Chérie
  • France - Djam Radio
  • France - Europe 1
  • France - FIP
  • France - FIP tout nouveau, tout FIP
  • France - FIP autour du reggae
  • France - FIP autour de l'électro
  • France - FIP autour du rock
  • France - FIP autour du jazz
  • France - FIP autour du groove
  • France - FIP autour du monde
  • France - France Culture
  • France - France Info
  • France - France Inter
  • France - France Musique
  • France - Fun Radio
  • France - Hit West
  • France - Jazz Radio
  • France - M Radio
  • France - Nostalgie
  • France - NRJ
  • France - OÜI FM
  • France - Radio Classique
  • France - Radio FG
  • France - Radio Meuh
  • France - Radio Nova
  • France - Radio Scoop Lyon
  • France - Rire et Chansons
  • France - RFM
  • France - RMC
  • France - RTL
  • France - RTL2
  • France - Skyrock
  • France - TSF Jazz
  • France - Virgin Radio France
  • France - Voltage
  • Germany - bigFM Deutschland
  • Germany - Fritz
  • Germany - Jam FM
  • Germany - Klassik Radio
  • Germany - Radio 7
  • Germany - RTL Radio
  • Italy - Radio 24
  • Italy - Radio Capital
  • Italy - Rai Radio 1
  • Italy - Rai Radio 2
  • Italy - Rai Radio 3
  • Spain - Cadena 100
  • Spain - Cadena SER
  • Spain - RAC 1
  • Spain - Rock FM
  • Switzerland - RTS La Premiere
  • Switzerland - RTS Couleur 3
  • Switzerland - Spoon Radio
  • United Kingdom - Absolute Radio
  • United Kingdom - BBC Radio 1
  • United Kingdom - BBC Radio 2
  • United Kingdom - BBC Radio 3
  • United Kingdom - BBC Radio 4
  • United Kingdom - Kiss UK

Contributing

You are welcome to submit a PR to add a new recipe for a radio or to fix a current recipe. Three strategies have been used to write the recipes:

  • parsing a JSON/XML API used by the radio website to dynamically update the page contents (GET or POST).
  • connecting through a websocket to receive metadata.
  • brute parsing the live webpage contents when no API is available.

When you have identified how to extract the data, you need to have a look at two files:

  1. Radio indexes: parsers/COUNTRY/index.js

Example syntax with COUNTRY=France and NAME=Fun Radio:

[
  ...
  { name: "Fun Radio", url: "https://www.funradio.fr/direct", parser: require("./RTL2") },
  ...

The name field should match the corresponding entry in the radio browser wiki. The url field is the path to the ressource to load. The parser field indicates the path to the parsing script. It is most often named as the radio itself, but can be another one, when the syntax for the other radio is the same.

  1. Parsers: parsers/COUNTRY/NAME.js

Sample:

"use strict";
const axios = require("axios");

module.exports = async function(exturl) {
  try {
    const req = await axios.get(exturl);
    const parsedResult = req.data;
    // const artist = ???
    // const title = ???
    // const cover = ???
    return { artist, title, cover };
  } catch (error) {
    return { error };
  }
}

License

See LICENSE file