mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-28 02:27:28 +00:00
no log: subsync memory usage improvement
This commit is contained in:
parent
0a0f609de8
commit
9c1397a14d
3 changed files with 10 additions and 11 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import gc
|
||||||
|
|
||||||
from flask import request
|
from flask import request
|
||||||
from flask_restful import Resource
|
from flask_restful import Resource
|
||||||
|
@ -9,7 +10,7 @@ from flask_restful import Resource
|
||||||
from database import TableEpisodes, TableMovies
|
from database import TableEpisodes, TableMovies
|
||||||
from helper import path_mappings
|
from helper import path_mappings
|
||||||
from ..utils import authenticate
|
from ..utils import authenticate
|
||||||
from subsyncer import subsync
|
from subsyncer import SubSyncer
|
||||||
from utils import translate_subtitles_file, subtitles_apply_mods
|
from utils import translate_subtitles_file, subtitles_apply_mods
|
||||||
from list_subtitles import store_subtitles, store_subtitles_movie
|
from list_subtitles import store_subtitles, store_subtitles_movie
|
||||||
from config import settings
|
from config import settings
|
||||||
|
@ -46,6 +47,7 @@ class Subtitles(Resource):
|
||||||
video_path = path_mappings.path_replace_movie(metadata['path'])
|
video_path = path_mappings.path_replace_movie(metadata['path'])
|
||||||
|
|
||||||
if action == 'sync':
|
if action == 'sync':
|
||||||
|
subsync = SubSyncer()
|
||||||
if media_type == 'episode':
|
if media_type == 'episode':
|
||||||
subsync.sync(video_path=video_path, srt_path=subtitles_path,
|
subsync.sync(video_path=video_path, srt_path=subtitles_path,
|
||||||
srt_lang=language, media_type='series', sonarr_series_id=metadata['sonarrSeriesId'],
|
srt_lang=language, media_type='series', sonarr_series_id=metadata['sonarrSeriesId'],
|
||||||
|
@ -53,6 +55,8 @@ class Subtitles(Resource):
|
||||||
else:
|
else:
|
||||||
subsync.sync(video_path=video_path, srt_path=subtitles_path,
|
subsync.sync(video_path=video_path, srt_path=subtitles_path,
|
||||||
srt_lang=language, media_type='movies', radarr_id=id)
|
srt_lang=language, media_type='movies', radarr_id=id)
|
||||||
|
del subsync
|
||||||
|
gc.collect()
|
||||||
elif action == 'translate':
|
elif action == 'translate':
|
||||||
dest_language = language
|
dest_language = language
|
||||||
forced = True if request.form.get('forced') == 'true' else False
|
forced = True if request.form.get('forced') == 'true' else False
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
# fmt: off
|
# fmt: off
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import gc
|
||||||
|
|
||||||
from config import settings
|
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,
|
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
|
subsync_threshold = settings.subsync.subsync_movie_threshold
|
||||||
|
|
||||||
if not use_subsync_threshold or (use_subsync_threshold and percent_score < float(subsync_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,
|
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)
|
sonarr_series_id=sonarr_series_id, sonarr_episode_id=sonarr_episode_id, radarr_id=radarr_id)
|
||||||
|
del subsync
|
||||||
|
gc.collect()
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
logging.debug("BAZARR subsync skipped because subtitles score isn't below this "
|
logging.debug("BAZARR subsync skipped because subtitles score isn't below this "
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import gc
|
|
||||||
from ffsubsync.ffsubsync import run, make_parser
|
from ffsubsync.ffsubsync import run, make_parser
|
||||||
from utils import get_binary
|
from utils import get_binary
|
||||||
from utils import history_log, history_log_movie
|
from utils import history_log, history_log_movie
|
||||||
|
@ -61,11 +60,8 @@ class SubSyncer:
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.exception('BAZARR an exception occurs during the synchronization process for this subtitles: '
|
logging.exception('BAZARR an exception occurs during the synchronization process for this subtitles: '
|
||||||
'{0}'.format(self.srtin))
|
'{0}'.format(self.srtin))
|
||||||
gc.collect()
|
|
||||||
return
|
|
||||||
else:
|
else:
|
||||||
if settings.subsync.getboolean('debug'):
|
if settings.subsync.getboolean('debug'):
|
||||||
gc.collect()
|
|
||||||
return result
|
return result
|
||||||
if os.path.isfile(self.srtout):
|
if os.path.isfile(self.srtout):
|
||||||
if not settings.subsync.getboolean('debug'):
|
if not settings.subsync.getboolean('debug'):
|
||||||
|
@ -89,9 +85,4 @@ class SubSyncer:
|
||||||
else:
|
else:
|
||||||
logging.error('BAZARR unable to sync subtitles: {0}'.format(self.srtin))
|
logging.error('BAZARR unable to sync subtitles: {0}'.format(self.srtin))
|
||||||
|
|
||||||
gc.collect()
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
subsync = SubSyncer()
|
|
||||||
|
|
Loading…
Reference in a new issue