Merge pull request #1215 from croneter/fix-subtitle-download

Fix playback failing due to caching of subtitles with non-ascii chars
This commit is contained in:
croneter 2020-09-19 20:45:21 +02:00 committed by GitHub
commit 249c0993e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -261,10 +261,19 @@ class Media(object):
if int(stream.get('streamType')) != 3 or 'key' not in stream.attrib: if int(stream.get('streamType')) != 3 or 'key' not in stream.attrib:
# Not a subtitle or not not an external subtitle # Not a subtitle or not not an external subtitle
continue continue
try:
path = self.download_external_subtitles( path = self.download_external_subtitles(
'{server}%s' % stream.get('key'), '{server}%s' % stream.get('key'),
stream.get('displayTitle'), stream.get('displayTitle'),
stream.get('codec')) stream.get('codec'))
except IOError:
# Catch "IOError: [Errno 22] invalid mode ('wb') or filename"
# Due to stream.get('displayTitle') returning chars that our
# OS is not supporting, e.g. "српски језик (SRT External)"
path = self.download_external_subtitles(
'{server}%s' % stream.get('key'),
stream.get('languageCode', 'Unknown'),
stream.get('codec'))
if path: if path:
externalsubs.append(path) externalsubs.append(path)
LOG.info('Found external subs: %s', externalsubs) LOG.info('Found external subs: %s', externalsubs)