+ 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
+