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

Ability to launch streams from outside the application (for browser integration etc) #613

Closed
2 tasks done
CodilX opened this issue Jan 16, 2019 · 6 comments
Closed
2 tasks done

Comments

@CodilX
Copy link

CodilX commented Jan 16, 2019

Feature request

  • I understand the difference between Streamlink and Streamlink Twitch GUI.
  • This is a feature request and I have read the contribution guidelines.

Description

It would be amazing if we could have an option to launch a stream externally - not using the app itself. A custom protocol handler would be the best. The use case could be browser integration - using Greasemonkey or something similar to inject buttons on Twitch with the URL such as twitchgui://some_stream.

I find it easier to browse Twitch via the website, then I switch to the application, find the stream I was watching and launch it from there. Having a button on Twitch that would do that automatically would be so great, all we need is some kind of external interaction with the app itself.

@bastimeyer
Copy link
Member

Supporting the registration of custom protocol handlers on all supported OSes, namely Linux, Windows and macOS is quite challenging. The registration methods don't just dramatically differ from OS to OS, but also from OS version to OS version. On Linux there are also a few differences between desktop environments, even though the XDG standard exists. That means you don't have to just "support Linux", but individual desktop environments, and there are a lot.

Unfortunately, there are no (usable) NodeJS modules available in the NPM registry for registering custom protocol handlers and they would have to be built from scratch. The only one that's available is for Windows, but it can't be used here, because it requires some dependencies being compiled for NW.js' NodeJS runtime, which can't be done with the nw-builder tool that's being used here to make the final app builds.

If you want to properly implement custom protocol handlers, you have to deal with a lot of stuff and care for a lot of edge cases. As an example of an edge case, there's the problem of the application path, which isn't static for the "portable" releases and once it changes, the registered protocol needs to be re-applied.

I don't think it's worth spending time on implementing custom protocol handlers unless well written and tested NodeJS modules are already available.


If you want to launch streams from an external source, you can already do that via the app's --launch parameter. See the parameters page on the wiki:
https://github.com/streamlink/streamlink-twitch-gui/wiki/Parameters

AFAIK, you can also set up custom handlers in Firefox, which would make it easy to write a browser extension or even a so called "bookmarklet" that makes you launch streams listed on the Twitch website with Streamlink.

@CodilX
Copy link
Author

CodilX commented Jan 16, 2019

@bastimeyer - I haven't looked into NodeJS support for protocol links, however the workaround could be Twitch GUI listening for http requests on some random port, the same could be achieved as a protocol link.

Edit: I tried using the --launch option, however it only works if Twitch GUI is closed, then it launches the application and opens the stream. However if the application is already opened the parameter doesn't actually launch a stream - it just does nothing. This could work in terms of what I meant with this suggestion if the the --launch didn't require Twitch GUI to be closed..

@bastimeyer
Copy link
Member

http requests

This seems unnecessary...

it only works if Twitch GUI is closed

You have to enable the "allow external commands" option in the settings menu (enable advanced settings first) in order to be able to receive parameters from other application starts.

However, there seems to be a bug with the parsed command line. NW.js is a bit stupid here and the passed command line gets merged with internal Chromium parameters at arbitrary positions. Those have to be filtered out and it seems that something broke here recently.
https://github.com/streamlink/streamlink-twitch-gui/blob/v1.6.0/src/app/nwjs/argv.js#L71-L82
Unfortunately, this can't be tested reliably, since it depends on NW.js not messing things up.
https://github.com/streamlink/streamlink-twitch-gui/blob/v1.6.0/src/test/tests/nwjs/argv.js#L160-L208

I'll see if I can fix this when I get the time.

@CodilX
Copy link
Author

CodilX commented Jan 16, 2019

Enabled advanced settings and enabled allow external commands - still not working from the command line if Twitch GUI is already launched, the cursor spins for a split second and nothing happens.

"C:\Program Files\Streamlink Twitch GUI\streamlink-twitch-gui.exe" --launch "summit1g"

bastimeyer added a commit that referenced this issue Jan 16, 2019
@CodilX
Copy link
Author

CodilX commented Jan 16, 2019

http requests

This seems unnecessary...

As far as I understand Twitch GUI already runs an http server for authentication to Twitch http://localhost:65432/redirect. Adding an option (disabled by default) for controlling Twitch GUI via http requests would be beneficial to some users if protocol handling is out of scope for Node and/or NW.js.

I'll fiddle around with custom protocols to get what I want working (launching streams in Twitch GUI via browser), I just hope one day something could be implemented that would allow more robust external controls of the application.

@bastimeyer
Copy link
Member

Regarding the --launch parameter, this was a bug in NW.js and has been fixed a long time ago. The recent Streamlink Twitch GUI releases already included this fix.

I'm closing the thread now, as there are no plans for implementing an HTTP server for sending commands to the GUI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants