mza921 / Plex-Auto-Collections

Python 3 script to automatically update Plex collections based off a configuration file
310 stars 27 forks source link

Very frequent crashing #175

Open LeendertPlas opened 3 years ago

LeendertPlas commented 3 years ago

Most of the time when i run this script, it crashes during the processing phase and gives the following error:

| Version 2.8.2
| Locating config...
| Using C:\Plex\Plex-Auto-Collections-master\config\config.yml as config
|===================================================================================================|
| Connecting to Plex...
| Plex Connection Successful
|===================================================================================================|
| Connecting to TMDb...
| TMDb Connection Successful
|===================================================================================================|
| Connecting to tautulli...
| tautulli Connection Successful
|===================================================================================================|
| Connecting to Trakt...
| Trakt Connection Successful
|===================================================================================================|
| Connecting to Radarr...
| Radarr Connection Successful
|===================================================================================================|
| image_server attribute not found
|===================================================================================================|
|
| Mapping Plex Movies
| Cache | ! | plex://movie/5d9f3c8ae4fc29001eb6f365          | Unable to map TMDb/IMDb ID for Bill Burr: I'm Sorry You Feel That Way
| Cache | ! | plex://movie/5d7768378a7581001f12d9e2          | Unable to map TMDb/IMDb ID for Blow Out
| Processing: 966/6282 The Breadwinner
Traceback (most recent call last):
  File "C:\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "C:\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 426, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "C:\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Python39-32\lib\http\client.py", line 1347, in getresponse
    response.begin()
  File "C:\Python39-32\lib\http\client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "C:\Python39-32\lib\http\client.py", line 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "C:\Python39-32\lib\socket.py", line 704, in readinto
    return self._sock.recv_into(b)
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python39-32\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "C:\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 726, in urlopen
    retries = retries.increment(
  File "C:\Python39-32\lib\site-packages\urllib3\util\retry.py", line 403, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Python39-32\lib\site-packages\urllib3\packages\six.py", line 734, in reraise
    raise value.with_traceback(tb)
  File "C:\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "C:\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 426, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "C:\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Python39-32\lib\http\client.py", line 1347, in getresponse
    response.begin()
  File "C:\Python39-32\lib\http\client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "C:\Python39-32\lib\http\client.py", line 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "C:\Python39-32\lib\socket.py", line 704, in readinto
    return self._sock.recv_into(b)
urllib3.exceptions.ProtocolError: ('Connection aborted.', TimeoutError(10060, 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond', None, 10060, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Plex\Plex-Auto-Collections-master\app\plex_auto_collections.py", line 1026, in <module>
    update_from_config(config_path, plex, True, args.no_meta, args.no_images)
  File "C:\Plex\Plex-Auto-Collections-master\app\plex_auto_collections.py", line 120, in update_from_config
    plex_map = get_map(config_path, plex)
  File "C:\Plex\Plex-Auto-Collections-master\app\plex_tools.py", line 125, in get_map
    key_id = imdb_tools.imdb_get_tmdb(config_path, check_id)
  File "C:\Plex\Plex-Auto-Collections-master\app\imdb_tools.py", line 86, in imdb_get_tmdb
    search = movie.external(external_id=imdb_id, external_source="imdb_id")['movie_results']
  File "C:\Python39-32\lib\site-packages\tmdbv3api\objs\movie.py", line 182, in external
    self._call(
  File "C:\Python39-32\lib\site-packages\tmdbv3api\tmdb.py", line 132, in _call
    req = self.cached_request(method, url, data)
  File "C:\Python39-32\lib\site-packages\tmdbv3api\tmdb.py", line 112, in cached_request
    return requests.request(method, url, data=data)
  File "C:\Python39-32\lib\site-packages\requests\api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python39-32\lib\site-packages\requests\sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Python39-32\lib\site-packages\requests\sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python39-32\lib\site-packages\requests\adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', TimeoutError(10060, 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond', None, 10060, None))

C:\Plex\Plex-Auto-Collections-master>`

I also find this strange because in a different issue 141, this step is not present and it skips to creating the collections.

`

LeendertPlas commented 3 years ago

When it finally does work, i get a different error.

| Trakt Trending Collection | + | Star Wars: The Rise of Skywalker
Traceback (most recent call last):
  File "C:\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 426, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "C:\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Python39-32\lib\http\client.py", line 1347, in getresponse
    response.begin()
  File "C:\Python39-32\lib\http\client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "C:\Python39-32\lib\http\client.py", line 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "C:\Python39-32\lib\socket.py", line 704, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python39-32\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "C:\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 726, in urlopen
    retries = retries.increment(
  File "C:\Python39-32\lib\site-packages\urllib3\util\retry.py", line 403, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Python39-32\lib\site-packages\urllib3\packages\six.py", line 735, in reraise
    raise value
  File "C:\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "C:\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 428, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "C:\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 335, in _raise_timeout
    raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='localhost', port=32400): Read timed out. (read timeout=30)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Plex\Plex-Auto-Collections-master\app\plex_auto_collections.py", line 1035, in <module>
    update_from_config(config_path, plex, False)
  File "C:\Plex\Plex-Auto-Collections-master\app\plex_auto_collections.py", line 668, in update_from_config
    missing, map = add_to_collection(config_path, plex, m, v, c, plex_map, map, filters)
  File "C:\Plex\Plex-Auto-Collections-master\app\plex_tools.py", line 347, in add_to_collection
    current_item.addCollection(c)
  File "C:\Python39-32\lib\site-packages\plexapi\base.py", line 389, in addCollection
    self._edit_tags('collection', collections)
  File "C:\Python39-32\lib\site-packages\plexapi\base.py", line 381, in _edit_tags
    self.refresh()
  File "C:\Python39-32\lib\site-packages\plexapi\base.py", line 427, in refresh
    self._server.query(key, method=self._server._session.put)
  File "C:\Python39-32\lib\site-packages\plexapi\server.py", line 440, in query
    response = method(url, headers=headers, timeout=timeout, **kwargs)
  File "C:\Python39-32\lib\site-packages\requests\sessions.py", line 590, in put
    return self.request('PUT', url, data=data, **kwargs)
  File "C:\Python39-32\lib\site-packages\requests\sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Python39-32\lib\site-packages\requests\sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python39-32\lib\site-packages\requests\adapters.py", line 529, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='localhost', port=32400): Read timed out. (read timeout=30)

C:\Plex\Plex-Auto-Collections-master>
burkasaurusrex commented 3 years ago

For your Plex config, try using 127.0.0.1 or your local IP address like 192.168.1.xxx instead of localhost

LeendertPlas commented 3 years ago
| 00s Movies Collection | + | Pieces of April
Traceback (most recent call last):
  File "C:\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 426, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "C:\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Python39-32\lib\http\client.py", line 1347, in getresponse
    response.begin()
  File "C:\Python39-32\lib\http\client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "C:\Python39-32\lib\http\client.py", line 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "C:\Python39-32\lib\socket.py", line 704, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python39-32\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "C:\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 726, in urlopen
    retries = retries.increment(
  File "C:\Python39-32\lib\site-packages\urllib3\util\retry.py", line 403, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Python39-32\lib\site-packages\urllib3\packages\six.py", line 735, in reraise
    raise value
  File "C:\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "C:\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 428, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "C:\Python39-32\lib\site-packages\urllib3\connectionpool.py", line 335, in _raise_timeout
    raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='192.168.2.11', port=32400): Read timed out. (read timeout=30)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Plex\Plex-Auto-Collections-master\app\plex_auto_collections.py", line 1026, in <module>
    update_from_config(config_path, plex, True, args.no_meta, args.no_images)
  File "C:\Plex\Plex-Auto-Collections-master\app\plex_auto_collections.py", line 668, in update_from_config
    missing, map = add_to_collection(config_path, plex, m, v, c, plex_map, map, filters)
  File "C:\Plex\Plex-Auto-Collections-master\app\plex_tools.py", line 347, in add_to_collection
    current_item.addCollection(c)
  File "C:\Python39-32\lib\site-packages\plexapi\base.py", line 389, in addCollection
    self._edit_tags('collection', collections)
  File "C:\Python39-32\lib\site-packages\plexapi\base.py", line 381, in _edit_tags
    self.refresh()
  File "C:\Python39-32\lib\site-packages\plexapi\base.py", line 427, in refresh
    self._server.query(key, method=self._server._session.put)
  File "C:\Python39-32\lib\site-packages\plexapi\server.py", line 440, in query
    response = method(url, headers=headers, timeout=timeout, **kwargs)
  File "C:\Python39-32\lib\site-packages\requests\sessions.py", line 590, in put
    return self.request('PUT', url, data=data, **kwargs)
  File "C:\Python39-32\lib\site-packages\requests\sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Python39-32\lib\site-packages\requests\sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python39-32\lib\site-packages\requests\adapters.py", line 529, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='192.168.2.11', port=32400): Read timed out. (read timeout=30)

C:\Plex\Plex-Auto-Collections-master>

I did that, but it only partially solved the problem. I have not encountered error 10060 but i still get the timeout error often when adding collections.

I think this occurs either due to the amount of movies, around 6000, or if plex scans another movie during the creation of collections. I also tried to change the timeout time but i couldn't find it anywhere. An earlier issue mentioned this, but the solution is for docker instead of windows. The config location is also not the same as specified in the manual

burkasaurusrex commented 3 years ago

Ok, it looks like both errors are caused by slow responses from Plex. Probably makes sense to extend the timeout. What's your current set up?

LeendertPlas commented 3 years ago

Yes i want to change that, but i couldn't find out how.

I'm using windows 10, plex, radarr and python 3.9.32 all running on the same computer.