Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differentiate between types of search results. #44

Merged
merged 2 commits into from
Jun 1, 2016

Conversation

jcass77
Copy link
Contributor

@jcass77 jcass77 commented Jun 1, 2016

This PR caters for the three different types of search results, and allows the user to test for each based on the format of musicToken.

@jcass77 jcass77 mentioned this pull request Jun 1, 2016
@@ -292,7 +294,18 @@ class SearchResultItem(PandoraModel):

@property
def is_song(self):
return self.song_name is not None
# Song result tokens start with 'S', followed by seven digits.
return re.compile('^([S])(\d{7})$').match(self.token)
Copy link
Owner

@mcrute mcrute Jun 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a startswith check work just as well here or is the stronger validation needed? If you do want the extra validation then you should just use re.match('^([S])(\d{7})$', self.token) since python will memoize the complied regex automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think startswith would actually be better as I have just come across a few instances where musicToken contains more or fewer digits.

Fixed in 27556ee.

@mcrute mcrute merged commit c5fc706 into mcrute:master Jun 1, 2016
@mcrute
Copy link
Owner

mcrute commented Jun 1, 2016

Released as 1.7.2

@jcass77 jcass77 deleted the enhance/search_tokens branch June 6, 2016 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants