Skip to content

Commit

Permalink
Fix #2: Add workaround for minidlna crashing on empty filter.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkem committed Apr 8, 2015
1 parent 5a37a03 commit 5094a94
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
5 changes: 0 additions & 5 deletions README.rst
Expand Up @@ -72,11 +72,6 @@ Known Bugs and Limitations
Currently, only the browse interface is implemented, so searching will
return no results from Digital Media Servers.

Browsing through this extension may crash at least some versions of
minidlna_ (a.k.a ReadyMedia, the NAS daemon provided with many NETGEAR
routers). The reasons for this, and possible workarounds, remain to
be investigated.


.. _Mopidy: http://www.mopidy.com/
.. _DLNA: http://www.dlna.org/
Expand Down
22 changes: 11 additions & 11 deletions mopidy_dleyna/library.py
Expand Up @@ -12,7 +12,7 @@

logger = logging.getLogger(__name__)

_BROWSE_FILTER = ['DisplayName', 'Path', 'Type']
_BROWSE_FILTER = ['*']


def _item_to_track(props):
Expand Down Expand Up @@ -55,20 +55,17 @@ def browse(self, uri):
refs.append(Ref.track(name=name, uri=uri))
else:
manager = self.__get_object(SERVER_ROOT_PATH, MANAGER_IFACE)
for path in manager.GetServers():
props = self.__get_object(path, dbus.PROPERTIES_IFACE)
try:
name = props.Get('', 'FriendlyName')
except Exception:
name = props.Get('', 'DisplayName')
refs.append(Ref.directory(name=name, uri='dleyna:'+path))
for obj in map(self.__get_properties, manager.GetServers()):
name = obj.get('FriendlyName', obj.get('DisplayName'))
uri = 'dleyna:' + obj['Path']
refs.append(Ref.directory(name=name, uri=uri))
return refs

def lookup(self, uri):
_, _, path = uri.partition(':')
props = self.__get_object(path, dbus.PROPERTIES_IFACE)
if props.Get('', 'Type') == 'music':
return [_item_to_track(props.GetAll(''))]
props = self.__get_properties(path)
if props.get('Type') == 'music':
return [_item_to_track(props)]
else:
return [] # TODO: lookup containers, etc.

Expand All @@ -81,3 +78,6 @@ def __get_object(self, path, iface=None):
return dbus.Interface(obj, iface)
else:
return obj

def __get_properties(self, path):
return self.__get_object(path, dbus.PROPERTIES_IFACE).GetAll('')

0 comments on commit 5094a94

Please sign in to comment.