Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Solved: API Access for Current Playing Info - MicroPython Integration Request
#1
API Access for Current Playing Info - MicroPython Integration Request
Hi All, 

I'm working on a project to display current internet radio station information on a small LCD screen (2.8" display pack) using a Raspberry Pi Pico W with MicroPython. I've successfully enabled the "Metadata file" option in MPD Config, but I'm running into some challenges accessing the current playing information programmatically.

What I'm trying to achieve:
  • Display current song info (for local files) or station name (for radio streams) on a Pico W display
  • Update the display when tracks/stations change
  • Works with both local music files and internet radio streams
Current status:
  • Metadata file is enabled in Audio Config → MPD Options
  • Local network access to Moode web interface works fine
  • WiFi connectivity from Pico W to Moode device is working
The challenge: When attempting to access
Code:
/var/local/www/currentsong.txt
via HTTP requests from MicroPython, I get:
  • Local music files: Works as expected, returns JSON with song metadata
  • Radio streams: Always returns HTTP 302 redirect to
    /images/default-album-cover.png
I understand from the forum that many radio stations don't provide metadata in their streams, which explains the redirect behavior. However, even when no song metadata is available, it would be helpful to at least get the station name that's currently selected/playing.

Questions:
  1. Is there a reliable API endpoint to get the current station name for radio streams, even when song metadata isn't available?
  2. Are there any plans to include basic station info (station name, stream URL) in the currentsong.txt file for radio streams?
  3. Would it be possible to have an additional endpoint like
    /currentstation.txt
Thank you!
Reply
#2
Works ok on my end

Code:
http://moode9/command/?cmd=get_currentsong

{"file":"http:\/\/ice1.somafm.com\/groovesalad-128-aac","artist":"Radio station","album":"Groove Salad [SomaFM]","title":"Afterlife - Ozo","coverurl":"imagesw%2Fradio-logos%2FSoma%20FM%20-%20Groove%20Salad.jpg","track":"","date":"","composer":"","encoded":"AAC","bitrate":"128 kbps","outrate":"PCM 32\/44.1 kHz, 2ch","volume":"15","mute":"0","state":"play"}
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
(06-26-2025, 11:40 AM)Tim Curtis Wrote: Works ok on my end

Code:
http://moode9/command/?cmd=get_currentsong

{"file":"http:\/\/ice1.somafm.com\/groovesalad-128-aac","artist":"Radio station","album":"Groove Salad [SomaFM]","title":"Afterlife - Ozo","coverurl":"imagesw%2Fradio-logos%2FSoma%20FM%20-%20Groove%20Salad.jpg","track":"","date":"","composer":"","encoded":"AAC","bitrate":"128 kbps","outrate":"PCM 32\/44.1 kHz, 2ch","volume":"15","mute":"0","state":"play"}

Thank you for your help Tim, that's solved my issue. Pico display is now working and displaying all the info :Smile
I will clean up the code and put in on github in case anyone wants to do similar.
Thanks again!
Reply


Forum Jump: