Updating the new implementation of ZukeboxControlPoint class, adding soap_GetPlaylist...
authorHenry Bilby <henrymiller.engenheiro@gmail.com>
Fri, 5 Jun 2009 13:10:42 +0000 (09:10 -0400)
committerHenry Bilby <henrymiller.engenheiro@gmail.com>
Fri, 5 Jun 2009 13:10:42 +0000 (09:10 -0400)
control_point/zukebox_control_point.py
zukebox_server/src/services/playlist/zb_playlist.py
zukebox_server/src/xml_descriptions/zukebox-playlist-scpd.xml

index fefad8a..82d3585 100644 (file)
@@ -68,14 +68,108 @@ class ZukeboxControlPoint(ControlPointAV):
 
         return False
 
+
     def get_playlist(self, cp):
-        print 'Ainda falta implementar a chamada do playlist, esqueci o codigo no lab' 
 
-    def search(self, cp):
-        print 'O mesmo para o print acima - search '
+       playlist = {}
+       try:
+            device = cp.get_current_server()
+            service = device.get_service_by_type('urn:schemas-upnp-org:service:Playlist:1')
+            playlist = service.GetPlaylist()
+       except Exception, e:
+            if not service:
+                print 'Service not discovered. Exception: %s' %e
+            elif not playlist:
+               print 'Error in get current playlist. Exception: %s' %e
+           else:
+               print '%s'%e
+           playlist = None
+       
+       return playlist
+
+
+    def searchGenreList(self, cp, genreType):
+
+       genre = {}
+       try:
+           device = cp.get_current_server()
+           service = device.get_service_by_type('urn:schemas-upnp-org:service:Search:1')
+           GenreType = {'GenreType':genreType}
+           genre = service.SearchGenreList(GenreType)
+       except Exception, e:
+           if not service:
+               print 'Service not discovered. Exception: %s' %e
+           elif not genre:
+               print 'Error in get genre type list. Exception: %s' %e
+           else:
+               print '%s' %e
+           genre = None
+
+       return genre
+
+
+    def searchMusicList(self, cp, music_name):
+
+       music = {}
+       try:
+           device = cp.get_current_server()
+           service = device.get_service_by_type('urn:schemas-upnp-org:service:Search:1')
+           MusicName = {'MusicName':music_name}
+           music = service.SearchMusicList(MusicName)
+       except Exception, e:
+           if not service:
+               print 'Service not discovered. Exception: %s' %e
+           elif not music:
+               print 'Error in get music list by name. Exception: %s' %e
+           else:
+               print '%s' %e
+           music = None
+
+       return music
+           
+
+    def searchArtistList(self, cp, artist_name):
+
+       artist = {}
+       try:
+           device = cp.get_current_server()
+           service = device.get_service_by_type('urn:schemas-upnp-org:service:Search:1')
+           ArtistName = {'ArtistName':artist_name}
+           artist = service.SearchMusicList(ArtistName)
+       except Exception, e:
+           if not service:
+               print 'Service not discovered. Exception: %s' %e
+           elif not artist:
+               print 'Error in get artist list by name. Exception: %s' %e
+           else:
+               print '%s' %e
+           artist = None
+
+       return artist
+
+
+    def searchAllAudioList(self, cp):
+
+       all_audio = {}
+       try:
+           device = cp.get_current_server()
+           service = device.get_service_by_type('urn:schemas-upnp-org:service:Search:1')
+           all_audio = service.SearchMusicList()
+       except Exception, e:
+           if not service:
+               print 'Service not discovered. Exception: %s' %e
+           elif not all_audio:
+               print 'Error in get music list by name. Exception: %s' %e
+           else:
+               print '%s' %e
+           all_audio = None
+
+       return all_audio
+
 
     def content_directory(self, cp):
-        print 'O mesmo para o print acima - content_directory '
+        print 'Testing content_directory acess '
+
 
     def stop(self, cp):
         cp.stop()
index fd4b067..74fdd05 100644 (file)
@@ -116,6 +116,10 @@ class PlayList(Service):
         prev_uri = prev["cur_uri"]
         return {"PreviousItem": prev_uri}
 
+    def soap_GetPlaylist(self, *args, **kwargs):
+        """Get the playlist"""
+        return {"Playlist": self.list}
+
 
     def clean_playlist(self):
         if self.available:
index fb348e5..b622ffd 100644 (file)
                                </argument>
                        </argumentList>
                </action>
+               <action>
+                       <name>GetPlaylist</name>
+                       <argumentList>
+                               <argument>
+                                       <name>Playlist</name>
+                                       <direction>out</direction>
+                                       <relatedStateVariable>A_ARG_TYPE_GetPlaylist</relatedStateVariable>
+                               </argument>
+                       </argumentList>
+               </action>
        </actionList>
        <serviceStateTable>
                <stateVariable sendEvents="no">
                        </allowedValueRange>
                </stateVariable>
                <stateVariable>
+                       <name>A_ARG_TYPE_GetPlayList</name>
+                       <dataType>ui4</dataType>
+                       <allowedValueRange>
+                               <minimum>0</minimum>
+                               <maximum>10</maximum>
+                               <step>1</step>
+                       </allowedValueRange>
+               </stateVariable>
+               <stateVariable>
                        <name>A_ARG_TYPE_Item</name>
                        <dataType>string</dataType>
                </stateVariable>