Skip to content

Commit

Permalink
Merge pull request #96 from meisnate12/master
Browse files Browse the repository at this point in the history
2.4.3 Fix for #93 and #94
  • Loading branch information
mza921 committed Nov 5, 2020
2 parents adffea9 + 6d16795 commit 48e722e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.4.3] - 2020-11-05 - [#96](https://github.com/mza921/Plex-Auto-Collections/pull/96)
### Fixed
- [#93](https://github.com/mza921/Plex-Auto-Collections/issues/93) - fixed max_age
- [#94](https://github.com/mza921/Plex-Auto-Collections/issues/94) - Fixed Trakt Trending

## [2.4.2] - 2020-11-04 - [#90](https://github.com/mza921/Plex-Auto-Collections/pull/90)
### Fixed
- [#87](https://github.com/mza921/Plex-Auto-Collections/issues/87) - 1000+ IMDB Error Fixed
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.4.2
##### Version 2.4.3
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](https://i.imgur.com/iHAYFIZ.png)
Expand Down
4 changes: 2 additions & 2 deletions app/plex_auto_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def check_details(check_name, check_value):
elif method_name in ["imdb_list", "trakt_list"]: #TODO: validate
methods.append((method_name, get_attribute_list(collections[c][m])))
elif method_name == "trakt_trending":
methods.append((method_name, regex_first_int(collections[c][m], method_name, default=30)))
methods.append((method_name, [regex_first_int(collections[c][m], method_name, default=30)]))
elif method_name == "tautulli": #TODO:test
try:
new_dictionary = {}
Expand Down Expand Up @@ -794,7 +794,7 @@ def append_collection(config_path, config_update=None):
print("| |_| |_|\___|/_\_\ /_/ \_\\\\_,_| \__|\___/ \___|\___/|_||_|\___|\__| \__||_|\___/|_||_|/__/ |")
print("| |")
print("|===================================================================================================|")
print("| Version 2.4.2")
print("| Version 2.4.3")
print("| Locating config...")
config_path = None
app_dir = os.path.dirname(os.path.abspath(__file__))
Expand Down
47 changes: 30 additions & 17 deletions app/plex_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@
import os
import sqlite3

#this will be taken out soon
def regex_first_int(data, method, id_type="number", default=None):
try:
id = re.search('(\\d+)', str(data)).group(1)
if len(str(id)) != len(str(data)):
print("| Config Warning: {} can be replaced with {}".format(data, id))
return id
except AttributeError:
if default is None:
raise ValueError("| Config Error: Skipping {} failed to parse {} from {}".format(method, id_type, data))
else:
print("| Config Error: {} failed to parse {} from {} using {} as default".format(method, id_type, data, default))
return default

def get_movie(plex, data):
# If an int is passed as data, assume it is a movie's rating key
Expand Down Expand Up @@ -143,22 +156,22 @@ def search_plex():
print(output)
return plex.Library.search(**search_terms)

if ("trakt" in method or ("tmdb" in method and plex.library_type == "show")) and not TraktClient.valid:
if ("trakt" in method or (("tmdb" in method or "tvdb" in method) and plex.library_type == "show")) and not TraktClient.valid:
raise KeyError("| trakt connection required for {}",format(method))
elif ("imdb" in method or "tmdb" in method) and not TMDB.valid:
raise KeyError("| tmdb connection required for {}",format(method))
elif method == "tautulli" and not Tautulli.valid:
raise KeyError("| tautulli connection required for {}",format(method))
elif plex.library_type == "movie":
if method == "imdb_list" and TMDB.valid:
if method == "imdb_list":
movies, missing = imdb_tools.imdb_get_movies(config_path, plex, value)
elif method == "tmdb_list" and TMDB.valid:
movies, missing = imdb_tools.tmdb_get_movies(config_path, plex, value, is_list=True)
elif method in ["tmdb_id", "tmdb_movie", "tmdb_collection"] and TMDB.valid:
movies, missing = imdb_tools.tmdb_get_movies(config_path, plex, value)
elif method == "trakt_list" and TraktClient.valid:
elif method in ["tmdb_list", "tmdb_id", "tmdb_movie", "tmdb_collection", "tmdb_company"]:
movies, missing = imdb_tools.tmdb_get_movies(config_path, plex, value, method)
elif method == "trakt_list":
movies, missing = trakt_tools.trakt_get_movies(config_path, plex, value)
elif method == "trakt_trending" and TraktClient.valid:
elif method == "trakt_trending":
movies, missing = trakt_tools.trakt_get_movies(config_path, plex, value, is_userlist=False)
elif method == "tautulli" and Tautulli.valid:
elif method == "tautulli":
movies, missing = imdb_tools.get_tautulli(config_path, plex, value)
elif method == "all":
movies = plex.Library.all()
Expand All @@ -167,17 +180,17 @@ def search_plex():
else:
print("| Config Error: {} method not supported".format(method))
elif plex.library_type == "show":
if method == "tmdb_list" and TMDB.valid and TraktClient.valid:
if method == "tmdb_list":
shows, missing = imdb_tools.tmdb_get_shows(config_path, plex, value, is_list=True)
elif method in ["tmdb_id", "tmdb_show"] and TMDB.valid and TraktClient.valid:
elif method in ["tmdb_id", "tmdb_show"]:
shows, missing = imdb_tools.tmdb_get_shows(config_path, plex, value)
elif method == "tvdb_show" and TraktClient.valid:
elif method == "tvdb_show":
shows, missing = imdb_tools.tvdb_get_shows(config_path, plex, value)
elif method == "trakt_list" and TraktClient.valid:
elif method == "trakt_list":
shows, missing = trakt_tools.trakt_get_shows(config_path, plex, value)
elif method == "trakt_trending" and TraktClient.valid:
elif method == "trakt_trending":
shows, missing = trakt_tools.trakt_get_shows(config_path, plex, value, is_userlist=False)
elif method == "tautulli" and Tautulli.valid:
elif method == "tautulli":
shows, missing = imdb_tools.get_tautulli(config_path, plex, value)
elif method == "all":
shows = plex.Library.all()
Expand Down Expand Up @@ -284,7 +297,7 @@ def search_plex():
modifier = sf[0][-4:]
method = subfilter_alias[sf[0][:-4]] if modifier in [".not", ".lte", ".gte"] else subfilter_alias[sf[0]]
if method == "max_age":
max_age = imdb_tools.regex_first_int(sf[1])
max_age = regex_first_int(sf[1])
if sf[1][-1] == "y":
max_age = int(365.25 * max_age)
threshold_date = datetime.now() - timedelta(days=max_age)
Expand Down Expand Up @@ -399,4 +412,4 @@ def update_cache(config_path, plex_guid, **kwargs):
if 'tmdb_id' in kwargs:
tmdb_id = kwargs['tmdb_id']
cursor.execute('INSERT OR IGNORE INTO guids(plex_guid, tmdb_id) VALUES(?, ?)', (plex_guid, tmdb_id, ))
cursor.execute('UPDATE guids SET tmdb_id = ? WHERE plex_guid = ?', (tmdb_id, plex_guid))
cursor.execute('UPDATE guids SET tmdb_id = ? WHERE plex_guid = ?', (tmdb_id, plex_guid))

0 comments on commit 48e722e

Please sign in to comment.