radarr and sonarr now show what theyre doing

pull/462/head
meisnate12 3 years ago
parent cc6d0ff58a
commit 574d55f637

@ -2,7 +2,7 @@ import logging
from modules import util from modules import util
from modules.util import Failed from modules.util import Failed
from arrapi import RadarrAPI from arrapi import RadarrAPI
from arrapi.exceptions import ArrException, Invalid from arrapi.exceptions import ArrException, Invalid, NotFound
logger = logging.getLogger("Plex Meta Manager") logger = logging.getLogger("Plex Meta Manager")
@ -28,8 +28,12 @@ class Radarr:
self.quality_profile = params["quality_profile"] self.quality_profile = params["quality_profile"]
self.tag = params["tag"] self.tag = params["tag"]
self.search = params["search"] self.search = params["search"]
self.radarr_path = "" if params["radarr_path"] and params["plex_path"] else params["radarr_path"] self.radarr_path = params["radarr_path"] if params["radarr_path"] and params["plex_path"] else ""
self.plex_path = "" if params["radarr_path"] and params["plex_path"] else params["plex_path"] self.plex_path = params["plex_path"] if params["radarr_path"] and params["plex_path"] else ""
logger.debug(params["radarr_path"])
logger.debug(self.radarr_path)
logger.debug(params["plex_path"])
logger.debug(self.plex_path)
def add_tmdb(self, tmdb_ids, **options): def add_tmdb(self, tmdb_ids, **options):
logger.info("") logger.info("")
@ -43,8 +47,28 @@ class Radarr:
quality_profile = options["quality"] if "quality" in options else self.quality_profile quality_profile = options["quality"] if "quality" in options else self.quality_profile
tags = options["tag"] if "tag" in options else self.tag tags = options["tag"] if "tag" in options else self.tag
search = options["search"] if "search" in options else self.search search = options["search"] if "search" in options else self.search
added = []
exists = []
invalid = []
movies = []
for i, item in enumerate(tmdb_ids, 1):
path = item[1] if isinstance(item, tuple) else None
tmdb_id = item[0] if isinstance(item, tuple) else item
util.print_return(f"Loading TMDb ID: {tmdb_id} {i}/{len(tmdb_ids)}")
try:
movie = self.api.get_movie(tmdb_id=tmdb_id)
movies.append((movie, path) if path else movie)
except NotFound:
invalid.append(item)
if len(movies) == 100 or len(tmdb_ids) == i:
try: try:
added, exists, invalid = self.api.add_multiple_movies(tmdb_ids, folder, quality_profile, monitor, search, availability, tags, per_request=100) _a, _e, _i = self.api.add_multiple_movies(movies, folder, quality_profile, monitor, search,
availability, tags, per_request=100)
added.extend(_a)
exists.extend(_e)
invalid.extend(_i)
movies = []
except Invalid as e: except Invalid as e:
raise Failed(f"Radarr Error: {e}") raise Failed(f"Radarr Error: {e}")

@ -2,7 +2,7 @@ import logging
from modules import util from modules import util
from modules.util import Failed from modules.util import Failed
from arrapi import SonarrAPI from arrapi import SonarrAPI
from arrapi.exceptions import ArrException, Invalid from arrapi.exceptions import ArrException, Invalid, NotFound
logger = logging.getLogger("Plex Meta Manager") logger = logging.getLogger("Plex Meta Manager")
@ -50,8 +50,8 @@ class Sonarr:
self.tag = params["tag"] self.tag = params["tag"]
self.search = params["search"] self.search = params["search"]
self.cutoff_search = params["cutoff_search"] self.cutoff_search = params["cutoff_search"]
self.sonarr_path = "" if params["sonarr_path"] and params["plex_path"] else params["sonarr_path"] self.sonarr_path = params["sonarr_path"] if params["sonarr_path"] and params["plex_path"] else ""
self.plex_path = "" if params["sonarr_path"] and params["plex_path"] else params["plex_path"] self.plex_path = params["plex_path"] if params["sonarr_path"] and params["plex_path"] else ""
def add_tvdb(self, tvdb_ids, **options): def add_tvdb(self, tvdb_ids, **options):
logger.info("") logger.info("")
@ -69,8 +69,28 @@ class Sonarr:
tags = options["tag"] if "tag" in options else self.tag tags = options["tag"] if "tag" in options else self.tag
search = options["search"] if "search" in options else self.search search = options["search"] if "search" in options else self.search
cutoff_search = options["cutoff_search"] if "cutoff_search" in options else self.cutoff_search cutoff_search = options["cutoff_search"] if "cutoff_search" in options else self.cutoff_search
added = []
exists = []
invalid = []
shows = []
for i, item in enumerate(tvdb_ids, 1):
path = item[1] if isinstance(item, tuple) else None
tvdb_id = item[0] if isinstance(item, tuple) else item
util.print_return(f"Loading TVDb ID: {tvdb_id} {i}/{len(tvdb_ids)}")
try:
show = self.api.get_series(tvdb_id=tvdb_id)
shows.append((show, path) if path else show)
except NotFound:
invalid.append(item)
if len(shows) == 100 or len(tvdb_ids) == i:
try: try:
added, exists, invalid = self.api.add_multiple_series(tvdb_ids, folder, quality_profile, language_profile, monitor, season, search, cutoff_search, series, tags, per_request=100) _a, _e, _i = self.api.add_multiple_series(shows, folder, quality_profile, language_profile, monitor,
season, search, cutoff_search, series, tags, per_request=100)
added.extend(_a)
exists.extend(_e)
invalid.extend(_i)
shows = []
except Invalid as e: except Invalid as e:
raise Failed(f"Sonarr Error: {e}") raise Failed(f"Sonarr Error: {e}")

Loading…
Cancel
Save