Sign inSign up

aljohn92/plex-auto-collections

By aljohn92

•Updated almost 6 years ago

Image
0

168

aljohn92/plex-auto-collections repository overview

⁠Plex Auto Collections

⁠Version 2.8.0

Plex Auto Collections is a Python 3 script that works off a configuration file to create/update Plex collections. Collection management with this tool can be automated in a varying degree of customizability. Supports IMDB, TMDb, and Trakt lists as well as built in Plex Searches using actors, genres, year, studio and more.

https://i.imgur.com/iHAYFIZ.png

⁠Table of Contents

  1. Usage⁠
  2. Configuration⁠
  3. Acknowledgements⁠

⁠Usage

This script can be used as an interactive Python shell script as well as a headless, configuration-driven script.

The interactive shell script has some limited abilities including the ability to add new collections based off searches, delete collections, search for collections and manage existing collections. The bulk of the feature-set is focused on configuration-driven updates.

⁠Local Installation

Some limited testing has been done only on Python 3.7 and 3.8 on Linux and Windows. Dependencies must be installed by running:

pip install -r requirements.txt

If there are issues installing dependencies try:

pip install -r requirements.txt --ignore-installed

To run the script in an interactive terminal run:

python plex_auto_collections.py

A config.yml file is required to run the script. The script checks for a config.yml file alongside plex_auto_collections.py as well as in config/config.yml. If desired, a different configuration file can be specified with -c <path_to_config> or --config-path <path_to_config>. This could be useful for creating collections against different libraries, such as a Movie and TV library (in this case, be sure to update the library_type in the configuration file).

python plex_auto_collections.py --config-path <path_to_config>

If you would like to run the script without any user interaction (e.g. to schedule the script to run on a schedule) the script can be launched with -u or --update:

python plex_auto_collections.py --update

If you would like the -u or --update option to update without updating metadata you can add -nm or --no_meta along with -u or --update:

python plex_auto_collections.py --update --no_meta

If you would like the -u or --update option to update without updating images you can add -ni or --no_images along with -u or --update:

python plex_auto_collections.py --update --no_images

Example command if you only want the collection to update without constantly updating metadata and images that don't change much

python plex_auto_collections.py --update --no_meta --no_images

⁠Docker

A simple Dockerfile is available in this repo if you'd like to build it yourself. The official build is also available from dockerhub here: https://hub.docker.com/r/mza921/plex-auto-collections⁠

The docker implementation today is limited but will improve over time. To use, try the following:

docker run --rm -v '/mnt/user/plex-auto-collections/':'/config':'rw' 'mza921/plex-auto-collections' -u

The -v '/mnt/user/plex-auto-collections/':'/config' mounts a persistent volume to store your config file. Today, the docker image defaults to running the config named config.yml in your persistent volume (eventually, the docker will support an environment variable to change the config path).

Lastly, you may need to run the docker with -it and without -u in order to interact with the script. For example, if you'd like to use Trakt lists, you need to go through the OAuth flow and interact with the script at first-run. After that, you should be able to run it without the -it flag.

⁠Configuration

The script allows utilizes a YAML config file to create collections in Plex. This is great for a few reasons:

  • Setting metadata manually in Plex is cumbersome. Having a config file allows template to be reused, backed-up, transferred, etc.
  • Plex often loses manually set metadata. Having a config file fixes metadata creep.
  • Collections change often. Having a config file pointing to dynamic data keeps collections fresh.

There are currently six YAML mappings that can be set:

You can find a template config file in config/config.yml.template⁠

⁠Collections

Each collection is defined by the mapping name which becomes the name of the Plex collection. Additionally, there are many different attributes you can set for each collection:

⁠List Type (Collection Attribute)

The only required attribute for each collection is the list type. There are many different list types to choose from:

Note that most list types supports multiple lists, with the following exceptions:

  • TMDb Popular
  • TMDb Trending
  • TMDb Top Rated
  • TMDb Now Playing
  • TMDb Discover
  • Trakt Trending Lists
  • Trakt Watchlist
  • Tautulli Lists
⁠Plex Search (List Type)
⁠Works with Movie and TV Show Libraries

You can create a collection based on the Plex search feature using the plex_search attribute. The search will return any movie/show that matches at least one term from each search option. You can run multiple searches. The search options are listed below.

Search OptionDescriptionMovie
Libraries
Show
Libraries
actorGets every movie with the specified actor:heavy_check_mark::x:
tmdb_actorGets every movie with the specified actor as well as the added TMDb metadata⁠:heavy_check_mark::x:
countryGets every movie with the specified country:heavy_check_mark::x:
decadeGets every movie from the specified year + the 9 that follow i.e. 1990 will get you 1990-1999:heavy_check_mark::x:
directorGets every movie with the specified director:heavy_check_mark::x:
tmdb_directorGets every movie with the specified director as well as the added TMDb metadata⁠:heavy_check_mark::x:
genreGets every movie/show with the specified genre:heavy_check_mark::heavy_check_mark:
studioGets every movie/show with the specified studio:heavy_check_mark::heavy_check_mark:
yearGets every movie/show with the specified year (Put a - between two years for a range i.e. year: 1990-1999 or end with NOW to go till current i.e. year: 2000-NOW):heavy_check_mark::heavy_check_mark:
writerGets every movie with the specified writer:heavy_check_mark::x:
tmdb_writerGets every movie with the specified writer as well as the added TMDb metadata⁠:heavy_check_mark::x:

Here's some high-level ideas:

collections:
  Documentaries:
    plex_search:
      genre: Documentary
collections:
  Dave Chappelle Comedy:
    plex_search:
      actor: Dave Chappelle
      genre: Comedy
collections:
  Pixar:
    plex_search:
      studio: Pixar
collections:
  90s Movies:
    plex_search:
      year:
        - 1990
        - 1991
        - 1992
        - 1993
        - 1994
        - 1995
        - 1996
        - 1997
        - 1998
        - 1999
collections:
  90s Movies:
    plex_search:
      year: 1990-1999
collections:
  2010+ Movies:
    plex_search:
      year: 2010-NOW
collections:
  90s Movies:
    plex_search:
      decade: 1990

Note if you only want to search using a single attribute you can do so without plex_search.

collections:
  90s Movies:
    year: 1990-1999

Notes:

  • You can only use each search option once per plex_search but you can give the search multiple values.
  • If you want to restrict the search by multiples of the same attribute (i.e. You want every movie that is a Romance and Comedy) try using filters⁠.
⁠Plex Collection (List Type)
⁠Works with Movie and TV Show Libraries

You can create Collections based on collections already in Plex

collections:
  Dinosaurs:
    plex_collection: Jurassic Park

Note if you want to add multiple collections you have to use a list. Comma separated values will not work.

collections:
  Dinosaurs:
    plex_collection:
      - Jurassic Park
      - The Land Before Time
⁠TMDb Collection (List Type)
⁠Works with Movie Libraries

The Movie Database (TMDb) strives to group movies into logical collections. This script can easily leverage that data. You can use the full url or just type in the TMDb ID for the collection:

collections:
  Jurassic Park:
    tmdb_collection: https://www.themoviedb.org/collection/328
collections:
  Jurassic Park:
    tmdb_collection: 328
collections:
  Alien (Past & Present):
    tmdb_collection:
      - https://www.themoviedb.org/collection/8091
      - 135416

Alternatively you can specify which tmdb_collection⁠, tmdb_summary⁠, tmdb_poster⁠, and tmdb_background⁠ all at once by using tmdb_id and setting it to the collections page ID or URL:

collections:
  Jurassic Park:
    tmdb_id: 328
collections:
  Alien (Past & Present):
    tmdb_id: 8091, 135416
  Anaconda:
    tmdb_id: 105995, 336560

Notes:

  • The tmdb_id can be either from a collection or an individual movie
  • You can specify more than one tmdb_id but it will pull the summary, poster, and background from only the first one.
  • Local posters/backgrounds are loaded over tmdb_poster/tmdb_background if they exist unless tmdb_poster/tmdb_background is also specified
  • tmdb_summary will load unless summary,tmdb_summary, or tmdb_biography is also specified
⁠TMDb People (List Type)

Similarly to tmdb_id, tmdb_actor, tmdb_director, tmdb_writer can specify tmdb_biography⁠ and tmdb_profile⁠ of the person's TMDb page ID or URL as well as search Plex using their respective Plex Search⁠ all with one attribute.

⁠TMDb Actor (List Type)
⁠Works with Movie and TV Show Libraries
collections:
  Robin Williams:
    tmdb_actor: 2157
collections:
  Robin Williams:
    tmdb_actor: https://www.themoviedb.org/person/2157-robin-williams
⁠TMDb Director (List Type)
⁠Works with Movie Libraries
collections:
  Steven Spielberg:
    tmdb_director: 488
collections:
  Steven Spielberg:
    tmdb_director: https://www.themoviedb.org/person/488-steven-spielberg
⁠TMDb Writer (List Type)
⁠Works with Movie Libraries
collections:
  Quentin Tarantino:
    tmdb_writer: 138
collections:
  Quentin Tarantino:
    tmdb_writer: https://www.themoviedb.org/person/138-quentin-tarantino

Notes:

  • You can specify more than one tmdb_actor, tmdb_director, or tmdb_writer but it will pull the summary and poster from only the first one.
  • Local posters are loaded over tmdb_profile if they exist unless tmdb_profile is also specified
  • tmdb_biography will load unless summary,tmdb_summary, or tmdb_biography is also specified
⁠TMDb Company (List Type)
⁠Works with Movie and TV Show Libraries

You can use a TMDb Company to build a collection based on all it's movies/shows by using tmdb_company. You can use the full url or just type in the TMDb ID for the collection:

collections:
  Studio Ghibli:
    tmdb_company: 10342
collections:
  Studio Ghibli:
    tmdb_company: https://www.themoviedb.org/company/10342
⁠TMDb Network (List Type)
⁠Works with Show Libraries

Similarly to using a TMDb Company, you can also use a TMDb Network to build a collection based on all it's shows by using tmdb_network. You can use the full url or just type in the TMDb ID for the collection:

collections:
  CBS:
    tmdb_network: 16
collections:
  CBS:
    tmdb_network: https://www.themoviedb.org/network/16
⁠Works with Movie and TV Show Libraries

You can build a collection using TMDb's most popular movies/shows by using tmdb_popular. The tmdb_popular attribute only supports a single integer value. The sync_mode: sync option is recommended since the list is continuously updated.

collections:
  TMDb Popular:
    tmdb_popular: 30
    sync_mode: sync
⁠Works with Movie and TV Show Libraries

You can build a collection using TMDb's daily or weekly trending movies/shows by using tmdb_trending_daily or tmdb_trending_weekly. Both attributes only support a single integer value. The sync_mode: sync option is recommended since the lists are continuously updated.

collections:
  TMDb Daily Trending:
    tmdb_trending_daily: 30
    sync_mode: sync
collections:
  TMDb Weekly Trending:
    tmdb_trending_weekly: 30
    sync_mode: sync
⁠TMDb Top Rated (List Type)
⁠Works with Movie and TV Show Libraries

You can build a collection using TMDb's top rated movies/shows by using tmdb_top_rated. The tmdb_top_rated attribute only supports a single integer value. The sync_mode: sync option is recommended since the list is continuously updated.

collections:
  TMDb Top Rated:
    tmdb_top_rated: 30
    sync_mode: sync
⁠TMDb Now Playing (List Type)
⁠Works with Movie Libraries

You can build a collection using TMDb's release_type to get movies that are now in theaters by using tmdb_now_playing. The tmdb_now_playing attribute only supports a single integer value. The sync_mode: sync option is recommended since the list is continuously updated.

collections:
  TMDb Now Playing:
    tmdb_now_playing: 30
    sync_mode: sync
⁠TMDb Discover (List Type)
⁠Works with Movie and TV Show Libraries

You can use TMDb's discover engine⁠ to create a collection based on the search for movies/shows using all different sorts of parameters shown below. The parameters are directly from TMDb Movie Discover⁠ and TMDb TV Discover⁠

TypeDescription
StringAny number of alphanumeric characters
IntegerAny whole number greater then zero i.e. 2, 10, 50
NumberAny number greater then zero i.e. 2.5, 7.4, 9
BooleanMust be true or false
Date: MM/DD/YYYYDate that fits the specified format
Year: YYYYYear must be a 4 digit integer i.e. 1990
⁠Discover Movies
Movie ParametersDescriptionType
limitSpecify how many movies you want returned by the query. (default: 100)Integer
languageSpecify a language to query translatable fields with. (default: en-US)([a-z]{2})-([A-Z]{2})
regionSpecify a ISO 3166-1 code⁠ to filter release dates. Must be uppercase.^[A-Z]{2}$
sort_byChoose from one of the many available sort options. (default: popularity.desc)See sort options⁠ below
certification_countryUsed in conjunction with the certification parameter, use this to specify a country with a valid certification.String
certificationFilter results with a valid certification from the certification_country parameter.String
certification.lteFilter and only include movies that have a certification that is less than or equal to the specified value.String
certification.gteFilter and only include movies that have a certification that is greater than or equal to the specified value.String
include_adultA filter and include or exclude adult movies.Boolean
primary_release_yearA filter to limit the results to a specific primary release year.Year: YYYY
primary_release_date.gteFilter and only include movies that have a primary release date that is greater or equal to the specified value.Date: MM/DD/YYYY
primary_release_date.lteFilter and only include movies that have a primary release date that is less than or equal to the specified value.Date: MM/DD/YYYY
release_date.gteFilter and only include movies that have a release date (looking at all release dates) that is greater or equal to the specified value.Date: MM/DD/YYYY
release_date.lteFilter and only include movies that have a release date (looking at all release dates) that is less than or equal to the specified value.Date: MM/DD/YYYY
yearA filter to limit the results to a specific year (looking at all release dates).Year: YYYY
vote_count.gteFilter and only include movies that have a vote count that is greater or equal to the specified value.Integer
vote_count.lteFilter and only include movies that have a vote count that is less than or equal to the specified value.Integer
vote_average.gteFilter and only include movies that have a rating that is greater or equal to the specified value.Number
vote_average.lteFilter and only include movies that have a rating that is less than or equal to the specified value.Number
with_castA comma separated list of person ID's. Only include movies that have one of the ID's added as an actor.String
with_crewA comma separated list of person ID's. Only include movies that have one of the ID's added as a crew member.String
with_peopleA comma separated list of person ID's. Only include movies that have one of the ID's added as a either a actor or a crew member.String
with_companiesA comma separated list of production company ID's. Only include movies that have one of the ID's added as a production company.String
with_genresComma separated value of genre ids that you want to include in the results.String
without_genresComma separated value of genre ids that you want to exclude from the results.String
with_keywordsA comma separated list of keyword ID's. Only includes movies that have one of the ID's added as a keyword.String
without_keywordsExclude items with certain keywords. You can comma and pipe separate these values to create an 'AND' or 'OR' logic.String
with_runtime.gteFilter and only include movies that have a runtime that is greater or equal to a value.Integer
with_runtime.lteFilter and only include movies that have a runtime that is less than or equal to a value.Integer
with_original_languageSpecify an ISO 639-1 string to filter results by their original language value.String
⁠Discover Shows
Show ParametersDescriptionType
limitSpecify how many movies you want returned by the query. (default: 100)Integer
languageSpecify a language to query translatable fields with. (default: en-US)([a-z]{2})-([A-Z]{2})
sort_byChoose from one of the many available sort options. (default: popularity.desc)See sort options⁠ below
air_date.gteFilter and only include TV shows that have a air date (by looking at all episodes) that is greater or equal to the specified value.Date: MM/DD/YYYY
air_date.lteFilter and only include TV shows that have a air date (by looking at all episodes) that is less than or equal to the specified value.Date: MM/DD/YYYY
first_air_date.gteFilter and only include TV shows that have a original air date that is greater or equal to the specified value. Can be used in conjunction with the include_null_first_air_dates filter if you want to include items with no air date.Date: MM/DD/YYYY
first_air_date.lteFilter and only include TV shows that have a original air date that is less than or equal to the specified value. Can be used in conjunction with the include_null_first_air_dates filter if you want to include items with no air date.Date: MM/DD/YYYY
first_air_date_yearFilter and only include TV shows that have a original air date year that equal to the specified value. Can be used in conjunction with the include_null_first_air_dates filter if you want to include items w

Tag summary

Content type

Image

Digest

Size

54.2 MB

Last updated

almost 6 years ago

docker pull aljohn92/plex-auto-collections