Coverage for coherence/upnp/services/clients/content_directory_client.py : 33%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# Licensed under the MIT license # http://opensource.org/licenses/mit-license.php
# Copyright (C) 2006 Fluendo, S.A. (www.fluendo.com). # Copyright 2006, Frank Scholz <coherence@beebits.net>
global work, pending
# print "ContentDirectoryClient __init__", self.url
# def __del__(self): # print "ContentDirectoryClient deleted" # pass
self.service.remove() self.service = None self.namespace = None self.url = None del self
self.service.subscribe_for_variable(var_name, instance=0, callback=callback, signal=signal)
action = self.service.get_action('GetSearchCapabilities') return action.call()
action = self.service.get_action('GetSortExtensionCapabilities') return action.call()
action = self.service.get_action('GetFeatureList') return action.call()
action = self.service.get_action('GetSystemUpdateID') return action.call()
filter='*', sort_criteria='', starting_index=0, requested_count=0, process_result=True, backward_compatibility=False):
items = [] if results is not None: elt = DIDLLite.DIDLElement.fromString(results['Result']) items = elt.getItems() return items
# print result r = {} r['number_returned'] = result['NumberReturned'] r['total_matches'] = result['TotalMatches'] r['update_id'] = result['UpdateID'] r['items'] = {} elt = DIDLLite.DIDLElement.fromString(result['Result']) for item in elt.getItems(): # print "process_result", item i = {} i['upnp_class'] = item.upnp_class i['id'] = item.id i['title'] = item.title i['parent_id'] = item.parentID if hasattr(item, 'childCount'): i['child_count'] = str(item.childCount) if hasattr(item, 'date') and item.date: i['date'] = item.date if hasattr(item, 'album') and item.album: i['album'] = item.album if hasattr(item, 'artist') and item.artist: i['artist'] = item.artist if hasattr(item, 'albumArtURI') and item.albumArtURI: i['album_art_uri'] = item.albumArtURI if hasattr(item, 'res'): resources = {} for res in item.res: url = res.data resources[url] = res.protocolInfo if len(resources): i['resources'] = resources r['items'][item.id] = i return r
BrowseFlag=browse_flag, Filter=filter, SortCriteria=sort_criteria, StartingIndex=str(starting_index), RequestedCount=str(requested_count)) d.addCallback(got_process_result) # else: # d.addCallback(got_result)
requested_count=0): # print "search:", criteria return None SearchCriteria=criteria, Filter="*", StartingIndex=starting_index, RequestedCount=requested_count, SortCriteria="")
upnp_class = DIDLLite.upnp_classes.get( elements.get('upnp_class', None), None) if upnp_class is None: return None
del elements['upnp_class'] item = upnp_class(id='', parentID=elements.get('parentID', None), title=elements.get('title', None), restricted=elements.get('restricted', None)) for k, v in list(elements.items()): attribute = getattr(item, k, None) if attribute is None: continue attribute = v
return item
if isinstance(elements, dict): elements = self.dict2item(elements) if isinstance(elements, DIDLLite.Object): didl = DIDLLite.DIDLElement() didl.addItem(elements) elements = didl.toString() if elements is None: elements = '' action = self.service.get_action('CreateObject') if action: # optional return action.call(ContainerID=container_id, Elements=elements) return None
action = self.service.get_action('DestroyObject') if action: # optional return action.call(ObjectID=object_id) return None
action = self.service.get_action('UpdateObject') if action: # optional return action.call(ObjectID=object_id, CurrentTagValue=current_tag_value, NewTagValue=new_tag_value) return None
action = self.service.get_action('MoveObject') if action: # optional return action.call(ObjectID=object_id, NewParentID=new_parent_id) return None
action = self.service.get_action('ImportResource') if action: # optional return action.call(SourceURI=source_uri, DestinationURI=destination_uri) return None
action = self.service.get_action('ExportResource') if action: # optional return action.call(SourceURI=source_uri, DestinationURI=destination_uri) return None
action = self.service.get_action('DeleteResource') if action: # optional return action.call(ResourceURI=resource_uri) return None
action = self.service.get_action('StopTransferResource') if action: # optional return action.call(TransferID=transfer_id) return None
action = self.service.get_action('GetTransferProgress') if action: # optional return action.call(TransferID=transfer_id) return None
action = self.service.get_action('CreateReference') if action: # optional return action.call(ContainerID=container_id, ObjectID=object_id) return None
|