1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-27 10:07:22 +00:00

no log: subsync memory usage improvement

This commit is contained in:
morpheus65535 2022-02-24 09:19:37 -05:00
parent 0a0f609de8
commit 9c1397a14d
3 changed files with 10 additions and 11 deletions

View file

@ -2,6 +2,7 @@
import os
import sys
import gc
from flask import request
from flask_restful import Resource
@ -9,7 +10,7 @@ from flask_restful import Resource
from database import TableEpisodes, TableMovies
from helper import path_mappings
from ..utils import authenticate
from subsyncer import subsync
from subsyncer import SubSyncer
from utils import translate_subtitles_file, subtitles_apply_mods
from list_subtitles import store_subtitles, store_subtitles_movie
from config import settings
@ -46,6 +47,7 @@ class Subtitles(Resource):
video_path = path_mappings.path_replace_movie(metadata['path'])
if action == 'sync':
subsync = SubSyncer()
if media_type == 'episode':
subsync.sync(video_path=video_path, srt_path=subtitles_path,
srt_lang=language, media_type='series', sonarr_series_id=metadata['sonarrSeriesId'],
@ -53,6 +55,8 @@ class Subtitles(Resource):
else:
subsync.sync(video_path=video_path, srt_path=subtitles_path,
srt_lang=language, media_type='movies', radarr_id=id)
del subsync
gc.collect()
elif action == 'translate':
dest_language = language
forced = True if request.form.get('forced') == 'true' else False

View file

@ -2,9 +2,10 @@
# fmt: off
import logging
import gc
from config import settings
from subsyncer import subsync
from subsyncer import SubSyncer
def sync_subtitles(video_path, srt_path, srt_lang, forced, media_type, percent_score, sonarr_series_id=None,
@ -24,8 +25,11 @@ def sync_subtitles(video_path, srt_path, srt_lang, forced, media_type, percent_s
subsync_threshold = settings.subsync.subsync_movie_threshold
if not use_subsync_threshold or (use_subsync_threshold and percent_score < float(subsync_threshold)):
subsync = SubSyncer()
subsync.sync(video_path=video_path, srt_path=srt_path, srt_lang=srt_lang, media_type=media_type,
sonarr_series_id=sonarr_series_id, sonarr_episode_id=sonarr_episode_id, radarr_id=radarr_id)
del subsync
gc.collect()
return True
else:
logging.debug("BAZARR subsync skipped because subtitles score isn't below this "

View file

@ -1,6 +1,5 @@
import logging
import os
import gc
from ffsubsync.ffsubsync import run, make_parser
from utils import get_binary
from utils import history_log, history_log_movie
@ -61,11 +60,8 @@ class SubSyncer:
except Exception:
logging.exception('BAZARR an exception occurs during the synchronization process for this subtitles: '
'{0}'.format(self.srtin))
gc.collect()
return
else:
if settings.subsync.getboolean('debug'):
gc.collect()
return result
if os.path.isfile(self.srtout):
if not settings.subsync.getboolean('debug'):
@ -89,9 +85,4 @@ class SubSyncer:
else:
logging.error('BAZARR unable to sync subtitles: {0}'.format(self.srtin))
gc.collect()
return result
subsync = SubSyncer()