Skip to content

Commit

Permalink
Fix for provider subtitle language being unintentionally modified
Browse files Browse the repository at this point in the history
This prevents unwanted changes to the provider copy of the language.
Thanks to @vitiko98 for suggesting a better place for this fix.
  • Loading branch information
JaiZed authored Aug 6, 2024
1 parent 866b1d5 commit 5582cc0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions custom_libs/subliminal_patch/subtitle.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import pysrt
import pysubs2
from bs4 import UnicodeDammit
from copy import deepcopy
from pysubs2 import SSAStyle
from pysubs2.formats.subrip import parse_tags, MAX_REPRESENTABLE_TIME
from pysubs2.time import ms_to_times
Expand Down Expand Up @@ -65,6 +66,11 @@ class Subtitle(Subtitle_):
# format = "srt" # default format is srt

def __init__(self, language, hearing_impaired=False, page_link=None, encoding=None, mods=None, original_format=False):
# language needs to be cloned because it is actually a reference to the provider language object
# if a new copy is not created then all subsequent subtitles for this provider will incorrectly be modified
# at least until Bazarr is restarted or the provider language object is recreated somehow
language = deepcopy(language)

# set subtitle language to hi if it's hearing_impaired
if hearing_impaired:
language = Language.rebuild(language, hi=True)
Expand Down

0 comments on commit 5582cc0

Please sign in to comment.