1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-26 18:34:32 +01:00

Simplified json parsing logic

This commit is contained in:
Ben Bryant 2020-04-20 00:26:15 -07:00
parent d4e94cb110
commit 460d7aef86

View File

@ -159,12 +159,10 @@ class FunimationIE(InfoExtractor):
def get_subtitles(self, url, video_id, display_id): def get_subtitles(self, url, video_id, display_id):
player_url = urljoin(url, '/player/' + video_id) player_url = urljoin(url, '/player/' + video_id)
player_page = self._download_webpage(player_url, display_id) player_page = self._download_webpage(player_url, display_id)
text_tracks_search = self._search_regex( text_tracks_json_string = self._search_regex(
r'("textTracks": \[{.+?}\])', r'"textTracks": (\[{.+?}\])',
player_page, 'player data', default='') player_page, 'player data', default='')
text_tracks_search = '{' + text_tracks_search + '}' text_tracks = self._parse_json(text_tracks_json_string, display_id, js_to_json, fatal=False) or []
player_json = self._parse_json(text_tracks_search, display_id, js_to_json, fatal=False) or {}
text_tracks = player_json.get('textTracks', [])
subtitles = {} subtitles = {}
for text_track in text_tracks: for text_track in text_tracks:
data = {'url': text_track['src']} data = {'url': text_track['src']}