summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2021-05-28 22:45:54 -0400
committermorpheus65535 <[email protected]>2021-05-28 22:45:54 -0400
commitb2b979581075788d320a1b76158f4607d2e41ca0 (patch)
treeadfdb9b94102d76ffe892a6bf98882356fd29965
parent7b9c19d7c00b9f73b3b2fe2b25dedc4d4b337033 (diff)
downloadbazarr-b2b979581075788d320a1b76158f4607d2e41ca0.tar.gz
bazarr-b2b979581075788d320a1b76158f4607d2e41ca0.zip
Added exclusion in get rootfolder functions for the ones that aren't used by any series/movies. #1413v0.9.6-beta.14
-rw-r--r--bazarr/get_rootfolder.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/bazarr/get_rootfolder.py b/bazarr/get_rootfolder.py
index f1704ec32..bda0a7356 100644
--- a/bazarr/get_rootfolder.py
+++ b/bazarr/get_rootfolder.py
@@ -6,7 +6,7 @@ import logging
from config import settings, url_sonarr, url_radarr
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"]}
@@ -30,8 +30,10 @@ def get_sonarr_rootfolder():
logging.exception("BAZARR Error trying to get rootfolder from Sonarr.")
return []
else:
+ sonarr_movies_paths = list(TableShows.select(TableShows.path).dicts())
for folder in rootfolder.json():
- sonarr_rootfolder.append({'id': folder['id'], 'path': folder['path']})
+ if any(item['path'].startswith(folder['path']) for item in sonarr_movies_paths):
+ sonarr_rootfolder.append({'id': folder['id'], 'path': folder['path']})
db_rootfolder = TableShowsRootfolder.select(TableShowsRootfolder.id, TableShowsRootfolder.path).dicts()
rootfolder_to_remove = [x for x in db_rootfolder if not
next((item for item in sonarr_rootfolder if item['id'] == x['id']), False)]
@@ -93,8 +95,10 @@ def get_radarr_rootfolder():
logging.exception("BAZARR Error trying to get rootfolder from Radarr.")
return []
else:
+ radarr_movies_paths = list(TableMovies.select(TableMovies.path).dicts())
for folder in rootfolder.json():
- radarr_rootfolder.append({'id': folder['id'], 'path': folder['path']})
+ if any(item['path'].startswith(folder['path']) for item in radarr_movies_paths):
+ radarr_rootfolder.append({'id': folder['id'], 'path': folder['path']})
db_rootfolder = TableMoviesRootfolder.select(TableMoviesRootfolder.id, TableMoviesRootfolder.path).dicts()
rootfolder_to_remove = [x for x in db_rootfolder if not
next((item for item in radarr_rootfolder if item['id'] == x['id']), False)]