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

Allow soundtouch to play https content too #16713

Merged
merged 1 commit into from
Sep 24, 2018
Merged

Conversation

robin13
Copy link
Contributor

@robin13 robin13 commented Sep 19, 2018

No description provided.

@homeassistant
Copy link
Contributor

Hi @robin13,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@robin13
Copy link
Contributor Author

robin13 commented Sep 19, 2018

Home assistant website is broken, so cannot sign CLA...
https://home-assistant.io results in NET::ERR_CERT_COMMON_NAME_INVALID

@@ -297,7 +297,7 @@ def media_album_name(self):
def play_media(self, media_type, media_id, **kwargs):
"""Play a piece of media."""
_LOGGER.debug("Starting media with media_id: %s", media_id)
if re.match(r'http://', str(media_id)):
if re.match(r'https?://', str(media_id)):
Copy link
Member

Choose a reason for hiding this comment

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

You should compile this statement on top.

URL = re.compile(r"..")
...
if URL.match(media_id):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

compiling regexes is generally a best practice, but as this is a function which will be called rarely it seems like unnecessary overhead here to compile a regex for just one execution no?

Copy link
Member

@pvizeli pvizeli Sep 20, 2018

Choose a reason for hiding this comment

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

Yes. You call this regex every time where some one play a URL with this platform. Maybe you use it 1-2 in a month but other could use it 3-6 per day

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pvizeli If we create a URL object here, it will exist for that one match, and as soon as the play_media function is completed, it will go out of scope, and be scrapped... the regular expression is used exactly one time per call of the function, and so there is no advantage in compiling it. Compiling regular expressions is only an advantage when they are being used many times within a context.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's fine to just do it here.

Copy link
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

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

Please next time do not remove the PR template and instead fill it in. It's there for a reason…

@balloob balloob merged commit 589554a into home-assistant:dev Sep 24, 2018
@ghost ghost removed the in progress label Sep 24, 2018
@luca-angemi
Copy link
Contributor

luca-angemi commented Sep 24, 2018

Hi all,

Are we sure this is going to work? It seems from @CharlesBlonde's libsoundtouch that https can't be played.

CharlesBlonde/libsoundtouch#12

@robin13
Copy link
Contributor Author

robin13 commented Sep 25, 2018

Aw shoot... I think you might be right... https://github.com/CharlesBlonde/libsoundtouch#070---20170705

@luca-angemi
Copy link
Contributor

Thanks. @balloob is it possible to unmerge? This will break things with Bose Soundtouch.

@balloob
Copy link
Member

balloob commented Sep 26, 2018

You could have spend the time to make a PR in the time it takes to write that comment 😉

@balloob
Copy link
Member

balloob commented Sep 26, 2018

(it's also not breaking anything)

@balloob balloob mentioned this pull request Sep 26, 2018
@luca-angemi
Copy link
Contributor

You could have spend the time to make a PR in the time it takes to write that comment

haha. I'm not that expert yet :)

@balloob balloob mentioned this pull request Sep 28, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Feb 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants