SoCo/SoCo — pull request #83 by KennethNielsen (2014-01-12 17:21:10+00:00)
Title: Music library data structures version 2

I have now incorporated all the suggestions from #61, which means that the first part of the data structures work is now once again ready for review. The only part that I have not acted on, is the request to have a data structure for the return values from get_musiclibrary_information (and get_queue). I have decided to save that for the second batch of data structure changes. I have also now written some pytest unit tests, but I will submit those in a separate PR, when this one is pulled.

Below is an edited version of the description of the PR from #61.

Regards Kenneth

=======================================================================

So I finally finished the first batch of the changes to implement classes for data structures. These changes implement data structure for all music library items. The means that:

* get_music_library_information and all the derived methods from that now return music library object e.g. MLTrack etc.
* add_to_queue now no longer accepts URI's as arguments but only instances of MusicLibraryItems. If desired, the old method can be re-added as a legacy function, but I think this is the way to go and it is still possible to make and data structure from a URI and pass that to the method

I have also added some documentation that explains the inheritance for these objects.

All of the data structures can be compare with == and they have usable str representations.

As an experiment I have fully Sphinx'ified all the doc strings. This means that they are less readable from a python interpreter, but much more beautiful and usable on ReadTheDocs.

I have **not yet** modified the get_queue method, since the queue can contain music service tracks and the data structures for those have not yet been implemented. That is next on the list. but I wanted to get some feedback on this first.

Here are some usage examples::

```python
def example_data(soc):
for search in ['folders', 'artists', 'album_artists', 'albums', 'genres',
'composers', 'tracks', 'share', 'playlists']:
items = soc.get_music_library_information(search, 0, 100)
item = items['item_list'][0]
print item
print '{0: <16}{1}'.format(search, item.title.encode('utf-8'))

def example_add(soc):
for search in ['artists', 'album_artists', 'albums', 'genres',
'composers', 'tracks', 'playlists']:
items = soc.get_music_library_information(search, 0, 1)
item = items['item_list'][0]
print item
print 'Press enter to add'
raw_input()
soc.add_to_queue(item)

soc = soco.SoCo('192.168.0.10')
items = soc.get_albums()
print items['item_list'][0]
example_add(soc)
example_data(soc)
```

(careful, the example_add will add stuff to your queue)

Let me know what you think.

Regards Kenneth