Create Radio Station list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage: 1. Download as Zip 2. Run `npm i` 3. run `node getStations.js` | |
// Note that the process might take 1-2 minutes | |
import fetch from 'node-fetch'; | |
import fs from 'fs'; | |
import lodash from 'lodash'; | |
const { uniqWith, uniqBy, isEqual, sortBy } = lodash; | |
async function main() { | |
const response = await fetch('http://de1.api.radio-browser.info/json/stations') | |
const responseJson = await response.json() | |
const reducedProps = responseJson.map(station => { | |
const { name, url, ...others } = station | |
return { name: name.trim(), url: url.trim() } | |
}) | |
const sorted = sortBy(reducedProps, 'name') | |
const onlyValue = sorted.map(channel => [channel.name, channel.url]) | |
const unique = uniqWith(onlyValue, isEqual) | |
fs.writeFileSync('allStations.json', JSON.stringify(unique)) | |
} | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "load-radio-stations", | |
"version": "1.0.0", | |
"main": "getAll.js", | |
"type": "module", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "Jonathan Heard", | |
"license": "MIT", | |
"dependencies": { | |
"lodash": "^4.17.21", | |
"node-fetch": "^2.6.1" | |
}, | |
"devDependencies": {}, | |
"description": "" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This file has been used to create the radioStations list for the Radio++ Cinnamon Applet. I am planing to implement a Github Action which automatically updates the radio station List. The code is not very good to be honest - I wanted to get it work asap and improve it afterwards but haven't done it yet😆 . As soon the Update is part of the official Repo I will delete this gist