diff options
Diffstat (limited to 'pandora/models/pandora.py')
-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: |