oscartbeaumont / ElectronPlayer

An Electron Based Web Video Services Player. Supporting Netflix, Youtube, Twitch, Floatplane, Hulu And More
MIT License
484 stars 89 forks source link

Feature Request: Option to launch a service via the terminal #79

Open zefir-git opened 3 years ago

zefir-git commented 3 years ago

Feature Request

It would be nice to be able to pass arguments like electronplayer --service netflix that would launch the specified service. This would allow people who have downloaded the app specifically for one of the services to be able to create a separate .desktop file with its icon, etc. I currently have set Netflix as the default service, but I would like to be able to create a separate file with the service icon and name entirely for aesthetical purposes.

zefir-git commented 3 years ago

https://www.electronjs.org/docs/api/command-line

Having found this, I might create a pull request with it implemented.

zefir-git commented 3 years ago

I can't really understand exactly how the application works, but this should be the code:

if (app.commandLine.hasSwitch('service') {
    const { app } = require('electron');
    //find service by name
    let service = services.filter(service => {
      //both to lowercase to make it case insensitive
      return service.name.toLowerCase() === app.commandLine.getSwitchValue("service").toLowerCase()
    })[0]; //get 1st result

    //client side
    animateLoader(service, createElement('img', null, service.style));
    console.log(
      `Switching to service ${service.name}} at the URL ${service.url}...`
    );
    ipc.send('open-url', service);
}