diff --git a/README.md b/README.md index 322039e4..9f37df97 100644 --- a/README.md +++ b/README.md @@ -73,3 +73,14 @@ pip install -r requirements.txt python backend/main.py ``` +## Symlinking settings +"host_mount" should point to your rclone mount that has your torrents on your host, if you are using native webdav set webdav-url to "https://dav.real-debrid.com/torrents" + +"container_mount" should point to the location of the mount in plex container + +### Example: +Rclone is mounted to /iceberg/vfs on your host machine -> settings should have: "host_mount": "/iceberg/vfs" + +Plex container volume configuration for rclone mount is "/iceberg/vfs:/media/vfs" -> settings should have: "container_mount": "/media/vfs" + +Plex libraries you want to add to sections: movies -> /media/library/movies, shows -> /media/library/shows diff --git a/backend/program/__init__.py b/backend/program/__init__.py index 3de49ec7..a50026ac 100644 --- a/backend/program/__init__.py +++ b/backend/program/__init__.py @@ -42,9 +42,7 @@ class TorrentioConfig(BaseModel): class Settings(BaseModel): version: str debug: bool - service_mode: bool log: bool - menu_on_startup: bool plex: PlexConfig mdblist: MdblistConfig overseerr: OverseerrConfig diff --git a/backend/program/libraries/plex.py b/backend/program/libraries/plex.py index 69a15de7..9c79ddd4 100644 --- a/backend/program/libraries/plex.py +++ b/backend/program/libraries/plex.py @@ -1,4 +1,5 @@ """Plex library module""" +import os import threading import time from typing import List, Optional @@ -36,6 +37,7 @@ def __init__(self, media_items: MediaItemContainer): while True: try: temp_settings = settings.get("plex") + self.library_path = os.path.abspath(os.path.join(settings.get("container_mount"), os.pardir, "library")) self.plex = PlexServer( temp_settings["url"], temp_settings["token"], timeout=15 ) @@ -69,7 +71,7 @@ def _update_items(self): processed_sections = set() for section in sections: - if section.key in processed_sections: + if section.key in processed_sections and not self._is_wanted_section(section): continue try: @@ -95,6 +97,8 @@ def _update_items(self): def _update_sections(self): """Update plex library section""" for section in self.plex.library.sections(): + if not self._is_wanted_section(section): + continue movie_items = [ item for item in self.media_items @@ -189,31 +193,8 @@ def _update_item(self, item: MediaItem, library_item: MediaItem): item.set("guid", library_item.guid) item.set("key", library_item.key) - def _fix_match(self, library_item: MediaItem, item: MediaItem): - """Internal method to use in match_items method. - It gets plex guid and checks if it matches with plex metadata - for given imdb_id. If it does, it will update the metadata of the plex item.""" - section = next( - section - for section in self.plex.library.sections() - if section.type == item.type - ) - dummy = section.search(maxresults=1)[0] - - if dummy and not section.refreshing: - if item.imdb_id: - try: - match = dummy.matches(agent=section.agent, title=item.imdb_id)[0] - except ReadTimeout: - return False - except IndexError: - return False - if library_item.guid != match.guid: - item_to_update = self.plex.fetchItem(library_item.key) - item_to_update.fixMatch(match) - return True - return False - + def _is_wanted_section(self, section): + return any(self.library_path in location for location in section.locations) def _map_item_from_data(item, item_type): """Map Plex API data to MediaItemContainer.""" diff --git a/backend/program/symlink.py b/backend/program/symlink.py index e21958d8..78fa8c52 100644 --- a/backend/program/symlink.py +++ b/backend/program/symlink.py @@ -20,9 +20,8 @@ def __init__(self, media_items: MediaItemContainer): self.running = False self.media_items = media_items self.cache = {} - self.settings = settings.get("symlink") - self.mount_path = os.path.abspath(self.settings["mount"]) - self.host_path = os.path.abspath(self.settings["host_mount"]) + self.mount_path = os.path.abspath(settings.get("container_mount")) + self.host_path = os.path.abspath(settings.get("host_mount")) if os.path.exists(self.host_path): self.symlink_path = os.path.join(self.host_path, os.pardir, "library") if not os.path.exists(self.symlink_path): diff --git a/backend/utils/default_settings.json b/backend/utils/default_settings.json index d50e378c..2367f5e3 100644 --- a/backend/utils/default_settings.json +++ b/backend/utils/default_settings.json @@ -1,19 +1,15 @@ { "version": "0.2.1", "debug": true, - "service_mode": false, "log": true, - "menu_on_startup": true, + "host_mount": "", + "container_mount": "", "plex": { "user": "", "token": "", "url": "http://localhost:32400", "watchlist": "" }, - "symlink": { - "host_mount": "", - "mount": "" - }, "mdblist": { "lists": [""], "api_key": "",