added condition to initialize empty translation language list when translationLanugage key is missing
This commit is contained in:
		
							parent
							
								
									d7af83feeb
								
							
						
					
					
						commit
						7ab2a9e4a5
					
				|  | @ -134,7 +134,7 @@ class TranscriptList(object): | |||
|             { | ||||
|                 'language': translation_language['languageName']['simpleText'], | ||||
|                 'language_code': translation_language['languageCode'], | ||||
|             } for translation_language in captions_json['translationLanguages'] | ||||
|             } for translation_language in captions_json.get('translationLanguages', []) | ||||
|         ] | ||||
| 
 | ||||
|         manually_created_transcripts = {} | ||||
|  |  | |||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							|  | @ -108,6 +108,19 @@ class TestYouTubeTranscriptApi(TestCase): | |||
|         with self.assertRaises(InvalidVideoId): | ||||
|             YouTubeTranscriptApi.list_transcripts('https://www.youtube.com/watch?v=GJLlxj_dtq8') | ||||
| 
 | ||||
| 
 | ||||
|     def test_list_transcripts__no_translation_languages_provided(self): | ||||
|         httpretty.register_uri( | ||||
|             httpretty.GET, | ||||
|             'https://www.youtube.com/watch', | ||||
|             body=load_asset('youtube_no_translation_languages.html.static') | ||||
|         ) | ||||
| 
 | ||||
|         transcript_list = YouTubeTranscriptApi.list_transcripts('GJLlxj_dtq8') | ||||
|         for transcript in transcript_list: | ||||
|             self.assertEqual(len(transcript.translation_languages), 0) | ||||
| 
 | ||||
| 
 | ||||
|     def test_translate_transcript(self): | ||||
|         transcript = YouTubeTranscriptApi.list_transcripts('GJLlxj_dtq8').find_transcript(['en']) | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue