mza921 / Plex-Auto-Collections

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

Testing and Trying to get this working #140

Closed ramair02 closed 3 years ago

ramair02 commented 3 years ago

This is as far as I'm getting:

B:\Tautulli Scripts\Plex-Auto-Collections-master\app>python plex_auto_collections.py

|===================================================================================================|
|     ___  _               _         _           ___       _  _           _    _                    |
|    | _ \| | ___ __ __   /_\  _  _ | |_  ___   / __| ___ | || | ___  __ | |_ (_) ___  _ _   ___    |
|    |  _/| |/ -_)\ \ /  / _ \| || ||  _|/ _ \ | (__ / _ \| || |/ -_)/ _||  _|| |/ _ \| ' \ (_-<    |
|    |_|  |_|\___|/_\_\ /_/ \_\\_,_| \__|\___/  \___|\___/|_||_|\___|\__| \__||_|\___/|_||_|/__/    |
|                                                                                                   |
|===================================================================================================|
| Version 2.6.0
| Locating config...
| Using B:\Tautulli Scripts\Plex-Auto-Collections-master\config\config.yml as config
|===================================================================================================|
| Connecting to Plex...
| Plex Connection Successful
|===================================================================================================|
| Connecting to TMDb...
| TMDb Connection Successful
|===================================================================================================|
| Connecting to tautulli...
| Config Error: Invalid url
| tautulli connection failed
|===================================================================================================|
| Connecting to Trakt...
| Trakt Connection Successful
|===================================================================================================|
| Connecting to Radarr...
| Radarr Connection Successful
|===================================================================================================|
| Locating Image Server...
| Posters Directory: ../config/posters not found
| Backgrounds Directory: ../config/backgrounds not found
| Using B:\Tautulli Scripts\Plex-Auto-Collections-master\config\images for Images Directory
|===================================================================================================|
|
| Update Collections from Config? (y/n): y
|
|===================================================================================================|
|
| Running collection update press Ctrl+C to abort at anytime
|
|===================================================================================================|
|
| Updating collection: Jurassic Park...
| Sync Mode: append
| Config Warning: https://www.themoviedb.org/collection/328 can be replaced with 328
| Processing tmdb_collection: (328) Jurassic Park Collection
Traceback (most recent call last):
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\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:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1347, in getresponse
    response.begin()
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\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:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 726, in urlopen
    retries = retries.increment(
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\retry.py", line 410, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\packages\six.py", line 735, in reraise
    raise value
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 428, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\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 "B:\Tautulli Scripts\Plex-Auto-Collections-master\app\plex_auto_collections.py", line 995, in <module>
    update_from_config(config_path, plex, False)
  File "B:\Tautulli Scripts\Plex-Auto-Collections-master\app\plex_auto_collections.py", line 615, in update_from_config
    missing, map = add_to_collection(config_path, plex, m, v, c, map, filters)
  File "B:\Tautulli Scripts\Plex-Auto-Collections-master\app\plex_tools.py", line 151, in add_to_collection
    movies, missing = imdb_tools.tmdb_get_movies(config_path, plex, value, method)
  File "B:\Tautulli Scripts\Plex-Auto-Collections-master\app\imdb_tools.py", line 219, in tmdb_get_movies
    p_movies = plex.Library.all()
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\site-packages\plexapi\library.py", line 450, in all
    return self.fetchItems(key, **kwargs)
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\site-packages\plexapi\library.py", line 376, in fetchItems
    data = self._server.query(ekey, params=url_kw)
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\site-packages\plexapi\server.py", line 440, in query
    response = method(url, headers=headers, timeout=timeout, **kwargs)
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 543, in get
    return self.request('GET', url, **kwargs)
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\jonat\AppData\Local\Programs\Python\Python39\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)

B:\Tautulli Scripts\Plex-Auto-Collections-master\app>

Here is my config. I haven't made many changes yet, since I want to get it working first:

collections:
  Jurassic Park:
    tmdb_collection: https://www.themoviedb.org/collection/328
    tmdb_summary: 328
  1080p Documentaries:
    genres: Documentary
    collection_mode: show_items
    filters:
      video_resolution: 1080
    summary: A collection of 1080p Documentaries
  IMDb Top 250:
    imdb_list: https://www.imdb.com/search/title/?groups=top_250&count=25
    sync_mode: sync
    collection_mode: show_items
  Robin Williams:
    tvdb_actor: 2157
    collection_mode: show_items
  Dave Chappelle:
    actors: Dave Chappelle
    tmdb_biography: 4169
    tmdb_profile: 4169
    collection_mode: show_items
  Marvel Cinematic Universe:
    trakt_list: https://trakt.tv/users/movistapp/lists/marvel
    collection_mode: show_items
  Trakt Trending:
    trakt_trending: 30
    sync_mode: sync
  90s Comedies:
    plex_search:
      year: [1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999]
      genre: Comedy
    summary: A collection of 90s Comedy movies
  Most Popular Movies (30 Days):
    sync_mode: sync
    collection_mode: show_items
    tautulli:
      list_type: popular
      list_days: 30
      list_size: 10
plex:
  library: Movies
  library_type: movie
  token: xxxxxxxxxxxxxxxxxxxx
  url: http://localhost:32400/
  sync_mode: append
radarr:
  url: http://localhost:38085/
  token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  quality_profile_id: 4
  root_folder_path: /mnt/user/PlexMedia/movies
  add_movie: false
  search_movie: false
  version: v3
tmdb:
  apikey: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  language: en
tautulli:
  url: http://localhost:8181/
  apikey: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
trakt:
  client_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  client_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  auto_refresh_token: false
  # Below is filled in automatically when the script is run
  authorization:
    access_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    token_type: Bearer
    expires_in: 7889237
    refresh_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    scope: public
    created_at: 1607374600
image_server:
  poster_directory: ../config/posters
  background_directory: ../config/backgrounds
  image_directory: ../config/images
xFlawless11x commented 3 years ago

My recommendation here is: re-download the latest package (2.8.1) - copy your config.yml into that new download.

In your config.yml, start simple with just one collection - here's my jurassic park one that works just fine.

Jurassic Park: imdb_list: https://www.imdb.com/list/ls068935685/ sync_mode: sync collection_mode: show_items

burkasaurusrex commented 3 years ago

It looks like the connection to Plex is timing out - I'd try the following under the plex key in the config:

mza921 commented 3 years ago

Another suggestion, especially if working with a large Plex library, is to increase the Plex API timeout. See here. If using docker, you can pass something like -e PLEXAPI_PLEXAPI_TIMEOUT=60 or larger.

burkasaurusrex commented 3 years ago

Another suggestion, especially if working with a large Plex library, is to increase the Plex API timeout. See here. If using docker, you can pass something like -e PLEXAPI_PLEXAPI_TIMEOUT=60 or larger.

Ah yea, forgot about this. We should consider catching any timeout errors and suggesting this fix in the script output. Or at least including in the documentation.

burkasaurusrex commented 3 years ago

Potential duplicate of #74

ramair02 commented 3 years ago

It works! Thank you for the suggestions. I had to change my Plex URL and Tautulli URL to the PC IP address. I didn't change the timeout, but I'll keep that in mind should other issues arise. Thanks again for the help. Now I have a lot of configuring to do to manage all of my Collections!

ramair02 commented 3 years ago

Spent a lot of time configuring Collections for a bunch of Actors, Directors, Writers. Also added Decades Collections, a few Studios, a Christmas Collection, etc.

Sharing a config template in case anyone else wants a similar setup. Would be cool if there was a place for users to share their configs since a lot of manual labor goes into these and it could save people a bunch of time!

config-ramair02.yml.template.zip

tehniemer commented 3 years ago

Spent a lot of time configuring Collections for a bunch of Actors, Directors, Writers. Also added Decades Collections, a few Studios, a Christmas Collection, etc.

Sharing a config template in case anyone else wants a similar setup. Would be cool if there was a place for users to share their configs since a lot of manual labor goes into these and it could save people a bunch of time!

config-ramair02.yml.template.zip

This is a great idea, now that GitHub supports discussions maybe this would be a good first topic if @mza921 would like to open those up.

LeendertPlas commented 3 years ago

Did anyone find out where the config file is on windows for PlexApi? it doesn't seem to be located in the location according to the manual

mza921 commented 3 years ago

Did anyone find out where the config file is on windows for PlexApi? it doesn't seem to be located in the location according to the manual

Try running python, then

import plexapi
help(plexapi)

It should be the value of CONFIG_PATH.

LeendertPlas commented 3 years ago

Thank you, i found the config_path as you said "CONFIG_PATH = r'C:\Users\Plex Media/.config/plexapi/config.ini'", but it doesn't seem to exist. I can't cd to it and there is no hidden folder named .config in that folder.

Is there a way to set it from the terminal?

i can do PLEXAPI_TIMEMOUT=120 or PLEXAPI_CONFIG_PATH="X" without an error but if i do help(plexapi) again the values are the default values again. So it doesn't seem to have changed anything.

LeendertPlas commented 3 years ago

i found a solution, you need to go to your python version/Lib/sitepackages/plexapi. Then you create a config.ini file with for example

[plexapi] container_size = 500 TIMEOUT = 300

and then in config.py you add a line under def init(self,path):) path = "X\config.ini"