diff --git a/README.md b/README.md index 6854568..db60fa6 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ Syncs two Radarr/Sonarr/Lidarr servers through the web API. Useful for syncing a * Supports Docker for multiple instances * Can set interval for syncing * Support two way sync (one way by default) +* Skip content with missing files * Set language profiles (Sonarr v3 only) * Filter syncing by content file quality (Radarr only) * Filter syncing by tags (Sonarr/Radarr v3 only) @@ -76,6 +77,7 @@ Syncs two Radarr/Sonarr/Lidarr servers through the web API. Useful for syncing a [general] sync_bidirectionally = 1 # sync from instance A to B **AND** instance B to A auto_search = 0 # search is automatically started on new content - disable by setting to 0 (default 1) + skip_missing = 1 # content with missing files are skipped on sync - disable by setting to 0 (default 1) monitor_new_content = 0 # set to 0 to never monitor new content synced or to 1 to always monitor new content synced (default 1) test_run = 1 # enable test mode - will run through sync program but will not actually sync content ``` diff --git a/config.py b/config.py index a415f32..711451e 100644 --- a/config.py +++ b/config.py @@ -170,6 +170,16 @@ if auto_search is not None: else: auto_search = 1 +# set to skip missing if config not set +skip_missing = get_config_value('SYNCARR_SKIP_MISSING', 'skip_missing', 'general') +if skip_missing is not None: + try: + skip_missing = int(skip_missing) + except ValueError: + skip_missing = 0 +else: + skip_missing = 1 + # set to monitor if config not set monitor_new_content = get_config_value('SYNCARR_MONITOR_NEW_CONTENT', 'monitor_new_content', 'general') if monitor_new_content is not None: @@ -497,6 +507,7 @@ logger.debug({ 'monitor_new_content': monitor_new_content, 'sync_bidirectionally': sync_bidirectionally, 'auto_search': auto_search, + 'skip_missing': skip_missing, 'api_version': api_version, }) diff --git a/index.py b/index.py index 6950d7c..49fd935 100644 --- a/index.py +++ b/index.py @@ -25,7 +25,7 @@ from config import ( get_status_path, get_content_path, get_profile_path, get_language_path, get_tag_path, is_in_docker, instance_sync_interval_seconds, - sync_bidirectionally, auto_search, monitor_new_content, + sync_bidirectionally, auto_search, skip_missing, monitor_new_content, tested_api_version, api_version, V3_API_PATH, is_test_run, ) @@ -207,6 +207,13 @@ def sync_servers(instanceA_contents, instanceB_language_id, instanceB_contentIds title = content.get('title') or content.get('artistName') instance_path = instanceB_path or dirname(content.get('path')) + # if skipping missing files, we want to skip any that don't have files + if skip_missing: + content_has_file = content.get('hasFile') + if not content_has_file: + logging.debug(f'Skipping content {title} - file missing') + continue + # if given this, we want to filter from instance by profile id if instanceA_profile_filter_id: quality_profile_id = content.get('qualityProfileId')