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

Relative path for livestreamer/video player executable & settings for portable setup #237

Closed
Wiethoofd opened this issue Apr 13, 2016 · 6 comments

Comments

@Wiethoofd
Copy link

Tried creating a portable version of the GUI by moving livestreamer + video player into the gui folder.

Expected vs. Actual behavior

Set relative paths to livestreamer in Executable location & Videoplayer and expected everything to work as intended. Instead of launching a video player it throws errors about missing dependencies/executables and thus watching streams only works with absolute paths to the required files.

Reproduction steps

  1. Set Executable location and/or Videoplayer paths to be relative to the Livestreamer GUI executable/folder (without modifying PATH system variable)
    • Error: Livestreamer could not be found
    • Error: Invalid player
      • error: Failed to start player <relative path to video player .exe> ([Error 2] Can't find file)
  2. Change locations to executables to be absolute paths and everything works as intended

Environment details (operating system/video players)

  • Windows 7, GOM Player/MPC-HC
  • Unmodified System & Environment variables related to $PATH

Other
For a true portable GUI having the option to move %LOCALAPPDATA%\livestreamer-twitch-gui inside the Livestreamer GUI folder so you don't have to log in to Twitch when switching devices would also be neat.

@Wiethoofd Wiethoofd changed the title Relative path for livestreamer/video player executable for portable setup Relative path for livestreamer/video player executable & settings for portable setup Apr 13, 2016
@bastimeyer
Copy link
Member

You can set custom paths for both livestreamer and your video player in the settings menu. This doesn't even require advanced settings to be enabled.

If you're unable to launch livestreamer from a custom location, then it's not the fault of the GUI. It is only looking for the livestreamer executable in directories of the system's PATH variable if you did not set a custom location.
If you did not set a custom video player executable in the settings, then the GUI won't set the --player parameter and livestreamer will try to launch the one defined in your .livestreamerrc config file, or VLC from the expected default path.
Every custom path can be absolute or relative to the CWD.

You can also tell the GUI to create the config folder at a different place by launching it with the --data-path=/path/to/your/config/folder parameter.

@Wiethoofd
Copy link
Author

Wiethoofd commented Apr 16, 2016

Over simplified folder structure & relative paths to the executables set in the Settings in my attempt to create a portable version of GUI without running any installers.

livestreamer-twitch-gui/
  ├── livestreamer-v1.12.2/livestreamer.exe
  ├── MPC-HC/mpc-hc.exe
  └── livestreamer-twitch-gui.exe

I downloaded livestreamer-twitch-gui-v0.13.0-win32.zip, extracted this and moved mpc-hc player+livestreamer in this folder, set paths to livestreamer and video player executables as listed above in the Settings through the GUI.

Moving the config folder to the livestreamer gui directory works, but --data-path isn't stored anywhere and needs to be there for every launch through a shortcut/.bat launcher, also creating/setting a config file with --config doesn't work for the GUI. Not running any installer means no .livestreamerrc file (?)

@bastimeyer
Copy link
Member

--data-path isn't stored anywhere and needs to be there for every launch through a shortcut/.bat launcher

Right, you need a shortcut with the data path parameter for the GUI, or else it doesn't know where your config folder is located. Simply use the --data-path=./data parameter in your shortcut and set the current working directory to the folder of the GUI's executable, so that the relative path will work.

Then go to the settings menu, set the livestreamer executable path to ./livestreamer-v1.12.2/livestreamer.exe. If you also want to set a custom livestreamer config file (although you really don't need to), you can do this by setting the custom livestreamer parameters in the GUI to --config "./custom-livestreamer-config.conf". I'm not sure if the path is relative to the livestreamer executable or the GUI, you need to test this for yourself. The same is true for the --player parameter (the custom player path).

creating/setting a config file with --config doesn't work for the GUI

This absolutely does work, unless you have messed up the config file itself. Livestreamer doesn't report this error correctly and will just complain about invalid arguments. If it works from the shell, it will work from the GUI, too. The GUI does parse the custom livestreamer parameters correctly.

Not running any installer means no .livestreamerrc file

No. The installer doesn't magically change the logic of livestreamer. It just installs a local python runtime alongside livestreamer and upgrades your system's PATH variable. That's all.
Here you can see where livestreamer will look for the default config file:
https://github.com/chrippa/livestreamer/blob/v1.12.2/src/livestreamer_cli/constants.py#L11

@Wiethoofd
Copy link
Author

Set the paths as mentioned and get the same errors as described in the first post.

Changing working directory to use relative paths would be leaving the 'Start in' blank in the shortcut, which doesn't work; or setting it to be the same folder, which won't work if you get assigned different drive letters when the folder is on a usb drive.

Setting --working-directory to "" or %cd% or the current folder path with a .bat file launching the GUI .exe or in the shortcut doesn't work either and still throws the same errors about a missing livestreamer. (used wmic process where "Name='livestreamer-twitch-gui.exe'" get CommandLine I found here)

There is no livestreamerrc to be found anywhere (I never ran any installers (for GUI, livestreamer or video player), nor is it created on launching the GUI) and yes, hidden files and .dot files are set to be visible in Explorer.

@bastimeyer
Copy link
Member

Sorry for not responding, I'm busy with other stuff right now...

The main issue here (on Windows) is the way how nw-builder is compiling the application. The app content is being appended to the NW.js binary during compilation and when launching the executable, it's being extracted into a temp directory. NW.js is then starting a sub-process and is reading the extracted app content from there. The issue is basically NW.js using a different CWD in the sub-process than the main-process. I don't know if this is intended, but it definately breaks it in this case here.

I didn't notice this, because I was testing the relative directories while launching the application on Windows from my repo by running grunt run:src.

Since the new NW.js releases >= v0.13.0 have been completely rewritten, there might be a chance that this has been corrected, but as I've already said in various other threads here, I'm unable to upgrade yet. The builder still doesn't properly support the new releases and there are also still some other breaking issues.

Another way of fixing this could be the builder implementing another compilation method and using a nw.pak file instead of appending the content to the executable. But yeah, nothing I can do about here.

@bastimeyer
Copy link
Member

Okay, I think I have fixed the issue.
Could you please try the cwd-fix branch and tell me if this fixes the issue for you?
@Wiethoofd @00xe

See 2e30ccf#diff-bdc31e004b6810cec4c935bf20daa497R12

This is how you can test it (requires git, nodejs and npm):

git clone --branch cwd-fix https://github.com/bastimeyer/livestreamer-twitch-gui.git
cd livestreamer-twitch-gui
npm install -g grunt-cli bower
npm install
# run this for a debug build
grunt build compile
# or this for a release build
grunt release

The executable can be found in the build/releases folder.

Thanks.

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

No branches or pull requests

2 participants