Thank you for your donation!


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


Internal API question
#1
Hi!

I'm toying with idea of making an alternative client app for Moode player, and been looking into its internal API for displaying music. It's been a while since I touched web development, so my question is likely very silly. I'm trying to figure out an HTTP request to get the all the library contents. I've found the command that should give me what I want, however it returns an empty structure:


Code:
$ curl http://192.168.0.7/command/music-library.php?cmd=load_library
[{"file":"","tracknum":"","title":"","disc":"1","artist":[""],"album_artist":"","composer":"Composer tag missing","year":"","time":"",
"album":"Nothing found","genre":[""],"time_mmss":"","last_modified":null,"encoded_at":"0","comment":"","mb_albumid":"0"}]

This is strange because the very same API call when debugging in the browser gives me a different output with all the tracks in the database. Am I missing something obvious?
Reply
#2
If you are going to use curl commands from the shell then you need to provide some options to create the correct http request to the back end php scripts like below. You could prolly get by with just providing the session cookie (the -b option) but YMMV.

Code:
curl -X GET -b PHPSESSID=ho7vk67sqrjua8sme0pqhsjgdq -H "Content-type: application/json" -H "Accept: application/json" "IP_ADDRESS_OR_HOST/command/music-library.php?cmd=load_library"
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
Thanks, Tim! This worked, and I'm not sure what is the significance of the specific PHPSESSID value you provided, but it only works with it and not if I try to change it. I'll read up, but this is already very useful for me.
Reply
#4
The PHP session id is needed because most of the PHP scripts need r/w access to the session file which contains all the session variables and their values for example $_SESSION['volknob'].

You can easily dump the session file using the command below. Note that all the radio station URL's are stored in the session file to make then easy to access from the front-end.

Code:
sudo moodeutl -d

Example using grep to filter the output for a specific set of variables

Code:
pi@sig:~ $ sudo moodeutl -d | grep library
library_utf8rep|No
library_show_genres|Yes
library_onetouch_album|Show tracks
library_recently_added|2592000000
library_covsearchpri|Embedded cover
library_hiresthm|600px,60
library_pixelratio|1
library_tagview_artist|Artist
library_ignore_articles|a,an,the
library_albumview_sort|Artist/Year
library_tagview_covers|Yes
library_tagview_sort|Album/Year
library_ellipsis_limited_text|Yes
library_thumbnail_columns|6/2 (Default)
library_encoded_at|1
library_flatlist_filter|full_lib
library_flatlist_filter_str|
library_misc_options|No,Album@Artist (Default)
library_onetouch_radio|Play
library_tagview_genre|Genres
library_track_play|Track
library_onetouch_pl|No action
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Forum Jump: