diff --git a/youtube_transcript_api/_api.py b/youtube_transcript_api/_api.py index 3cd602a..ef33e01 100644 --- a/youtube_transcript_api/_api.py +++ b/youtube_transcript_api/_api.py @@ -133,8 +133,8 @@ class YouTubeTranscriptApi(): Formatter = formats.get_formatter(format) transcript = cls.list_transcripts( video_id,proxies, cookies).find_transcript(languages).fetch() - return ''.join(Formatter.format(transcript)) - + return Formatter.format(transcript) + @classmethod def _load_cookies(cls, cookies, video_id): cookie_jar = {} diff --git a/youtube_transcript_api/test/test_api.py b/youtube_transcript_api/test/test_api.py index dc552d4..3a09a63 100644 --- a/youtube_transcript_api/test/test_api.py +++ b/youtube_transcript_api/test/test_api.py @@ -50,11 +50,11 @@ class TestYouTubeTranscriptApi(TestCase): self.assertEqual( transcript, - json.dumps([ + [ {'text': 'Hey, this is just a test', 'start': 0.0, 'duration': 1.54}, {'text': 'this is not the original transcript', 'start': 1.54, 'duration': 4.16}, {'text': 'just something shorter, I made up for testing', 'start': 5.7, 'duration': 3.239} - ]) + ] ) def test_list_transcripts(self): @@ -165,11 +165,11 @@ class TestYouTubeTranscriptApi(TestCase): ) self.assertEqual( transcript, - json.dumps([ + [ {'text': 'Hey, this is just a test', 'start': 0.0, 'duration': 1.54}, {'text': 'this is not the original transcript', 'start': 1.54, 'duration': 4.16}, {'text': 'just something shorter, I made up for testing', 'start': 5.7, 'duration': 3.239} - ]) + ] ) def test_get_transcript__with_cookies(self): @@ -179,11 +179,11 @@ class TestYouTubeTranscriptApi(TestCase): self.assertEqual( transcript, - json.dumps([ + [ {'text': 'Hey, this is just a test', 'start': 0.0, 'duration': 1.54}, {'text': 'this is not the original transcript', 'start': 1.54, 'duration': 4.16}, {'text': 'just something shorter, I made up for testing', 'start': 5.7, 'duration': 3.239} - ]) + ] ) @patch('youtube_transcript_api.YouTubeTranscriptApi.get_transcript')