ctrueden / ibroadcast-python

Python client for iBroadcast
The Unlicense
4 stars 0 forks source link

Missing settings from API response #2

Closed robsonke closed 2 months ago

robsonke commented 2 months ago

First of all thanks for this library. I'm currently using it to make iBroadcast part of Music Assistant. What I seem to miss are the basic settings included in the initial response, from the documentation:

{
    "result": true,
    "message": "Success",
    "settings": {
        "librarysongspersecond": 4000,
        "librarybytespersong": 150,
        "artwork_server": "https://artwork.ibroadcast.com",
        "streaming_server": "https://streaming.ibroadcast.com"
    },
    "status": {
        "timestamp": "2021-02-17 18:42:42",
        "lastmodified": "2021-02-17 18:42:42"
    },
    "library": { // library object }
}

Is this correct? I'm willing to create a PR on your repository for implementing this, just let me know.

ctrueden commented 2 months ago

The response from the API call to library.ibroadcast.com is stored into the iBroadcast object's library field. So you can do:

>>> ib = iBroadcast(...)
>>> ib.library['settings']
{'fast_polling': 30, 'streaming_server': 'https://streaming.ibroadcast.com', 'librarybytespersong': 150, 'artwork_server': 'https://artwork.ibroadcast.com', 'librarysongspersecond': 4000, 'slow_polling': 300}
>>> ib.library['status']
{'app_available': False, 'lastmodified': '2024-09-03 19:21:35', 'expires': '2024-07-13 21:09:45.000000', 'timestamp': '2024-06-29 21:09:45', 'app_version': '6.5'}

And for the initial login, the response is stored in the status field:

>>> ib.status['user'].keys()
dict_keys(['email_address', 'password_change', 'premium', 'verified_on', 'client', 'facebook', 'subscription', 'verified', 'remote_addr', 'preferences', 'device_name', 'id', 'userid', 'tester', 'username', 'token', 'user_id', 'profiles', 'user_agent', 'session', 'created_on'])

Does that contain what you're looking for?

robsonke commented 2 months ago

Oh I'm stupid, I should have just tried it. I looked up for references in the code but you automap the json keys to fields obviously.

This should be fine! Lets close this one.

ctrueden commented 2 months ago

Glad that will work! Please feel welcome to open issues if anything else comes up.