diff options
author | jcass <john.cass77@gmail.com> | 2016-06-01 04:17:09 +0200 |
---|---|---|
committer | jcass <john.cass77@gmail.com> | 2016-06-01 04:17:09 +0200 |
commit | 20080cfc037c0aa281f613c045bccd719bf5668c (patch) | |
tree | a9c3bbf6a895f4c3ddaca17ba7227bed61606c05 /pandora | |
parent | aabde7966a7ffef083f73368ca6f2904a778a78f (diff) | |
download | pydora-20080cfc037c0aa281f613c045bccd719bf5668c.tar.bz2 pydora-20080cfc037c0aa281f613c045bccd719bf5668c.tar.xz pydora-20080cfc037c0aa281f613c045bccd719bf5668c.zip |
Fix SearchResult model.
Diffstat (limited to 'pandora')
-rw-r--r-- | pandora/models/pandora.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/pandora/models/pandora.py b/pandora/models/pandora.py index a3a83b7..d42fe0d 100644 --- a/pandora/models/pandora.py +++ b/pandora/models/pandora.py | |||
@@ -1,3 +1,5 @@ | |||
1 | import re | ||
2 | |||
1 | from .. import BaseAPIClient | 3 | from .. import BaseAPIClient |
2 | from . import with_metaclass, ModelMetaClass | 4 | from . import with_metaclass, ModelMetaClass |
3 | from . import Field, PandoraModel, PandoraListModel, PandoraDictListModel | 5 | from . import Field, PandoraModel, PandoraListModel, PandoraDictListModel |
@@ -292,7 +294,18 @@ class SearchResultItem(PandoraModel): | |||
292 | 294 | ||
293 | @property | 295 | @property |
294 | def is_song(self): | 296 | def is_song(self): |
295 | return self.song_name is not None | 297 | # Song result tokens start with 'S', followed by seven digits. |
298 | return re.compile('^([S])(\d{7})$').match(self.token) | ||
299 | |||
300 | @property | ||
301 | def is_artist(self): | ||
302 | # Artist result tokens start with 'R', followed by six digits. | ||
303 | return re.compile('^([R])(\d{6})$').match(self.token) | ||
304 | |||
305 | @property | ||
306 | def is_composer(self): | ||
307 | # Composer result tokens start with 'C', followed by five digits. | ||
308 | return re.compile('^([C])(\d{5})$').match(self.token) | ||
296 | 309 | ||
297 | def create_station(self): | 310 | def create_station(self): |
298 | if self.is_song: | 311 | if self.is_song: |