luigi311 / JellyPlex-Watched

Sync watched between jellyfin and plex locally
GNU General Public License v3.0
366 stars 19 forks source link

[BUG] Fails to sync watched with many users #145

Closed ampersandru closed 5 months ago

ampersandru commented 5 months ago

Trying to sync user watched status for all my users. I initially just synced myself and JellyPlex synced all watched successfully to Jellyfin without any issues. Then I used Plex2Jellyfin to just sync my users (only migrate_users.py) to Jellyfin. After that was completed, I re-ran JellyPlex and after Jellyplex generated the watched status for all my users, it gives these errors. FYI, I am just using a reverse proxy for my plex server but did set the env "PLEX_BASEURL"

 Server 1: Plex: 1.40.0.7775-456fbaf97
Server 2: Jellyfin: 10.8.13
...
Plex: Generating watched for xxxxyyyy in library Movies
Plex: Generating watched for xxxxyyyy in library TV Shows
[ERROR]: Plex: Failed to get watched, Error: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
[ERROR]: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
[ERROR]: Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 790, in urlopen
    response = self._make_request(
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 536, in _make_request
    response = conn.getresponse()
               ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 461, in getresponse
    httplib_response = super().getresponse()
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/http/client.py", line 1386, in getresponse
    response.begin()
  File "/usr/local/lib/python3.11/http/client.py", line 325, in begin
    version, status, reason = self._read_status()
                              ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/http/client.py", line 294, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 844, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/retry.py", line 470, in increment
    raise reraise(type(error), error, _stacktrace)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/util.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 790, in urlopen
    response = self._make_request(
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 536, in _make_request
    response = conn.getresponse()
               ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 461, in getresponse
    httplib_response = super().getresponse()
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/http/client.py", line 1386, in getresponse
    response.begin()
  File "/usr/local/lib/python3.11/http/client.py", line 325, in begin
    version, status, reason = self._read_status()
                              ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/http/client.py", line 294, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/src/plex.py", line 490, in get_watched
    libraries = user_plex.library.sections()
                ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/functools.py", line 1001, in __get__
    val = self.func(instance)
          ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plexapi/server.py", line 179, in library
    data = self.query(Library.key)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plexapi/server.py", line 759, in query
    response = method(url, headers=headers, timeout=timeout, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 501, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/src/main.py", line 394, in main
    main_loop()
  File "/app/src/main.py", line 326, in main_loop
    server_1_watched = get_server_watched(
                       ^^^^^^^^^^^^^^^^^^^
  File "/app/src/main.py", line 176, in get_server_watched
    return server_connection[1].get_watched(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/plex.py", line 522, in get_watched
    raise Exception(e)
Exception: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

Retrying in 3600.0
ampersandru commented 5 months ago

also noticed that jellyplex wants to sync plex user's full names if they have added it (i.e., it wants to sync their full name "John Smith" instead of their actual username "johnsmith123")

ampersandru commented 5 months ago

I figured it out, it definitely was the reverse proxy, likely cloudflare flagging it as spam. Switched it to local IP and it synced fine. It still does want to sync first and last name though

luigi311 commented 5 months ago

Do a docker pull that should be fixed now

ampersandru commented 5 months ago

Do a docker pull that should be fixed now

looks like that fixed it, thanks for the quick response!