It can be used to have internet radio playing always in the particular hours daily. Sometimes kodi stream ends/drops because of poor internet connection or server error. With this app you can fix it.
To use it you have to configure your kodi device in config/cfg.ini
[KODI_DEV]
url = https://192.168.1.111:8080/jsonrpc
user = kodi_user
password = kodi_pass
We can use it i.e. on Raspberry PI ZERO with cron:
*/15 6-22 * * * ~/kodi_random_player/.venv/bin/python ~/kodi_random_player/random_play.py
When random_play.py is executed, it checks if kodi player is playing something. If nothing is being played, it will choose random internet radio station and play it. In the code I set search query for station name:
def search_hq_popular_stations(self, what: str = "chill") -> List:
The https://www.radio-browser.info/ is used as a source of internet radio station streams.
Logs are written when nothing is played and random radio stream is starting:
2025.04.06 18:48:58 -> {
"changeuuid": "5360ac6f-d0f5-43a7-bca6-06eb1eede566",
"stationuuid": "7ac57607-cacc-441d-89fe-bcfc1a8faf36",
"serveruuid": "b6c6bd12-dbd3-4c60-8a73-d6ef2c7eab7d",
"name": "Chillsynth",
"url": "https://stream.nightride.fm/chillsynth.mp3",
"url_resolved": "https://stream.nightride.fm/chillsynth.mp3",
"homepage": "https://nightride.fm/stations?station=chillsynth",
"favicon": "https://nightride.fm/apple-touch-icon.png",
"tags": "electronic",
"country": "The United States Of America",
"countrycode": "US",
"iso_3166_2": "",
"state": "",
"language": "",
"languagecodes": "",
"votes": 221,
"lastchangetime": "2025-03-26 12:47:00",
"lastchangetime_iso8601": "2025-03-26T12:47:00Z",
"codec": "MP3",
"bitrate": 320,
"hls": 0,
"lastcheckok": 1,
"lastchecktime": "2025-04-06 08:16:30",
"lastchecktime_iso8601": "2025-04-06T08:16:30Z",
"lastcheckoktime": "2025-04-06 08:16:30",
"lastcheckoktime_iso8601": "2025-04-06T08:16:30Z",
"lastlocalchecktime": "2025-04-06 05:19:00",
"lastlocalchecktime_iso8601": "2025-04-06T05:19:00Z",
"clicktimestamp": "2025-04-06 12:11:00",
"clicktimestamp_iso8601": "2025-04-06T12:11:00Z",
"clickcount": 27,
"clicktrend": -5,
"ssl_error": 0,
"geo_lat": null,
"geo_long": null,
"geo_distance": null,
"has_extended_info": false
}
----------
2025.04.06 18:49:06 -> OK
----------
2025.04.06 18:49:07 -> Barely Sociable - 64 https://stream.nightride.fm/chillsynth.mp3
----------