Python API for Ocean Digital Internet Radios or radios with the Skytune (ALD) chipset https://www.oceandigitalshop.com/internet-radio
Future proof your investment with hardware that contains station management onboard. Ocean Digital's products provide a better way to ensure our hardware keeps on working even if they discontinue their skytune service. Tested on the Ocean Digital WR-26F, and likely compatible with other radios that contain a similar server to manage favourites.
It's just you, me and an MP3 player. OceanEyes hopes to provide easier and consistent programming access to the onboard preset server.
To import as a module.
Be on the same network as your radio device, in the init declare your radio's location on your WiFi network:
#!/usr/bin/python3
import oceaneyes as oe
def main():
settings, stations = oe.init("192.168.1.200")
ip = settings["ipaddress"]
print(oe.status())
if __name__ == "__main__":
main()
oe.add_import("./import.pls", False)
[i] Importing station presets from ./import.pls
[+] 1 of 3 ...
[+] 2 of 3 ...
[+] 3 of 3 ...
200,OpenFM - EDM Anthems,http://stream.open.fm/361
200,OpenFM - Trance,http://stream.open.fm/7
200,OpenFM - House,http://stream.open.fm/5
$ chmod +x *.sh
$ chmod +x *.py
$ ./install.sh
$ cd ~/python-apps/oceaneyes
$ source bin/activate oceaneyes
$ cd app
$ ../bin/python3 main.py
Load a browser at the address replacing the ipaddr with yours found with ifconfig | grep "192":
firefox http://192.168.x.xx:1929/docs
Running api.sh in the root directory of the repo will run a FastAPI server at port 1929 that uses the oe module to interact with the device via OceanEyes.
# Read the API endpoints
http://192.168.x.xx:1929/docs
# Search for a station in the Community Radio Browser
http://192.168.x.xx:1929/v1/search/radiobrowser/bbc radio 4
import sys, time
import oceaneyes as oe
# Declare global data
settings, stations = oe.init("192.168.2.20")
ip = settings["ipaddress"]
# Find out if the radio is online
if oe.is_online():
print("Radio is online")
# Show name of currently playing channel
print(oe.status()) - Returns the currently playing station name.
# Change volume of your radio
oe.volume("up|down|mute|unmute")
# Get stats on favourite storage
fav_remaining = oe.get_remaining("fav")
fav_total = oe.get_total("fav")
print("Presets: Total=" + str(fav_total) + " Remaining=" + str(fav_remaining))
# Play a channel on your radio
oe.play("1")
# Play a channel on your computer instead (install vlc)
oe.listen("1")
# Delete a channel
oe.delete("1")
# Edit a channel
oe.edit("1", "Vivaldi", "https://stream.0nlineradio.com/vivaldi", "3;17;-1", "2;15", "0")
# Move a channel from one favourite placement to another
print(oe.move("2", "1"))
# Decode country and genre codes
print(oe.decode_country("3", "17", "-1"))
print(oe.decode_genre("-1", "1", "6"))
# Encode plain text to a country or genre code
print(encode_country("United Kingdom"))
print(encode_genre("Pop"))
# Get info on a channel
print(oe.info_get("1"))
# Exact match search of Community Radio Browser by station name
code, result = oe.search("BBC Radio 4", "RadioBrowser", True)
if code == 200:
i = 0
while i < len(result):
print(result[i]["chname"] + "," + result[i]["churl"])
i+=1
# Use Community Radio Browser to replace a masked URL from skytune
print(oe.enrich_url("BBC Radio 4"))
# Export favourties in these formats
# (json-rpp exports to Linux Mint's Radio++ Applet directly)
print(oe.get_list("plain", False))
print(oe.get_list("json", True))
print(oe.get_list("json-rpp", True))
print(oe.get_list("csv", False))
print(oe.get_list("ssv", False))
print(oe.get_list("m3u", True))
print(oe.get_list("pls", False))
-- You would not believe your eyes if ten million fireflies lit up the world as I fell asleep - Adam Young
-- I've never fallen from quite this high, Fallin' into your ocean eyes, Those ocean eyes - Billie Eilish
Open Source our radio preset systems! Sick and tired of Internet Radio portals shutting down? Help send a message to the industry that the potential of service shutdowns is leading to the dimise of a whole product category and it need not be this way. Internet Radio as a standalone category of hardware can continue to grow if we invest in the right ways to allow people to manage their own databases.
https://www.eff.org/issues/right-to-repair
https://www.repair.org/stand-up
https://hackaday.io/project/183339-saving-a-reciva-box-from-the-landfill
To protect your investment and lengthen the life of your device ask community members or reviewers if the device lets you add your own station URL's directly. Avoid known Reciva radios, like older CC Crane's, Grace Digital's, and Sirius radios that have a vested interest in broadcast technologies like satelite radio. Frontier service based devices are also risky unless adding station URl's directly is allowed via upgrade.
Avoid Pure and Pure Evoke's and Inscabin's, Lemega's, NakiRadio, Sungale's, most Sangean's, AUNA's.
Non-Skytune Radios that have long life potenital: Tivoli, Logitech, Brennan, Raspbery Pi / DIY devices and Single Board based retro handhelds, as well as set-top boxes or streaming devices like Roku, Amazon Fire, Apple TV or iOS devices, Now TV, Android or Android TV devices, Chromecast and AirPlay devices.
Ocean Digital chips decode DAB and DAB + and are sold in the US but we use the HDRadio system instead. It would be nice to buy a radio with a HD tuner. However there is the potenital to feed an RTL SDR into nrsc5, if that output from nrsc5 could be sent to icecast or ezstream to icecast then a local URL could be added to listen to HDRadio on the Ocean Digitals.