Adding an API to the B2

157 views
Skip to first unread message

Jasper Warwick

unread,
Mar 16, 2018, 6:34:54 AM3/16/18
to Brennan Forum
This is a bit of a blue sky thinking type of post......

Having read and taken part in this forum for some months now I have come to the conclusion that;

1. Everyone seems to have a different idea on what they want to do with their B2
2. There are lots of clever people contributing
3. I was able to make a huge different to what I get of of my B2 by writing some fairly simple software to improve its library organisation.

I think there is also quite a challenge in how to develop the B2 software as whatever you do is sure to please some people and annoy others. If you try to make it all things to all people you run the risk of making the software overly complicated and unwieldy.

A possible solution is to provide an API (Application Programming Interface) to the B2, this would allow people to develop their own PC or Mac (or even phone) apps to help organise their music collections and even control the B2. This is something that I certainly would want to do myself. It would then be possible to share these applications with other B2 users. At is most basic level it would allow you to manage your library and playlists remotely, provide functions for  setting and reading attributes for artists, albums, and tracks (ID3 Tags) but obviously could be expanded to allow programmatic access to any of the B2 functionality. To some extent you can do this already just by accessing the library through the NAS but it is slow and very limited on what you can do with it.

What got me started on this thought process (apart from far too much free time on my hands) as a discussion with an other user about how he wanted to have a much more complex categorisation of his classical music collection and how it would be a complete nightmare to do it with the B2 but how much more easily it could be done on a spreadsheet. I suppose the principle I an working to is that the B2 focuses on the media player aspects of the user experience while the more data orientated aspects of library management is offloaded to the PC or Mac. Obviously the standard B2 software would have basic library management functionality much as it does now but for those people that want something more sophisticated there would be a library of user contributed utilities they could access.

If this strikes a chord with Martin or any other users I am happy to develop the idea to see if it has legs.

Jasper.



Jasper Warwick

unread,
Mar 18, 2018, 9:15:02 AM3/18/18
to Brennan Forum
If you were to provide a more sophisticated way of managing libraries then playlists are the obvious way to display it to the user. The structure of Artist Album Track is pretty universal as a folder structure and I don't think it would be sensible to play around with that. The current playlist system is pretty good but does tend to be less easy to use if you have a large number of playlists. A solution might be to allow nested playlists, it would be easy to use folders to hold the nesting structure. You could then have a more sophisticated navigation pane (popup window?) to help the user navigate the structure. I mocked up something below.


My idea is to build on the existing system which personally I really like but make it a bit more flexible.



Brennan Support

unread,
Mar 20, 2018, 5:31:31 AM3/20/18
to Brennan Forum
Hello Jasper

I'm happy for you to explore this angle - in fact there is an API and while there isn't a document describing it - because I'd be the author and the only reader - the API is completely visible and open for use.

If you open up Chrome on the B2 Web UI then click on the three dots at the top right of the browser and go to more tools->Developer tools you get a debug window that shows whats going on.

There's a lot going on in that window - but if you click the network tab you will see the HTTP requests sent from the browser to B2.

They look complicated but actually they are very simple and the seemingly random number - is just the tme - which is needed to make Internet Explorer stop caching everything.

So if you were to create a web page - say jasper.html - and save it to /var/www on the B2 (using SCP) then the B2 would serve your webpage when you put /192.168.0.4/jasper.html into the browser.

You could even replace the b2 web UI - if you overwrite index.html

But basically the javascript in jasper.html is free to make any requests and present the reply (mostly json data) how you see fit - so yes you can have an entirely bespoke web UI.

You could also have a go at editing index.html - so start from something working - but its pretty big and messy to get started.

If you ever wanted a new API - because you wanted to do something that isn't available - its usually very quick to add.

Food for thought

Martin 

Tony

unread,
Mar 20, 2018, 9:44:48 AM3/20/18
to Brennan Forum
Martin :  

Are you willing to take the 30 minutes to cut & paste the list of defined API functions from the code from the b2 task as a form of documentation?  That's probably all the the effort required at this point.

Tony

Brennan Support

unread,
Mar 21, 2018, 5:42:32 AM3/21/18
to Brennan Forum
Hello Tony

30 minutes not available - two minutes yes - I just cut and pasted a section from the code that shows the API function names - you will have to do some reverse engineering.

Martin
api.c
Reply all
Reply to author
Forward
0 new messages