]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/nba.py
[ie/patreon] Fix Vimeo embed extraction (#9712)
[yt-dlp.git] / yt_dlp / extractor / nba.py
index 3c678c50d00688c232904b64099210b7e38fdd51..81d11e3a5061a0cc3e490ad7556801f2d2fe1efc 100644 (file)
@@ -1,14 +1,10 @@
-from __future__ import unicode_literals
-
 import functools
 import re
 
 from .turner import TurnerBaseIE
 from ..compat import (
-    compat_parse_qs,
     compat_str,
     compat_urllib_parse_unquote,
-    compat_urllib_parse_urlparse,
 )
 from ..utils import (
     int_or_none,
@@ -16,6 +12,7 @@
     OnDemandPagedList,
     parse_duration,
     parse_iso8601,
+    parse_qs,
     try_get,
     update_url_query,
     urljoin,
@@ -95,13 +92,12 @@ def _extract_video(self, filter_key, filter_value):
                 formats.extend(cvp_info['formats'])
                 info = merge_dicts(info, cvp_info)
 
-        self._sort_formats(formats)
         info['formats'] = formats
         return info
 
 
 class NBAWatchEmbedIE(NBAWatchBaseIE):
-    IENAME = 'nba:watch:embed'
+    IE_NAME = 'nba:watch:embed'
     _VALID_URL = NBAWatchBaseIE._VALID_URL_BASE + r'embed\?.*?\bid=(?P<id>\d+)'
     _TESTS = [{
         'url': 'http://watch.nba.com/embed?id=659395',
@@ -165,15 +161,11 @@ class NBAWatchIE(NBAWatchBaseIE):
 
     def _real_extract(self, url):
         display_id = self._match_id(url)
-        collection_id = compat_parse_qs(compat_urllib_parse_urlparse(url).query).get('collection', [None])[0]
-        if collection_id:
-            if self.get_param('noplaylist'):
-                self.to_screen('Downloading just video %s because of --no-playlist' % display_id)
-            else:
-                self.to_screen('Downloading playlist %s - add --no-playlist to just download video' % collection_id)
-                return self.url_result(
-                    'https://www.nba.com/watch/list/collection/' + collection_id,
-                    NBAWatchCollectionIE.ie_key(), collection_id)
+        collection_id = parse_qs(url).get('collection', [None])[0]
+        if self._yes_playlist(collection_id, display_id):
+            return self.url_result(
+                'https://www.nba.com/watch/list/collection/' + collection_id,
+                NBAWatchCollectionIE.ie_key(), collection_id)
         return self._extract_video('seoName', display_id)
 
 
@@ -325,7 +317,6 @@ def _extract_video(self, video, team, extract_all=True):
                     subtitles = self._merge_subtitles(subtitles, cvp_info['subtitles'])
                     info = merge_dicts(info, cvp_info)
 
-            self._sort_formats(formats)
         else:
             info.update(self._embed_url_result(team, video['videoId']))
 
@@ -348,7 +339,7 @@ def _real_extract(self, url):
 
 
 class NBAEmbedIE(NBABaseIE):
-    IENAME = 'nba:embed'
+    IE_NAME = 'nba:embed'
     _VALID_URL = r'https?://secure\.nba\.com/assets/amp/include/video/(?:topI|i)frame\.html\?.*?\bcontentId=(?P<id>[^?#&]+)'
     _TESTS = [{
         'url': 'https://secure.nba.com/assets/amp/include/video/topIframe.html?contentId=teams/bulls/2020/12/04/3478774/1607105587854-20201204_SCHEDULE_RELEASE_FINAL_DRUPAL-3478774&team=bulls&adFree=false&profile=71&videoPlayerName=TAMPCVP&baseUrl=&videoAdsection=nba.com_mobile_web_teamsites_chicagobulls&ampEnv=',
@@ -359,7 +350,7 @@ class NBAEmbedIE(NBABaseIE):
     }]
 
     def _real_extract(self, url):
-        qs = compat_parse_qs(compat_urllib_parse_urlparse(url).query)
+        qs = parse_qs(url)
         content_id = qs['contentId'][0]
         team = qs.get('team', [None])[0]
         if not team:
@@ -370,7 +361,7 @@ def _real_extract(self, url):
 
 
 class NBAIE(NBABaseIE):
-    IENAME = 'nba'
+    IE_NAME = 'nba'
     _VALID_URL = NBABaseIE._VALID_URL_BASE + '(?!%s)video/(?P<id>(?:[^/]+/)*[^/?#&]+)' % NBABaseIE._CHANNEL_PATH_REGEX
     _TESTS = [{
         'url': 'https://www.nba.com/bulls/video/teams/bulls/2020/12/04/3478774/1607105587854-20201204schedulereleasefinaldrupal-3478774',
@@ -397,7 +388,7 @@ def _extract_url_results(self, team, content_id):
 
 
 class NBAChannelIE(NBABaseIE):
-    IENAME = 'nba:channel'
+    IE_NAME = 'nba:channel'
     _VALID_URL = NBABaseIE._VALID_URL_BASE + '(?:%s)/(?P<id>[^/?#&]+)' % NBABaseIE._CHANNEL_PATH_REGEX
     _TESTS = [{
         'url': 'https://www.nba.com/blazers/video/channel/summer_league',