summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorJayZed <[email protected]>2024-01-23 19:59:09 -0500
committerGitHub <[email protected]>2024-01-23 19:59:09 -0500
commit345408d692b6cd6917a0a0db786c1b0af3ed809c (patch)
tree73e1aba625fb0060db6ea441226ddedf3dea8140 /libs
parente17865ad535da06caddb25cfff30961cecae20f1 (diff)
downloadbazarr-345408d692b6cd6917a0a0db786c1b0af3ed809c.tar.gz
bazarr-345408d692b6cd6917a0a0db786c1b0af3ed809c.zip
Fixed wizdom provider to handle Zip files with more than one (up to two entries). #2351
Diffstat (limited to 'libs')
-rw-r--r--libs/subliminal_patch/providers/wizdom.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/libs/subliminal_patch/providers/wizdom.py b/libs/subliminal_patch/providers/wizdom.py
index 12666f541..4091b7ad8 100644
--- a/libs/subliminal_patch/providers/wizdom.py
+++ b/libs/subliminal_patch/providers/wizdom.py
@@ -213,7 +213,12 @@ class WizdomProvider(Provider):
with zipfile.ZipFile(io.BytesIO(r.content)) as zf:
# remove some filenames from the namelist
namelist = [n for n in zf.namelist() if os.path.splitext(n)[1] in ['.srt', '.sub']]
- if len(namelist) > 1:
- raise ProviderError('More than one file to unzip')
-
- subtitle.content = fix_line_ending(zf.read(namelist[0]))
+ if len(namelist) > 0:
+ subtitle.content = fix_line_ending(zf.read(namelist[0]))
+ # this provider sometimes returns both utf-8 and windows-1255 encodings of the same text in one zip file
+ if len(namelist) > 1:
+ # check if the first one we downloaded is good
+ valid = subtitle.is_valid()
+ if not valid:
+ # in case we can't use the first one, return the second one and hope for the best
+ subtitle.content = fix_line_ending(zf.read(namelist[1]))