From 81e13e1eac1d2bdbd9ee10ca79d59feb01d09159 Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Wed, 27 Jul 2022 22:58:26 -0400 Subject: [PATCH] Fixed episodes or movies importation skipped when Sonarr/Radarr improperly report that media file size is null. --- bazarr/radarr/sync/movies.py | 8 +++++++- bazarr/sonarr/sync/episodes.py | 8 +++++++- bazarr/sonarr/sync/parser.py | 7 ++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/bazarr/radarr/sync/movies.py b/bazarr/radarr/sync/movies.py index f0578d66c..dd7fcd681 100644 --- a/bazarr/radarr/sync/movies.py +++ b/bazarr/radarr/sync/movies.py @@ -1,5 +1,6 @@ # coding=utf-8 +import os import logging from peewee import IntegrityError @@ -69,7 +70,12 @@ def update_movies(send_event=True): if movie['hasFile'] is True: if 'movieFile' in movie: - if movie['movieFile']['size'] > 20480: + try: + bazarr_file_size = \ + os.path.getsize(path_mappings.path_replace_movie(movie['movieFile']['path'])) + except OSError: + bazarr_file_size = 0 + if movie['movieFile']['size'] > 20480 or bazarr_file_size > 20480: # Add movies in radarr to current movies list current_movies_radarr.append(str(movie['tmdbId'])) diff --git a/bazarr/sonarr/sync/episodes.py b/bazarr/sonarr/sync/episodes.py index 0ea1a7124..9daa04282 100644 --- a/bazarr/sonarr/sync/episodes.py +++ b/bazarr/sonarr/sync/episodes.py @@ -1,5 +1,6 @@ # coding=utf-8 +import os import logging from peewee import IntegrityError @@ -71,7 +72,12 @@ def sync_episodes(series_id=None, send_event=True): if 'hasFile' in episode: if episode['hasFile'] is True: if 'episodeFile' in episode: - if episode['episodeFile']['size'] > 20480: + try: + bazarr_file_size = \ + os.path.getsize(path_mappings.path_replace(episode['episodeFile']['path'])) + except OSError: + bazarr_file_size = 0 + if episode['episodeFile']['size'] > 20480 or bazarr_file_size > 20480: # Add episodes in sonarr to current episode list current_episodes_sonarr.append(episode['id']) diff --git a/bazarr/sonarr/sync/parser.py b/bazarr/sonarr/sync/parser.py index 47b5214da..47ca9f4ff 100644 --- a/bazarr/sonarr/sync/parser.py +++ b/bazarr/sonarr/sync/parser.py @@ -4,6 +4,7 @@ import os from app.database import TableShows from sonarr.info import get_sonarr_info +from utilities.path_mappings import path_mappings from .converter import SonarrFormatVideoCodec, SonarrFormatAudioCodec @@ -79,7 +80,11 @@ def episodeParser(episode): if 'hasFile' in episode: if episode['hasFile'] is True: if 'episodeFile' in episode: - if episode['episodeFile']['size'] > 20480: + try: + bazarr_file_size = os.path.getsize(path_mappings.path_replace(episode['episodeFile']['path'])) + except OSError: + bazarr_file_size = 0 + if episode['episodeFile']['size'] > 20480 or bazarr_file_size > 20480: if 'sceneName' in episode['episodeFile']: sceneName = episode['episodeFile']['sceneName'] else: