]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/amp.py
[ie/crunchyroll] Fix stream extraction (#10005)
[yt-dlp.git] / yt_dlp / extractor / amp.py
index 6015baad55e5b1dc6542fd29a840d547354ad8e6..0d259c549fa315f7420d7015eb497dbb1d3f0bd8 100644 (file)
@@ -5,6 +5,7 @@
     int_or_none,
     mimetype2ext,
     parse_iso8601,
+    strip_jsonp,
     unified_timestamp,
     url_or_none,
 )
@@ -15,7 +16,7 @@ class AMPIE(InfoExtractor):  # XXX: Conventionally, base classes should end with
     def _extract_feed_info(self, url):
         feed = self._download_json(
             url, None, 'Downloading Akamai AMP feed',
-            'Unable to download Akamai AMP feed')
+            'Unable to download Akamai AMP feed', transform_source=strip_jsonp)
         item = feed.get('channel', {}).get('item')
         if not item:
             raise ExtractorError('%s said: %s' % (self.IE_NAME, feed['error']))
@@ -73,8 +74,10 @@ def get_media_node(name, default=None):
                     media_url + '?hdcore=3.4.0&plugin=aasp-3.4.0.132.124',
                     video_id, f4m_id='hds', fatal=False))
             elif ext == 'm3u8':
-                formats.extend(self._extract_m3u8_formats(
-                    media_url, video_id, 'mp4', m3u8_id='hls', fatal=False))
+                fmts, subs = self._extract_m3u8_formats_and_subtitles(
+                    media_url, video_id, 'mp4', m3u8_id='hls', fatal=False)
+                formats.extend(fmts)
+                self._merge_subtitles(subs, target=subtitles)
             else:
                 formats.append({
                     'format_id': media_data.get('media-category', {}).get('@attributes', {}).get('label'),
@@ -84,8 +87,6 @@ def get_media_node(name, default=None):
                     'ext': ext,
                 })
 
-        self._sort_formats(formats)
-
         timestamp = unified_timestamp(item.get('pubDate'), ' ') or parse_iso8601(item.get('dc-date'))
 
         return {