Merge pull request #137 from xenova/master
Raise `TranscriptsDisabled` if 'playerCaptionsTracklistRenderer' is not found (Fixes #136)
This commit is contained in:
commit
161be4a422
|
@ -60,7 +60,9 @@ class TranscriptListFetcher(object):
|
|||
|
||||
captions_json = json.loads(
|
||||
splitted_html[1].split(',"videoDetails')[0].replace('\n', '')
|
||||
)['playerCaptionsTracklistRenderer']
|
||||
).get('playerCaptionsTracklistRenderer')
|
||||
if captions_json is None:
|
||||
raise TranscriptsDisabled(video_id)
|
||||
|
||||
if 'captionTracks' not in captions_json:
|
||||
raise NoTranscriptAvailable(video_id)
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -205,6 +205,14 @@ class TestYouTubeTranscriptApi(TestCase):
|
|||
with self.assertRaises(TranscriptsDisabled):
|
||||
YouTubeTranscriptApi.get_transcript('dsMFmonKDD4')
|
||||
|
||||
httpretty.register_uri(
|
||||
httpretty.GET,
|
||||
'https://www.youtube.com/watch',
|
||||
body=load_asset('youtube_transcripts_disabled2.html.static')
|
||||
)
|
||||
with self.assertRaises(TranscriptsDisabled):
|
||||
YouTubeTranscriptApi.get_transcript('Fjg5lYqvzUs')
|
||||
|
||||
def test_get_transcript__exception_if_language_unavailable(self):
|
||||
with self.assertRaises(NoTranscriptFound):
|
||||
YouTubeTranscriptApi.get_transcript('GJLlxj_dtq8', languages=['cz'])
|
||||
|
|
Loading…
Reference in New Issue