move id parsing from application to capability

This commit is contained in:
Bezleputh 2014-02-18 23:13:06 +01:00 committed by Florent
commit b6fd529249
2 changed files with 16 additions and 9 deletions

View file

@ -301,16 +301,9 @@ class Radioob(ReplApplication):
except (IndexError, ValueError):
pass
m = re.match('^(\w+)\.(.*)', _id)
m = ICapAudio.get_object_method(_id)
if m:
if m.group(1) == 'album':
return self.get_object(_id, 'get_album')
elif m.group(1) == 'playlist':
return self.get_object(_id, 'get_playlist')
else:
return self.get_object(_id, 'get_audio')
return self.get_object(_id, m)
return self.get_object(_id, 'get_radio')

View file

@ -110,6 +110,20 @@ class ICapAudio(ICapFile):
"""
Audio file provider
"""
@classmethod
def get_object_method(cls, _id):
m = re.match('^(\w+)\.(.*)', _id)
if m:
if m.group(1) == 'album':
return 'get_album'
elif m.group(1) == 'playlist':
return 'get_playlist'
else:
return 'get_audio'
def search_audio(self, pattern, sortby=ICapFile.SEARCH_RELEVANCE):
"""
search for a audio file