1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-26 09:37:25 +00:00

Added exclusion in get rootfolder functions for the ones that aren't used by any series/movies. #1413

This commit is contained in:
morpheus65535 2021-05-28 22:45:54 -04:00
parent 7b9c19d7c0
commit b2b9795810

View file

@ -6,7 +6,7 @@ import logging
from config import settings, url_sonarr, url_radarr from config import settings, url_sonarr, url_radarr
from helper import path_mappings from helper import path_mappings
from database import TableShowsRootfolder, TableMoviesRootfolder from database import TableShowsRootfolder, TableMoviesRootfolder, TableShows, TableMovies
headers = {"User-Agent": os.environ["SZ_USER_AGENT"]} headers = {"User-Agent": os.environ["SZ_USER_AGENT"]}
@ -30,7 +30,9 @@ def get_sonarr_rootfolder():
logging.exception("BAZARR Error trying to get rootfolder from Sonarr.") logging.exception("BAZARR Error trying to get rootfolder from Sonarr.")
return [] return []
else: else:
sonarr_movies_paths = list(TableShows.select(TableShows.path).dicts())
for folder in rootfolder.json(): for folder in rootfolder.json():
if any(item['path'].startswith(folder['path']) for item in sonarr_movies_paths):
sonarr_rootfolder.append({'id': folder['id'], 'path': folder['path']}) sonarr_rootfolder.append({'id': folder['id'], 'path': folder['path']})
db_rootfolder = TableShowsRootfolder.select(TableShowsRootfolder.id, TableShowsRootfolder.path).dicts() db_rootfolder = TableShowsRootfolder.select(TableShowsRootfolder.id, TableShowsRootfolder.path).dicts()
rootfolder_to_remove = [x for x in db_rootfolder if not rootfolder_to_remove = [x for x in db_rootfolder if not
@ -93,7 +95,9 @@ def get_radarr_rootfolder():
logging.exception("BAZARR Error trying to get rootfolder from Radarr.") logging.exception("BAZARR Error trying to get rootfolder from Radarr.")
return [] return []
else: else:
radarr_movies_paths = list(TableMovies.select(TableMovies.path).dicts())
for folder in rootfolder.json(): for folder in rootfolder.json():
if any(item['path'].startswith(folder['path']) for item in radarr_movies_paths):
radarr_rootfolder.append({'id': folder['id'], 'path': folder['path']}) radarr_rootfolder.append({'id': folder['id'], 'path': folder['path']})
db_rootfolder = TableMoviesRootfolder.select(TableMoviesRootfolder.id, TableMoviesRootfolder.path).dicts() db_rootfolder = TableMoviesRootfolder.select(TableMoviesRootfolder.id, TableMoviesRootfolder.path).dicts()
rootfolder_to_remove = [x for x in db_rootfolder if not rootfolder_to_remove = [x for x in db_rootfolder if not