mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-25 11:41:52 +00:00
[pluralsight] Fix subtitles conversion (closes #10990)
This commit is contained in:
parent
e034cbc581
commit
425f3fdfcb
1 changed files with 7 additions and 3 deletions
|
@ -11,6 +11,7 @@ from ..compat import (
|
||||||
compat_urlparse,
|
compat_urlparse,
|
||||||
)
|
)
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
dict_get,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
float_or_none,
|
float_or_none,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
|
@ -119,14 +120,17 @@ class PluralsightIE(PluralsightBaseIE):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _convert_subtitles(duration, subs):
|
def _convert_subtitles(duration, subs):
|
||||||
srt = ''
|
srt = ''
|
||||||
|
TIME_OFFSET_KEYS = ('displayTimeOffset', 'DisplayTimeOffset')
|
||||||
|
TEXT_KEYS = ('text', 'Text')
|
||||||
for num, current in enumerate(subs):
|
for num, current in enumerate(subs):
|
||||||
current = subs[num]
|
current = subs[num]
|
||||||
start, text = float_or_none(
|
start, text = (
|
||||||
current.get('DisplayTimeOffset')), current.get('Text')
|
float_or_none(dict_get(current, TIME_OFFSET_KEYS)),
|
||||||
|
dict_get(current, TEXT_KEYS))
|
||||||
if start is None or text is None:
|
if start is None or text is None:
|
||||||
continue
|
continue
|
||||||
end = duration if num == len(subs) - 1 else float_or_none(
|
end = duration if num == len(subs) - 1 else float_or_none(
|
||||||
subs[num + 1].get('DisplayTimeOffset'))
|
dict_get(subs[num + 1], TIME_OFFSET_KEYS))
|
||||||
if end is None:
|
if end is None:
|
||||||
continue
|
continue
|
||||||
srt += os.linesep.join(
|
srt += os.linesep.join(
|
||||||
|
|
Loading…
Reference in a new issue