beardypig/streamlink-portable

tvr.by : UnicodeEncodeError

karlo2105 opened this issue · 8 comments

As you can see below with fast proxy I got 50 % of time long error messages on streamlink. Is it normal ?
To reproduce it you need to make several attempts.

streamlink -p "%homedrive%\Users\Ddr\Downloads\VLCPortable\App\vlc\vlc" --http-proxy 
"86.57.146.126:3128" "http://www.tvr.by/televidenie/belarus-2"
[cli][info] Found matching plugin tvrby for URL http://www.tvr.by/televidenie/belarus-2
Traceback (most recent call last):
  File "C:\Users\Ddr\Downloads\streamlink\packages\requests\packages\urllib3\con
nection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "C:\Users\Ddr\Downloads\streamlink\packages\requests\packages\urllib3\uti
l\connection.py", line 83, in create_connection
    raise err
  File "C:\Users\Ddr\Downloads\streamlink\packages\requests\packages\urllib3\uti
l\connection.py", line 73, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] Aucune connexion n\u2019a pu être établ
ie car l\u2019ordinateur cible l\u2019a expressément refusée

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Ddr\Downloads\streamlink\packages\requests\packages\urllib3\con
nectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "C:\Users\Ddr\Downloads\streamlink\packages\requests\packages\urllib3\con
nectionpool.py", line 356, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "http\client.py", line 1106, in request
  File "http\client.py", line 1151, in _send_request
  File "http\client.py", line 1102, in endheaders
  File "http\client.py", line 934, in _send_output
  File "http\client.py", line 877, in send
  File "C:\Users\Ddr\Downloads\streamlink\packages\requests\packages\urllib3\con
nection.py", line 166, in connect
    conn = self._new_conn()
  File "C:\Users\Ddr\Downloads\streamlink\packages\requests\packages\urllib3\con
nection.py", line 150, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urll
ib3.connection.HTTPConnection object at 0x02C8CE30>: Failed to establish a new c
onnection: [WinError 10061] Aucune connexion n\u2019a pu être établie car l\u201
9ordinateur cible l\u2019a expressément refusée

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Ddr\Downloads\streamlink\packages\requests\adapters.py", line 4
23, in send
    timeout=timeout
  File "C:\Users\Ddr\Downloads\streamlink\packages\requests\packages\urllib3\con
nectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "C:\Users\Ddr\Downloads\streamlink\packages\requests\packages\urllib3\uti
l\retry.py", line 376, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='86.
57.146.126', port=3128): Max retries exceeded with url: http://www.tvr.by/televi
denie/belarus-2/ (Caused by ProxyError('Cannot connect to proxy.', NewConnection
Error('<requests.packages.urllib3.connection.HTTPConnection object at 0x02C8CE30
>: Failed to establish a new connection: [WinError 10061] Aucune connexion n\u20
19a pu être établie car l\u2019ordinateur cible l\u2019a expressément refusée',)
))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Ddr\Downloads\streamlink\packages\streamlink\plugin\api\http_se
ssion.py", line 164, in request
    *args, **kwargs)
  File "C:\Users\Ddr\Downloads\streamlink\packages\requests\sessions.py", line 4
88, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\Ddr\Downloads\streamlink\packages\requests\sessions.py", line 6
09, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\Ddr\Downloads\streamlink\packages\requests\adapters.py", line 4
85, in send
    raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPConnectionPool(host='86.57.146.126', port=31
28): Max retries exceeded with url: http://www.tvr.by/televidenie/belarus-2/ (Ca
used by ProxyError('Cannot connect to proxy.', NewConnectionError('<requests.pac
kages.urllib3.connection.HTTPConnection object at 0x02C8CE30>: Failed to establi
sh a new connection: [WinError 10061] Aucune connexion n\u2019a pu être établie
car l\u2019ordinateur cible l\u2019a expressément refusée',)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Ddr\Downloads\streamlink\packages\streamlink_cli\main.py", line
 479, in handle_url
    streams = fetch_streams(plugin)
  File "C:\Users\Ddr\Downloads\streamlink\packages\streamlink_cli\main.py", line
 391, in fetch_streams
    sorting_excludes=args.stream_sorting_excludes)
  File "C:\Users\Ddr\Downloads\streamlink\packages\streamlink\plugin\plugin.py",
 line 321, in get_streams
    return self.streams(*args, **kwargs)
  File "C:\Users\Ddr\Downloads\streamlink\packages\streamlink\plugin\plugin.py",
 line 236, in streams
    ostreams = list(ostreams)
  File "C:\Users\Ddr\Downloads\streamlink\packages\streamlink\plugins\tvrby.py",
 line 38, in _get_streams
    res = http.get(self.url)
  File "C:\Users\Ddr\Downloads\streamlink\packages\requests\sessions.py", line 5
01, in get
    return self.request('GET', url, **kwargs)
  File "C:\Users\Ddr\Downloads\streamlink\packages\streamlink\plugin\api\http_se
ssion.py", line 175, in request
    raise err
streamlink.exceptions.PluginError: Unable to open URL: http://www.tvr.by/televid
enie/belarus-2/ (HTTPConnectionPool(host='86.57.146.126', port=3128): Max retrie
s exceeded with url: http://www.tvr.by/televidenie/belarus-2/ (Caused by ProxyEr
ror('Cannot connect to proxy.', NewConnectionError('<requests.packages.urllib3.c
onnection.HTTPConnection object at 0x02C8CE30>: Failed to establish a new connec
tion: [WinError 10061] Aucune connexion n\u2019a pu être établie car l\u2019ordi
nateur cible l\u2019a expressément refusée',))))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Ddr\Downloads\streamlink\\streamlink-script.py", line 12, in <m
odule>
    main()
  File "C:\Users\Ddr\Downloads\streamlink\packages\streamlink_cli\main.py", line
 952, in main
    handle_url()
  File "C:\Users\Ddr\Downloads\streamlink\packages\streamlink_cli\main.py", line
 483, in handle_url
    console.exit(u"{0}", err)
  File "C:\Users\Ddr\Downloads\streamlink\packages\streamlink_cli\console.py", l
ine 69, in exit
    self.msg(u"{0}", msg)
  File "C:\Users\Ddr\Downloads\streamlink\packages\streamlink_cli\console.py", l
ine 45, in msg
    self.output.write(formatted)
  File "encodings\cp850.py", line 19, in encode
UnicodeEncodeError: 'charmap' codec can't encode character '\u2019' in position
413: character maps to <undefined>

I think this is general limitation of the Windows terminal, nothing specific to tvr.by or the proxy. I assume your computer is set to French?
Lemme try and recreate it in Windows 10...

Yes computer is in French. I don't have Windows 10. ;) You think it's Windows 7 limitation ?
I wonder on other plugins, I don't remember even with dead proxies such messages as here above.

Aucune connexion n\u2019a pu être établie car l\u2019ordi
nateur cible l\u2019a expressément refusée'

No connection was established because target computer refused it.

OK, can you see if doing

chcp 65001

before running streamlink fixes it?

Now I have shorter message :

streamlink -p "%homedrive%\Users\Ddr\Downloads\VLCPortable\App\vlc\vlc" 
--http-proxy "86.57.146.126:3128" "http://www.tvr.by/televidenie/belarus-2"
[cli][info] Found matching plugin tvrby for URL http://www.tvr.by/televidenie/be
larus-2
error: Unable to open URL: http://www.tvr.by/televidenie/belarus-2/ (HTTPConnect
ionPool(host='86.57.146.126', port=3128): Max retries exceeded with url: http://
www.tvr.by/televidenie/belarus-2/ (Caused by ProxyError('Cannot connect to proxy
.', NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection obj
ect at 0x02C8BDF0>: Failed to establish a new connection: [WinError 10061] Aucun
e connexion n’a pu être établie car l’ordinateur cible l’a expressément
 refusée',))))

OK... better, still not exactly what you want. What if you do

chcp 65001
set PYTHONIOENCODING=utf-8
streamlink ...

?

I did it step by step and I got same message as above on every attempt but proxy is fast active.
First I thought it was related to proxy, but it loads pages quickly.

It seems to be a limitations of Windows, so I think setting the codepage is closest we can get... I have updated the streamlink.bat to set the codepage to 65001.

Appreciate it. ;)