Fixed episodes or movies importation skipped when Sonarr/Radarr improperly report that media file size is null.

pull/1912/head
morpheus65535 2 years ago
parent 414900c24e
commit 81e13e1eac

@ -1,5 +1,6 @@
# coding=utf-8 # coding=utf-8
import os
import logging import logging
from peewee import IntegrityError from peewee import IntegrityError
@ -69,7 +70,12 @@ def update_movies(send_event=True):
if movie['hasFile'] is True: if movie['hasFile'] is True:
if 'movieFile' in movie: 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 # Add movies in radarr to current movies list
current_movies_radarr.append(str(movie['tmdbId'])) current_movies_radarr.append(str(movie['tmdbId']))

@ -1,5 +1,6 @@
# coding=utf-8 # coding=utf-8
import os
import logging import logging
from peewee import IntegrityError from peewee import IntegrityError
@ -71,7 +72,12 @@ def sync_episodes(series_id=None, send_event=True):
if 'hasFile' in episode: if 'hasFile' in episode:
if episode['hasFile'] is True: if episode['hasFile'] is True:
if 'episodeFile' in episode: 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 # Add episodes in sonarr to current episode list
current_episodes_sonarr.append(episode['id']) current_episodes_sonarr.append(episode['id'])

@ -4,6 +4,7 @@ import os
from app.database import TableShows from app.database import TableShows
from sonarr.info import get_sonarr_info from sonarr.info import get_sonarr_info
from utilities.path_mappings import path_mappings
from .converter import SonarrFormatVideoCodec, SonarrFormatAudioCodec from .converter import SonarrFormatVideoCodec, SonarrFormatAudioCodec
@ -79,7 +80,11 @@ def episodeParser(episode):
if 'hasFile' in episode: if 'hasFile' in episode:
if episode['hasFile'] is True: if episode['hasFile'] is True:
if 'episodeFile' in episode: 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']: if 'sceneName' in episode['episodeFile']:
sceneName = episode['episodeFile']['sceneName'] sceneName = episode['episodeFile']['sceneName']
else: else:

Loading…
Cancel
Save