Skip to content

Commit

Permalink
Merge pull request #83 from meisnate12/develop
Browse files Browse the repository at this point in the history
v1.4.0
  • Loading branch information
meisnate12 authored Mar 9, 2021
2 parents 288fa7e + f1966a0 commit 706b2c3
Show file tree
Hide file tree
Showing 16 changed files with 629 additions and 246 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Plex Meta Manager
#### Version 1.3.0
#### Version 1.4.0

The original concept for Plex Meta Manager is [Plex Auto Collections](https://github.com/mza921/Plex-Auto-Collections), but this is rewritten from the ground up to be able to include a scheduler, metadata edits, multiple libraries, and logging. Plex Meta Manager is a Python 3 script that can be continuously run using YAML configuration files to update on a schedule the metadata of the movies, shows, and collections in your libraries as well as automatically build collections based on various methods all detailed in the wiki. Some collection examples that the script can automatically build and update daily include Plex Based Searches like actor, genre, or studio collections or Collections based on TMDb, IMDb, Trakt, TVDb, AniDB, or MyAnimeList lists and various other services.

The script can update many metadata fields for movies, shows, collections, seasons, and episodes and can act as a backup if your plex DB goes down. It can even update metadata the plex UI can't like Season Names. If the time is put into the metadata configuration file you can have a way to recreate your library and all its metadata changes with the click of a button.

The script is designed to work with most Metadata agents including the new Plex Movie Agent, [Hama Anime Agent](https://github.com/ZeroQI/Hama.bundle), and [MyAnimeList Anime Agent](https://github.com/Fribb/MyAnimeList.bundle).
The script is designed to work with most Metadata agents including the new Plex Movie Agent, New Plex TV Agent, [Hama Anime Agent](https://github.com/ZeroQI/Hama.bundle), and [MyAnimeList Anime Agent](https://github.com/Fribb/MyAnimeList.bundle).

[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/donate?business=JTK3CVKF3ZHP2&item_name=Plex+Meta+Manager&currency_code=USD)

## Getting Started

Expand All @@ -20,4 +22,3 @@ The script is designed to work with most Metadata agents including the new Plex
* To see user submitted Metadata configuration files and you could even add your own go to the [Plex Meta Manager Configs](https://github.com/meisnate12/Plex-Meta-Manager-Configs)
* Pull Request are welcome but please submit them to the develop branch
* If you wish to contribute to the Wiki please fork and send a pull request on the [Plex Meta Manager Wiki Repository](https://github.com/meisnate12/Plex-Meta-Manager-Wiki)
* [Buy Me a Pizza](https://www.buymeacoffee.com/meisnate12)
2 changes: 2 additions & 0 deletions config/config.yml.template
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ sonarr: # Can be individually specified
root_folder_path: "S:/TV Shows"
add: false
search: false
omdb:
apikey: ########
trakt:
client_id: ################################################################
client_secret: ################################################################
Expand Down
46 changes: 6 additions & 40 deletions modules/anidb.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
logger = logging.getLogger("Plex Meta Manager")

class AniDBAPI:
def __init__(self, Cache=None, TMDb=None, Trakt=None):
self.Cache = Cache
self.TMDb = TMDb
self.Trakt = Trakt
def __init__(self, config):
self.config = config
self.urls = {
"anime": "https://anidb.net/anime",
"popular": "https://anidb.net/latest/anime/popular/?h=1",
Expand Down Expand Up @@ -80,9 +78,10 @@ def get_items(self, method, data, language, status_message=True):
movie_ids = []
for anidb_id in anime_ids:
try:
tmdb_id = self.convert_from_imdb(self.convert_anidb_to_imdb(anidb_id))
if tmdb_id: movie_ids.append(tmdb_id)
else: raise Failed
for imdb_id in self.convert_anidb_to_imdb(anidb_id):
tmdb_id, _ = self.config.convert_from_imdb(imdb_id, language)
if tmdb_id: movie_ids.append(tmdb_id)
else: raise Failed
except Failed:
try: show_ids.append(self.convert_anidb_to_tvdb(anidb_id))
except Failed: logger.error(f"AniDB Error: No TVDb ID or IMDb ID found for AniDB ID: {anidb_id}")
Expand All @@ -91,36 +90,3 @@ def get_items(self, method, data, language, status_message=True):
logger.debug(f"TMDb IDs Found: {movie_ids}")
logger.debug(f"TVDb IDs Found: {show_ids}")
return movie_ids, show_ids

def convert_from_imdb(self, imdb_id):
output_tmdb_ids = []
if not isinstance(imdb_id, list):
imdb_id = [imdb_id]

for imdb in imdb_id:
expired = False
if self.Cache:
tmdb_id, tvdb_id = self.Cache.get_ids_from_imdb(imdb)
if not tmdb_id:
tmdb_id, expired = self.Cache.get_tmdb_from_imdb(imdb)
if expired:
tmdb_id = None
else:
tmdb_id = None
from_cache = tmdb_id is not None

if not tmdb_id and self.TMDb:
try: tmdb_id = self.TMDb.convert_imdb_to_tmdb(imdb)
except Failed: pass
if not tmdb_id and self.Trakt:
try: tmdb_id = self.Trakt.convert_imdb_to_tmdb(imdb)
except Failed: pass
try:
if tmdb_id and not from_cache: self.TMDb.get_movie(tmdb_id)
except Failed: tmdb_id = None
if tmdb_id: output_tmdb_ids.append(tmdb_id)
if self.Cache and tmdb_id and expired is not False:
self.Cache.update_imdb("movie", expired, imdb, tmdb_id)
if len(output_tmdb_ids) == 0: raise Failed(f"AniDB Error: No TMDb ID found for IMDb: {imdb_id}")
elif len(output_tmdb_ids) == 1: return output_tmdb_ids[0]
else: return output_tmdb_ids
Loading

0 comments on commit 706b2c3

Please sign in to comment.