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

livestreamerrc not parsed correctly on windows #432

Closed
ripdog opened this Issue Jul 3, 2014 · 3 comments

Comments

Projects
None yet
2 participants
@ripdog

ripdog commented Jul 3, 2014

Thanks for this tool, it's fantastic. However, when I made a livestreamerrc at %APPDATA%/livestreamer/liverstreamerrc, it stopped working.

livestreamerrc:

player="F:\Program Files\MPC-HC\mpc-hc.exe"
best-stream-default

Output:

Traceback (most recent call last):
  File "F:\Python34\Scripts\livestreamer-script.py", line 9, in <module>
    load_entry_point('livestreamer==1.8.2', 'console_scripts', 'livestreamer')()
  File "F:\Python34\lib\site-packages\livestreamer_cli\main.py", line 784, in main
    handle_url()
  File "F:\Python34\lib\site-packages\livestreamer_cli\main.py", line 453, in handle_url
    plugin = livestreamer.resolve_url(args.url)
  File "F:\Python34\lib\site-packages\livestreamer\session.py", line 275, in resolve_url
    res = self.http.get(url, stream=True)
  File "F:\Python34\lib\site-packages\requests\sessions.py", line 395, in get
    return self.request('GET', url, **kwargs)
  File "F:\Python34\lib\site-packages\livestreamer\plugin\api\http_session.py", line 116, in request

    *args, **kwargs)
  File "F:\Python34\lib\site-packages\requests\sessions.py", line 349, in request
    prep = self.prepare_request(req)
  File "F:\Python34\lib\site-packages\requests\sessions.py", line 287, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "F:\Python34\lib\site-packages\requests\models.py", line 287, in prepare
    self.prepare_url(url, params)
  File "F:\Python34\lib\site-packages\requests\models.py", line 334, in prepare_url
    scheme, auth, host, port, path, query, fragment = parse_url(url)
  File "F:\Python34\lib\site-packages\requests\packages\urllib3\util.py", line 397, in parse_url
    raise LocationParseError("Failed to parse: %s" % url)
requests.packages.urllib3.exceptions.LocationParseError: Failed to parse: Failed to parse: --player=F:\Program Files\MPC-HC\mpc-hc.exe

For some reason the first argument in the rc is always interpreted as a url? Flipping the args in the rc around, so best-stream-default is first, produces:

livestreamer-script.py: error: unrecognized arguments: --best-stream-default

Windows 8.1, stock install of python3.4, installed with pip install livestreamer.

@chrippa

This comment has been minimized.

Show comment
Hide comment
@chrippa

chrippa Jul 3, 2014

Owner

I'm not sure why it would get interpreted as a URL, but looking at --best-stream-default it seems you have some odd characters in your livestreamerrc. It's possible your text editor is hiding them from you for some reason so you might need to use another one to find and remove them.

Owner

chrippa commented Jul 3, 2014

I'm not sure why it would get interpreted as a URL, but looking at --best-stream-default it seems you have some odd characters in your livestreamerrc. It's possible your text editor is hiding them from you for some reason so you might need to use another one to find and remove them.

@ripdog

This comment has been minimized.

Show comment
Hide comment
@ripdog

ripdog Jul 3, 2014

I switched to UTF-8 without the Byte Order Mark,
and it works fine now. Putting the BOM back in breaks it. Taking it out
fixes again. Hmm, so I guess the code extracting each line from the rc file
to feed to argparse should be excluding the BOM, but isn't? Bug in argparse
or your code?

ripdog commented Jul 3, 2014

I switched to UTF-8 without the Byte Order Mark,
and it works fine now. Putting the BOM back in breaks it. Taking it out
fixes again. Hmm, so I guess the code extracting each line from the rc file
to feed to argparse should be excluding the BOM, but isn't? Bug in argparse
or your code?

@chrippa

This comment has been minimized.

Show comment
Hide comment
@chrippa

chrippa Jul 3, 2014

Owner

Ah, I see, well argparse is responsible for opening and reading the file and only feeds us lines that we parse into arguments. I guess the solution is to strip non-ascii characters from the option name.

Owner

chrippa commented Jul 3, 2014

Ah, I see, well argparse is responsible for opening and reading the file and only feeds us lines that we parse into arguments. I guess the solution is to strip non-ascii characters from the option name.

@chrippa chrippa closed this in bee28f0 Jul 7, 2014

cheah added a commit to cheah/livestreamer that referenced this issue Aug 17, 2014

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