]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/piksel.py
[utils] Add `join_nonempty`
[yt-dlp.git] / yt_dlp / extractor / piksel.py
index ecf56ff8f69588b08fc578234f116b1372953cdf..84c3de2f0e76e159705d34c27775a9cc003b5953 100644 (file)
@@ -4,11 +4,11 @@
 import re
 
 from .common import InfoExtractor
-from ..compat import compat_str
 from ..utils import (
     dict_get,
     ExtractorError,
     int_or_none,
+    join_nonempty,
     parse_iso8601,
     try_get,
     unescapeHTML,
@@ -85,7 +85,7 @@ def _call_api(self, app_token, resource, display_id, query, fatal=True):
         return response
 
     def _real_extract(self, url):
-        ref_id, display_id = re.match(self._VALID_URL, url).groups()
+        ref_id, display_id = self._match_valid_url(url).groups()
         webpage = self._download_webpage(url, display_id)
         app_token = self._search_regex([
             r'clientAPI\s*:\s*"([^"]+)"',
@@ -116,12 +116,8 @@ def process_asset_file(asset_file):
             elif asset_type == 'audio':
                 tbr = abr
 
-            format_id = ['http']
-            if tbr:
-                format_id.append(compat_str(tbr))
-
             formats.append({
-                'format_id': '-'.join(format_id),
+                'format_id': join_nonempty('http', tbr),
                 'url': unescapeHTML(http_url),
                 'vbr': vbr,
                 'abr': abr,
@@ -167,7 +163,7 @@ def process_asset_files(asset_files):
                 re.sub(r'/od/[^/]+/', '/od/http/', smil_url), video_id,
                 transform_source=transform_source, fatal=False))
 
-        self._sort_formats(formats)
+        self._sort_formats(formats, ('tbr', ))  # Incomplete resolution information
 
         subtitles = {}
         for caption in video_data.get('captions', []):