mirror of
https://github.com/mza921/Plex-Auto-Collections
synced 2024-11-14 00:07:18 +00:00
Merge branch 'master' into performance
This commit is contained in:
commit
3430ea653a
4 changed files with 95 additions and 81 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -8,6 +8,5 @@ app/images
|
|||
app/config.yml
|
||||
config/config-*
|
||||
config/*.pickle
|
||||
config/db/*
|
||||
**/cache.db*
|
||||
**/*.cache*
|
||||
|
|
30
CHANGELOG.md
30
CHANGELOG.md
|
@ -4,36 +4,6 @@ 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.8.0] - 2020-12-14 - [#142](https://github.com/mza921/Plex-Auto-Collections/pull/142)
|
||||
### Added
|
||||
- Faster initialization of a GUID mapping database for the new Plex Movie Agent using the Plex database
|
||||
|
||||
### Removed
|
||||
- `cache` and `cache_interval` options removed from the config. Movie/Show ID lookups are now always cached on each script execution.
|
||||
|
||||
### Fixed
|
||||
- [#132](https://github.com/mza921/Plex-Auto-Collections/issues/132) - plex_search with a range of years
|
||||
|
||||
## [2.7.0] - 2020-11-26 - [#115](https://github.com/mza921/Plex-Auto-Collections/pull/115)
|
||||
### Added
|
||||
- Added `tmdb_trending_daily` and `tmdb_trending_weekly`
|
||||
- Added requirements checking with an error message telling the user to update their requirements
|
||||
- [#98](https://github.com/mza921/Plex-Auto-Collections/issues/98) - Added `cache` attribute to cache the IDs of movies/shows for quicker lookup and `cache_update_interval` to determine how often to update the cache
|
||||
- [#123](https://github.com/mza921/Plex-Auto-Collections/issues/123) - Added new filter `plex_collection`
|
||||
- [#125](https://github.com/mza921/Plex-Auto-Collections/issues/125) - Added error message for YAML Scan Failures
|
||||
|
||||
### Changed
|
||||
- Created a mapping for TMDb ID to Plex Rating Key once each run instead of every time tmdb, imdb, tvdb, or trakt list was run.
|
||||
- [#110](https://github.com/mza921/Plex-Auto-Collections/issues/110) - Added `add_to_radarr` as a collection level attribute override
|
||||
- [#121](https://github.com/mza921/Plex-Auto-Collections/issues/121) - Added paging to `tmdb_network` and `tmdb_company` for show libraries
|
||||
- Upgrade tmdbv3api dependency to 1.7.1
|
||||
|
||||
### Fixed
|
||||
- [#109](https://github.com/mza921/Plex-Auto-Collections/issues/109) - The Cache shouldn't be created unless it has to be
|
||||
- [#117](https://github.com/mza921/Plex-Auto-Collections/issues/117) - Typo
|
||||
- [#118](https://github.com/mza921/Plex-Auto-Collections/issues/118) - Check for to see if the tmdb attribute exists
|
||||
- [#120](https://github.com/mza921/Plex-Auto-Collections/issues/120) - Sometimes the collection wasn't found
|
||||
|
||||
## [2.6.0] - 2020-11-12 - [#113](https://github.com/mza921/Plex-Auto-Collections/pull/113)
|
||||
### Added
|
||||
- [#107](https://github.com/mza921/Plex-Auto-Collections/issues/107) - Added `plex_collection`
|
||||
|
|
|
@ -68,45 +68,45 @@ def imdb_get_ids(plex, imdb_url):
|
|||
|
||||
def tmdb_get_imdb(config_path, tmdb_id):
|
||||
movie = Movie()
|
||||
movie.api_key = config_tools.TMDB(config_path).apikey
|
||||
return str(movie.external_ids(tmdb_id)['imdb_id'])
|
||||
imdb_map = {}
|
||||
matched_imdb_movies = []
|
||||
missing_imdb_movies = []
|
||||
current_length = 0
|
||||
current_count = 0
|
||||
plex_tools.create_cache(config_path)
|
||||
plex_movies = plex.Library.all()
|
||||
for m in plex_movies:
|
||||
current_count += 1
|
||||
print_display = "| Processing: {}/{} {}".format(current_count, len(plex_movies), m.title)
|
||||
print(adjust_space(current_length, print_display), end="\r")
|
||||
current_length = len(print_display)
|
||||
if 'plex://' in m.guid:
|
||||
item = m
|
||||
# Check cache for imdb_id
|
||||
imdb_id = plex_tools.query_cache(config_path, item.guid, 'imdb_id')
|
||||
if not imdb_id:
|
||||
imdb_id, tmdb_id = plex_tools.alt_id_lookup(plex, item)
|
||||
print(adjust_space(current_length, "| Cache | + | {} | {} | {} | {}".format(item.guid, imdb_id, tmdb_id, item.title)))
|
||||
plex_tools.update_cache(config_path, item.guid, imdb_id=imdb_id, tmdb_id=tmdb_id)
|
||||
elif 'themoviedb://' in m.guid:
|
||||
if not tmdb.api_key == "None":
|
||||
tmdb_id = m.guid.split('themoviedb://')[1].split('?')[0]
|
||||
tmdbapi = movie.details(tmdb_id)
|
||||
imdb_id = tmdbapi.imdb_id if hasattr(tmdbapi, 'imdb_id') else None
|
||||
else:
|
||||
imdb_id = None
|
||||
elif 'imdb://' in m.guid:
|
||||
imdb_id = m.guid.split('imdb://')[1].split('?')[0]
|
||||
else:
|
||||
imdb_id = None
|
||||
|
||||
def tmdb_get_tvdb(config_path, tmdb_id):
|
||||
show = TV()
|
||||
show.api_key = config_tools.TMDB(config_path).apikey
|
||||
return str(show.external_ids(tmdb_id)['tvdb_id'])
|
||||
if imdb_id and imdb_id in title_ids:
|
||||
imdb_map[imdb_id] = m
|
||||
else:
|
||||
imdb_map[m.ratingKey] = m
|
||||
|
||||
def imdb_get_tmdb(config_path, imdb_id):
|
||||
movie = Movie()
|
||||
movie.api_key = config_tools.TMDB(config_path).apikey
|
||||
search = movie.external(external_id=imdb_id, external_source="imdb_id")['movie_results']
|
||||
if len(search) == 1:
|
||||
try:
|
||||
return str(search[0]['id'])
|
||||
except IndexError:
|
||||
return None
|
||||
else:
|
||||
return None
|
||||
print(adjust_space(current_length, "| Processed {} Movies".format(len(plex_movies))))
|
||||
|
||||
def tvdb_get_tmdb(config_path, tvdb_id):
|
||||
movie = Movie()
|
||||
movie.api_key = config_tools.TMDB(config_path).apikey
|
||||
search = movie.external(external_id=tvdb_id, external_source="tvdb_id")['tv_results']
|
||||
if len(search) == 1:
|
||||
try:
|
||||
return str(search[0]['id'])
|
||||
except IndexError:
|
||||
return None
|
||||
else:
|
||||
return None
|
||||
|
||||
def imdb_get_movies(config_path, plex, plex_map, data):
|
||||
title_ids = data[1]
|
||||
print("| {} Movies found on IMDb".format(len(title_ids)))
|
||||
t_movie = Movie()
|
||||
t_movie.api_key = config_tools.TMDB(config_path).apikey
|
||||
matched = []
|
||||
missing = []
|
||||
for imdb_id in title_ids:
|
||||
tmdb_id = imdb_get_tmdb(config_path, imdb_id)
|
||||
if tmdb_id in plex_map:
|
||||
|
@ -146,9 +146,9 @@ def tmdb_get_movies(config_path, plex, plex_map, data, method):
|
|||
if count == amount:
|
||||
break
|
||||
elif method in ["tmdb_popular", "tmdb_top_rated", "tmdb_now_playing", "tmdb_trending_daily", "tmdb_trending_weekly"]:
|
||||
trending = Trending()
|
||||
trending.api_key = t_movie.api_key
|
||||
for x in range(int(int(data) / 20) + 1):
|
||||
#trending = Trending() #TURNON:Trending
|
||||
#trending.api_key = t_movie.api_key #TURNON:Trending
|
||||
for x in range(int(data / 20) + 1):
|
||||
if method == "tmdb_popular":
|
||||
tmdb_movies = t_movie.popular(x + 1)
|
||||
elif method == "tmdb_top_rated":
|
||||
|
@ -206,10 +206,40 @@ def tmdb_get_movies(config_path, plex, plex_map, data, method):
|
|||
|
||||
matched = []
|
||||
missing = []
|
||||
for mid in t_movs:
|
||||
mid = str(mid)
|
||||
if mid in plex_map:
|
||||
matched.append(plex.Server.fetchItem(plex_map[mid]))
|
||||
plex_tools.create_cache(config_path)
|
||||
# We want to search for a match first to limit TMDb API calls
|
||||
# Too many rapid calls can cause a momentary block
|
||||
# If needed in future maybe add a delay after x calls to let the limit reset
|
||||
for mid in t_movs: # For each TMBd ID in TMBd Collection
|
||||
match = False
|
||||
for m in p_m_map: # For each movie in Plex
|
||||
item = m
|
||||
agent_type = urlparse(m.guid).scheme.split('.')[-1]
|
||||
# Plex movie agent
|
||||
if agent_type == 'plex':
|
||||
# Check cache for tmdb_id
|
||||
tmdb_id = plex_tools.query_cache(config_path, item.guid, 'tmdb_id')
|
||||
imdb_id = plex_tools.query_cache(config_path, item.guid, 'imdb_id')
|
||||
if not tmdb_id:
|
||||
imdb_id, tmdb_id = plex_tools.alt_id_lookup(plex, item)
|
||||
print("| Cache | + | {} | {} | {} | {}".format(item.guid, imdb_id, tmdb_id, item.title))
|
||||
plex_tools.update_cache(config_path, item.guid, imdb_id=imdb_id, tmdb_id=tmdb_id)
|
||||
if int(tmdb_id) == int(mid):
|
||||
match = True
|
||||
break
|
||||
elif agent_type == 'themoviedb':
|
||||
if int(p_m_map[m]) == int(mid):
|
||||
match = True
|
||||
break
|
||||
elif agent_type == 'imdb':
|
||||
imdb_id = t_movie.details(mid).imdb_id
|
||||
for m in p_m_map:
|
||||
if "tt" in p_m_map[m]:
|
||||
if p_m_map[m] == imdb_id:
|
||||
match = True
|
||||
break
|
||||
if match:
|
||||
matched.append(m)
|
||||
else:
|
||||
missing.append(mid)
|
||||
|
||||
|
@ -293,9 +323,9 @@ def tmdb_get_shows(config_path, plex, plex_map, data, method):
|
|||
if count == amount:
|
||||
break
|
||||
elif method in ["tmdb_popular", "tmdb_top_rated", "tmdb_trending_daily", "tmdb_trending_weekly"]:
|
||||
trending = Trending()
|
||||
trending.api_key = t_movie.api_key
|
||||
for x in range(int(int(data) / 20) + 1):
|
||||
#trending = Trending() #TURNON:Trending
|
||||
#trending.api_key = t_movie.api_key #TURNON:Trending
|
||||
for x in range(int(data / 20) + 1):
|
||||
if method == "tmdb_popular":
|
||||
tmdb_shows = t_tv.popular(x + 1)
|
||||
elif method == "tmdb_top_rated":
|
||||
|
@ -347,8 +377,23 @@ def tmdb_get_shows(config_path, plex, plex_map, data, method):
|
|||
|
||||
return matched, missing
|
||||
|
||||
def tvdb_get_shows(config_path, plex, plex_map, data):
|
||||
tvdb_id = str(data)
|
||||
def tvdb_get_shows(config_path, plex, data):
|
||||
config_tools.TraktClient(config_path)
|
||||
|
||||
id = int(data)
|
||||
|
||||
p_tv_map = {}
|
||||
for item in plex.Library.all():
|
||||
guid = urlparse(item.guid)
|
||||
item_type = guid.scheme.split('.')[-1]
|
||||
if item_type == 'thetvdb':
|
||||
tvdb_id = guid.netloc
|
||||
elif item_type == 'themoviedb' and TraktClient.valid:
|
||||
tvdb_id = get_tvdb_id_from_tmdb_id(guid.netloc)
|
||||
else:
|
||||
tvdb_id = None
|
||||
p_tv_map[item] = tvdb_id
|
||||
|
||||
matched = []
|
||||
missing = []
|
||||
if tvdb_id in plex_map:
|
||||
|
|
|
@ -544,7 +544,7 @@ def update_from_config(config_path, plex, headless=False, no_meta=False, no_imag
|
|||
year_pair = get_method_pair_year(final_attr, collections[c][m][search_attr])
|
||||
if len(year_pair[1]) > 0:
|
||||
searches_used.append(final_attr[:-4] if final_attr.endswith(".not") else final_attr)
|
||||
search.append(get_method_pair_int(final_attr, year_pair[1], final_attr[:-4] if final_attr.endswith(".not") else final_attr))
|
||||
search.append(get_method_pair_int(final_attr, collections[c][m][search_attr], final_attr[:-4] if final_attr.endswith(".not") else final_attr))
|
||||
elif final_attr in plex_searches:
|
||||
if final_attr.startswith("tmdb_"):
|
||||
final_attr = final_attr[5:]
|
||||
|
@ -1002,7 +1002,7 @@ print("| | _/| |/ -_)\ \ / / _ \| || || _|/ _ \ | (__ / _ \| || |/ -_)/ _|
|
|||
print("| |_| |_|\___|/_\_\ /_/ \_\\\\_,_| \__|\___/ \___|\___/|_||_|\___|\__| \__||_|\___/|_||_|/__/ |")
|
||||
print("| |")
|
||||
print("|===================================================================================================|")
|
||||
print("| Version 2.8.0")
|
||||
print("| Version 2.6.0")
|
||||
print("| Locating config...")
|
||||
config_path = None
|
||||
app_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
|
Loading…
Reference in a new issue