Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix breaking typo, some other clean up #68

Merged
merged 15 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8-slim
FROM python:3-slim
VOLUME /config
COPY . /
RUN \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
40 changes: 23 additions & 17 deletions app/imdb_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions app/plex_auto_collections.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import argparse
import re
import sys
import threading
import glob
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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__))
Expand Down
2 changes: 1 addition & 1 deletion app/plex_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down