Hellowlol / bw_plex

binge watching for plex
MIT License
368 stars 23 forks source link

Error Connecting to Devices #70

Closed Letahl closed 5 years ago

Letahl commented 5 years ago

bw_plex seems to be working properly, as it finds the correct time for the theme:

Found tv.show.sXXeXX theme start 01:08, theme end 01:26, ffmpeg_end 06:55 progress 00:09 best_time 01:26 credits_start 00:00 credits_end 00:00

However, when it comes to connecting to the device, it comes up with an error and doesn't seek properly. I assume this is because the Chromecast isn't supported. bw_plex is dockerized and the command used to run it is "bw_plex watch".

Relevant excerpts from log (timestamps removed):

INFO :: plex.py:760 :: Called client_action with 86.16925170068028 01:26 56 None
INFO :: plex.py:795 :: client Chromecast 73.0
INFO :: plex.py:814 :: wqlscy4rwfqsx6sbvvqbqh5n dfbqe5wv9m6exq57xum22f5o
INFO :: plex.py:814 :: wqlscy4rwfqsx6sbvvqbqh5n dfbqe5wv9m6exq57xum22f5o
INFO :: plex.py:814 :: 1cw2t2k47d4ph7sf3ojdjv4q dfbqe5wv9m6exq57xum22f5o
INFO :: plex.py:814 :: 988t0m49tuukydsmrs7vm909 dfbqe5wv9m6exq57xum22f5o
INFO :: plex.py:814 :: t92k0xgudrofs09l4777md0m dfbqe5wv9m6exq57xum22f5o
DEBUG :: plex.py:823 :: We couldnt match the client. Trying a hail marry.
INFO :: plex.py:828 :: Connectiong to Chromecast
ERROR :: plex.py:48 :: There was an exception in client_action

Traceback (most recent call last):
  File "/app/bw_plex/bw_plex/plex.py", line 43, in inner
    return func(*args)
  File "/app/bw_plex/bw_plex/plex.py", line 829, in client_action
    correct_client.connect()
  File "/usr/local/lib/python3.6/dist-packages/plexapi/client.py", line 91, in connect
    data = self.query(self.key, timeout=timeout)
  File "/usr/local/lib/python3.6/dist-packages/plexapi/client.py", line 155, in query
    url = self.url(path)
  File "/usr/local/lib/python3.6/dist-packages/plexapi/client.py", line 201, in url
    raise BadRequest('PlexClient object missing baseurl.')
plexapi.exceptions.BadRequest: PlexClient object missing baseurl.

Similarly, when trying to watch directly on an Android device, the relevant log files are as follows (timestamps removed):

ERROR :: plex.py:831 :: Cant connect to Pixel 2 XL

Traceback (most recent call last):

  File "/usr/local/lib/python3.6/dist-packages/urllib3/connection.py", line 159, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/usr/local/lib/python3.6/dist-packages/urllib3/util/connection.py", line 80, in create_connection
    raise err
  File "/usr/local/lib/python3.6/dist-packages/urllib3/util/connection.py", line 70, in create_connection
    sock.connect(sa)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/usr/local/lib/python3.6/dist-packages/urllib3/connection.py", line 181, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.6/dist-packages/urllib3/connection.py", line 164, in _new_conn
    (self.host, self.timeout))
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPConnection object at 0x7fdea068d978>, 'Connection to 192.168.1.181 timed out. (connect timeout=30)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/dist-packages/urllib3/util/retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.1.181', port=32500): Max retries exceeded with url: /resources (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7fdea068d978>, 'Connection to 192.168.1.181 timed out. (connect timeout=30)'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/bw_plex/bw_plex/plex.py", line 829, in client_action
    correct_client.connect()
  File "/usr/local/lib/python3.6/dist-packages/plexapi/client.py", line 91, in connect
    data = self.query(self.key, timeout=timeout)
  File "/usr/local/lib/python3.6/dist-packages/plexapi/client.py", line 160, in query
    response = method(url, headers=headers, timeout=timeout, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 504, in send
    raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPConnectionPool(host='192.168.1.181', port=32500): Max retries exceeded with url: /resources (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7fdea068d978>, 'Connection to 192.168.1.181 timed out. (connect timeout=30)'))
Hellowlol commented 5 years ago

Chromecast dont supported by plexapi, so that will not work. (I might add support later, i dont have chromecast)

As for the other traceback. I assume 192.168.1.181 is your device not the server? The strange part is that I can’t seems to find the matching machineid. So we try the hailmarry where the address isn’t listed in the xml response (that’s why you get error about missing _baseurl) I can try to catch that and retry connecting to the server. On a side note: have you enabled advertise as player in your device? (Dunno if it’s required for Android)

Letahl commented 5 years ago

Here is some relevant content regarding casting to chromecast with PlexAPI, should you decide to add support:

https://forum.xda-developers.com/android-tv/chromecast/plex-python-chromecast-t3520651

Also, 192.168.1.181 is the device. What does the machineid reference? I have enabled advertise as player on my Android.

Hellowlol commented 5 years ago

It don’t really do anything. But it’s a way to check that we are trying to control the correct client. The strange part is that according to plex your client isn’t connected to the same network. (Ofc it is but it should be listed)

Hellowlol commented 5 years ago

What docker are you using?

Letahl commented 5 years ago

Strange, it is connected to the same local network, and that's how it behaves in Plex. I'm using your latest docker image.

Hellowlol commented 5 years ago

Oh, I’m sorry, I was referring to your plex image

Letahl commented 5 years ago

Plex is installed natively (official Plex) and is not dockerized. Should bw_plex's docker image utilize the host network?

Hellowlol commented 5 years ago

That isn’t needed as far as I know. I’ll try to look into it, but dealing with the clients can be hit and miss. I add Chapter support so the user can manually skip intros if the clients supports chapters

Letahl commented 5 years ago

Don't believe Plex for Android supports chapters. If there's anything I can do on my end to assist in fixing the Android client, let me know. bw_plex works for the Xbox One app, so its not an issue with my installation. Chromecast functionality is my most desired feature for my use case, however.

UnR34L commented 5 years ago

Having the same issue with a Samsung Smart TV, works fine in chrome.

Hellowlol commented 5 years ago

I didn’t expect it too work on Samsung. I have a older tv and the client seems to be a dlna client.

UnR34L commented 5 years ago

I didn’t expect it too work on Samsung. I have a older tv and the client seems to be a dlna client.

I had a quick mess around with the plexapi last year and I got it to control the TV, so I don't see why it wouldn't work.

The ideal client for this would be TVs, it worked for chrome but if your at the computer its easy to click around and skip the intro, its more annoying to do on TV/Chromecast.

Great project btw, wish I had the knowhow to help.

Hellowlol commented 5 years ago

Open a new issue and post your log? This issue is because the client is chromecast (not supported by plexapi)