Improve radio setup

This commit is contained in:
Wiktor Zykubek 2021-05-24 10:34:06 +02:00
parent 5bba670b04
commit de51053d20
2 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,17 @@
#!/usr/bin/python3
import requests
import json
response = json.loads(
requests.get("https://open.fm/radio/api/v2/ofm/stations_slug.json").text
)
dict_ = {}
for channel in response["channels"]:
id_ = channel["instance_id"]
name = channel["name"]
dict_[name] = id_
with open("/home/samedamci/.config/radio/openfm_channels.json", "w") as f:
f.write(json.dumps(dict_, indent=2, ensure_ascii=False))

9
.local/bin/scripts/sync-radio Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
stream="$(mpc status -f "%file%" | awk 'NR==1')"
mpc stop >/dev/null
mpc clear >/dev/null
mpc add "$stream" >/dev/null
mpc play >/dev/null