diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index e84d35d4d..17ea7bc09 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -2831,6 +2831,9 @@ def dfxp2srt(dfxp_data): continue default_style.update(style) + last_begin_time = None + last_end_time = None + for para, index in zip(paras, itertools.count(1)): begin_time = parse_dfxp_time_expr(para.attrib.get('begin')) end_time = parse_dfxp_time_expr(para.attrib.get('end')) @@ -2841,12 +2844,20 @@ def dfxp2srt(dfxp_data): if not dur: continue end_time = begin_time + dur - out.append('%d\n%s --> %s\n%s\n\n' % ( - index, - srt_subtitles_timecode(begin_time), - srt_subtitles_timecode(end_time), - parse_node(para))) + if begin_time == last_begin_time and end_time == last_end_time: + out.append('%s\n' % (parse_node(para))) + else: + out.append('\n%d\n%s --> %s\n%s\n' % ( + index, + srt_subtitles_timecode(begin_time), + srt_subtitles_timecode(end_time), + parse_node(para))) + + last_begin_time = begin_time + last_end_time = end_time + + out.append('\n') return ''.join(out)