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

Add support for DRTV app as a custom controller #646

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mchro
Copy link

@mchro mchro commented Jul 4, 2022

Notably, the app requires two JWTs ("session tokens") to allow playback. These
can either be retrieved from a browser and given (expiry seem to not be
critical), or alternatively retrieval of an anonymous token using Selenium will
be attempted.

print(msg)
self.send_message(msg, inc_session_id=True, callback_function=callback_function)

def _get_drtokens(self):
Copy link
Author

Choose a reason for hiding this comment

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

Guidance on whether this approach to retrieving tokens is acceptable is welcome :-)
It should work with Selenium as an optional dependency in this way.

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, this is not OK.
Make the token a mandatory input parameter to quick_play instead if it's needed for all media.

What's the lifetime of the tokens?

Copy link
Author

@mchro mchro Jul 7, 2022

Choose a reason for hiding this comment

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

The tokens are mandatory for all media. The stated lifetime of the tokens is 12 hours; there seems to be some grace period, but I have been unable to ascertain how much.
I'm mostly worried about the user experience, if having to provide a hardcoded token that then regularly expires. Of course we could leave it up to the consumer of this API, i.e. somewhere inside Home Assistant, to do the token maintenance?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe code for getting the token etc. would fit in well in https://github.com/Eerovil/castextensions, @Eerovil wdyt?

Copy link
Author

Choose a reason for hiding this comment

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

In the meantime I have pushed a commit to make the tokens a mandatory parameter in the controller, but left the Selenium way in the example code.
I also dug a bit deeper in the JWTs, and found a parameter in there indicating the tokens are valid for 1 month.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe code for getting the token etc. would fit in well in https://github.com/Eerovil/castextensions, @Eerovil wdyt?

Castextensions isn't maintained and most of the functionality for half the apps is mostly broken... But yes, this would fit nicely.

Notably, the app requires two JWTs ("session tokens") to allow playback. These
can either be retrieved from a browser and given (expiry seem to not be
critical), or alternatively retrieval of an anonymous token using Selenium will
be attempted.
@emontnemery
Copy link
Collaborator

but left the Selenium way in the example code

That's fine.
Unless it's trivial, please amend the example with instructions on how to setup selenium and so on.

@mchro
Copy link
Author

mchro commented Jul 12, 2022

but left the Selenium way in the example code

That's fine. Unless it's trivial, please amend the example with instructions on how to setup selenium and so on.

Should be pretty trivial, just needs the Python module selenium and Chromium. I'll link the official module.

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.

3 participants