]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/adultswim.py
[ie/mlbtv] Fix extraction (#10296)
[yt-dlp.git] / yt_dlp / extractor / adultswim.py
index 8d1d9ac7da1bbd1c4b61d903010fa766adf13993..2c83701e785a7015a4ee6c5827fa44c183678d7e 100644 (file)
@@ -1,8 +1,4 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
 import json
-import re
 
 from .turner import TurnerBaseIE
 from ..utils import (
@@ -89,13 +85,13 @@ class AdultSwimIE(TurnerBaseIE):
     }]
 
     def _real_extract(self, url):
-        show_path, episode_path = re.match(self._VALID_URL, url).groups()
+        show_path, episode_path = self._match_valid_url(url).groups()
         display_id = episode_path or show_path
         query = '''query {
   getShowBySlug(slug:"%s") {
     %%s
   }
-}''' % show_path
+}''' % show_path  # noqa: UP031
         if episode_path:
             query = query % '''title
     getVideoBySlug(slug:"%s") {
@@ -111,7 +107,6 @@ def _real_extract(self, url):
       title
       tvRating
     }''' % episode_path
-            ['getVideoBySlug']
         else:
             query = query % '''metaDescription
     title
@@ -133,7 +128,7 @@ def _real_extract(self, url):
             episode_title = title = video_data['title']
             series = show_data.get('title')
             if series:
-                title = '%s - %s' % (series, title)
+                title = f'{series} - {title}'
             info = {
                 'id': video_id,
                 'title': title,
@@ -174,8 +169,10 @@ def _real_extract(self, url):
                         continue
                     ext = determine_ext(asset_url, mimetype2ext(asset.get('mime_type')))
                     if ext == 'm3u8':
-                        info['formats'].extend(self._extract_m3u8_formats(
-                            asset_url, video_id, 'mp4', m3u8_id='hls', fatal=False))
+                        fmts, subs = self._extract_m3u8_formats_and_subtitles(
+                            asset_url, video_id, 'mp4', m3u8_id='hls', fatal=False)
+                        info['formats'].extend(fmts)
+                        self._merge_subtitles(subs, target=info['subtitles'])
                     elif ext == 'f4m':
                         continue
                         # info['formats'].extend(self._extract_f4m_formats(
@@ -184,7 +181,6 @@ def _real_extract(self, url):
                         info['subtitles'].setdefault('en', []).append({
                             'url': asset_url,
                         })
-            self._sort_formats(info['formats'])
 
             return info
         else:
@@ -195,7 +191,7 @@ def _real_extract(self, url):
                 if not slug:
                     continue
                 entries.append(self.url_result(
-                    'http://adultswim.com/videos/%s/%s' % (show_path, slug),
+                    f'http://adultswim.com/videos/{show_path}/{slug}',
                     'AdultSwim', video.get('_id')))
             return self.playlist_result(
                 entries, show_path, show_data.get('title'),