diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..cf7a39f --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "pip" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "daily" diff --git a/Dockerfile b/Dockerfile index 89663ff..3098e7c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.8-slim +FROM python:3-slim VOLUME /config COPY . / RUN \ diff --git a/README.md b/README.md index 8e9ae8c..9626455 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Plex Auto Collections -##### Version 2.1.0 +##### Version 2.1.1 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 filters such as actors, genres, year, studio and more. ![https://i.imgur.com/iHAYFIZ.png](https://i.imgur.com/iHAYFIZ.png) diff --git a/app/imdb_tools.py b/app/imdb_tools.py index a6f42ee..81c2e7b 100644 --- a/app/imdb_tools.py +++ b/app/imdb_tools.py @@ -86,12 +86,25 @@ def imdb_get_movies(config_path, plex, data): return matched_imbd_movies, missing_imdb_movies -def tmdb_get_movies(config_path, plex, data, is_list=False): +def tmdb_parse_id(data): try: - tmdb_id = re.search('.*?(\\d+)', data) + tmdb_id = re.search('.*?(\\d+)', str(data)) # re.search requires a string tmdb_id = tmdb_id.group(1) + return tmdb_id except AttributeError: # Bad URL Provided - raise ValueError("| Config Error: TMDb: {} is invalid".format(data)) + raise ValueError("| Config Error: TMDb ID: {} is invalid it must be a number".format(data)) + +def tvdb_parse_id(data): + try: + tvdb_id = re.search('(\\d+)', str(data)) # re.search requires a string + tvdb_id = tvdb_id.group(1) + return tvdb_id + except AttributeError: + raise ValueError("| Config Error: TVDb ID: {} is invalid it must be a number".format(data)) + + +def tmdb_get_movies(config_path, plex, data, is_list=False): + tmdb_id = tmdb_parse_id(data) t_movs = [] t_movie = Movie() t_movie.api_key = config_tools.TMDB(config_path).apikey # Set TMDb api key for Movie @@ -212,11 +225,9 @@ def get_tvdb_id_from_tmdb_id(id): def tmdb_get_shows(config_path, plex, data, is_list=False): config_tools.TraktClient(config_path) - try: - tmdb_id = re.search('.*?(\\d+)', data) - tmdb_id = tmdb_id.group(1) - except AttributeError: # Bad URL Provided - return + + tmdb_id = tmdb_parse_id(data) + t_tvs = [] t_tv = TV() t_tv.api_key = config_tools.TMDB(config_path).apikey # Set TMDb api key for Movie @@ -271,11 +282,8 @@ def tmdb_get_shows(config_path, plex, data, is_list=False): def tvdb_get_shows(config_path, plex, data, is_list=False): config_tools.TraktClient(config_path) - try: - id = re.search('(\\d+)', data) - id = id.group(1) - except AttributeError: - raise ValueError("| Config Error: TVDb ID: {} is invalid it must be a number".format(data)) + + id = tvdb_parse_id(data) p_tv_map = {} for item in plex.Library.all(): @@ -306,10 +314,8 @@ def tvdb_get_shows(config_path, plex, data, is_list=False): def tmdb_get_summary(config_path, data, type): # Instantiate TMDB objects - try: - id = re.search('.*?(\\d+)', data).group(1) - except AttributeError: - raise ValueError("| Config Error: TMBd ID: {} is invalid it must be a number".format(data)) + id = tmdb_parse_id(data) + api_key = config_tools.TMDB(config_path).apikey language = config_tools.TMDB(config_path).language is_movie = config_tools.Plex(config_path).library_type == "movie" diff --git a/app/plex_auto_collections.py b/app/plex_auto_collections.py index fffee92..949853a 100644 --- a/app/plex_auto_collections.py +++ b/app/plex_auto_collections.py @@ -1,5 +1,6 @@ import os import argparse +import re import sys import threading import glob @@ -89,7 +90,7 @@ def update_from_config(config_path, plex, headless=False, no_meta=False, no_imag v_print = v if m == "tmdb_id" and tmdb_id is None: try: - tmdb_id = re.search('.*?(\\d+)', v).group(1) + tmdb_id = re.search('.*?(\\d+)', str(v)).group(1) except AttributeError: print("| Config Error: TMDb ID: {} is invalid".format(v)) add = False @@ -615,7 +616,7 @@ def append_collection(config_path, config_update=None): print("| |_| |_|\___|/_\_\ /_/ \_\\\\_,_| \__|\___/ \___|\___/|_||_|\___|\__| \__||_|\___/|_||_|/__/ |") print("| |") print("|===================================================================================================|") -print("| Version 2.1.0") +print("| Version 2.1.1") print("| Locating config...") config_path = None app_dir = os.path.dirname(os.path.abspath(__file__)) diff --git a/app/plex_tools.py b/app/plex_tools.py index b5239e4..16faf57 100644 --- a/app/plex_tools.py +++ b/app/plex_tools.py @@ -137,7 +137,7 @@ def add_to_collection(config_path, plex, method, value, c, map, subfilters=None) movies, missing = imdb_tools.imdb_get_movies(config_path, plex, value) elif method == "tmdb_list": movies, missing = imdb_tools.tmdb_get_movies(config_path, plex, value, is_list=True) - elif method in ["tmdb_id", "tmdb_movie", "tmd_collection"]: + elif method in ["tmdb_id", "tmdb_movie", "tmdb_collection"]: movies, missing = imdb_tools.tmdb_get_movies(config_path, plex, value) elif method == "trakt_list" and TraktClient.valid: movies, missing = trakt_tools.trakt_get_movies(config_path, plex, value) diff --git a/requirements.txt b/requirements.txt index d042e15..fe50f67 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ # Remove PyYAML==5.1.2 # Less common, pinned -PlexAPI==4.1.1 +PlexAPI==4.1.2 tmdbv3api==1.6.2 trakt.py==4.2.0 # More common, flexible