Merge pull request #20 from jdepoix/bugfix/ISSUE-19

fixed bug reported in ISSUE-19
This commit is contained in:
jdepoix 2019-07-22 13:14:25 +02:00 committed by GitHub
commit 9d302d679d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 1 deletions

View File

@ -151,4 +151,5 @@ class _TranscriptParser():
'duration': float(xml_element.attrib['dur']),
}
for xml_element in ElementTree.fromstring(self.plain_data)
if xml_element.text is not None
]

View File

@ -27,7 +27,7 @@ class YouTubeTranscriptCli():
return '\n\n'.join(
[str(YouTubeTranscriptApi.CouldNotRetrieveTranscript(video_id)) for video_id in unretrievable_videos]
+ [json.dumps(transcripts) if parsed_args.json else pprint.pformat(transcripts)]
+ ([json.dumps(transcripts) if parsed_args.json else pprint.pformat(transcripts)] if transcripts else [])
)
def _parse_args(self):

View File

@ -2,5 +2,6 @@
<transcript>
<text start="0" dur="1.54">Hey, this is just a test</text>
<text start="1.54" dur="4.16">this is not the original transcript</text>
<text start="5" dur="0.5"></text>
<text start="5.7" dur="3.239">just something shorter, I made up for testing</text>
</transcript>