[ufctv] add support for more domains and remove compatibility code(closes #23332)
authorRemita Amine <remitamine@gmail.com>
Fri, 6 Dec 2019 10:04:12 +0000 (11:04 +0100)
committerRemita Amine <remitamine@gmail.com>
Fri, 6 Dec 2019 10:04:12 +0000 (11:04 +0100)
youtube_dl/extractor/imggaming.py
youtube_dl/extractor/ufctv.py

index 8bb5de4637c3609a4cd0f7c2e10e7e5baa62f3d1..10d26adab5776766b55d59ba8e86361ae47db74a 100644 (file)
@@ -17,19 +17,12 @@ from ..utils import (
 class ImgGamingBaseIE(InfoExtractor):
     _API_BASE = 'https://dce-frontoffice.imggaming.com/api/v2/'
     _API_KEY = '857a1e5d-e35e-4fdf-805b-a87b6f8364bf'
-    _DOMAIN = None
     _HEADERS = None
-    _LOGIN_REQUIRED = True
-    _LOGIN_SUFFIX = ''
     _MANIFEST_HEADERS = {'Accept-Encoding': 'identity'}
     _REALM = None
-    _TOKEN = None
-    _VALID_URL_TEMPL = r'https?://%s/(?P<type>live|playlist|video)/(?P<id>\d+)(?:\?.*?\bplaylistId=(?P<playlist_id>\d+))?'
+    _VALID_URL_TEMPL = r'https?://(?P<domain>(?:(?:app|www)\.)?%s)/(?P<type>live|playlist|video)/(?P<id>\d+)(?:\?.*?\bplaylistId=(?P<playlist_id>\d+))?'
 
     def _real_initialize(self):
-        if not self._LOGIN_REQUIRED:
-            return
-
         self._HEADERS = {
             'Realm': 'dce.' + self._REALM,
             'x-api-key': self._API_KEY,
@@ -42,7 +35,7 @@ class ImgGamingBaseIE(InfoExtractor):
         p_headers = self._HEADERS.copy()
         p_headers['Content-Type'] = 'application/json'
         self._HEADERS['Authorization'] = 'Bearer ' + self._download_json(
-            self._API_BASE + 'login' + self._LOGIN_SUFFIX,
+            self._API_BASE + 'login',
             None, 'Logging in', data=json.dumps({
                 'id': email,
                 'secret': password,
@@ -52,9 +45,6 @@ class ImgGamingBaseIE(InfoExtractor):
         return self._download_json(
             self._API_BASE + path + media_id, media_id, headers=self._HEADERS)
 
-    def _extract_media_id(self, url, display_id):
-        return display_id
-
     def _extract_dve_api_url(self, media_id, media_type):
         stream_path = 'stream'
         if media_type == 'video':
@@ -72,8 +62,7 @@ class ImgGamingBaseIE(InfoExtractor):
             raise
 
     def _real_extract(self, url):
-        media_type, display_id, playlist_id = re.match(self._VALID_URL, url).groups()
-        media_id = self._extract_media_id(url, display_id)
+        domain, media_type, media_id, playlist_id = re.match(self._VALID_URL, url).groups()
 
         if playlist_id:
             if self._downloader.params.get('noplaylist'):
@@ -90,7 +79,7 @@ class ImgGamingBaseIE(InfoExtractor):
                 if not video_id:
                     continue
                 entries.append(self.url_result(
-                    'https://%s/video/%s' % (self._DOMAIN, video_id),
+                    'https://%s/video/%s' % (domain, video_id),
                     self.ie_key(), video_id))
             return self.playlist_result(
                 entries, media_id, playlist.get('title'),
@@ -133,7 +122,6 @@ class ImgGamingBaseIE(InfoExtractor):
 
         return {
             'id': media_id,
-            'display_id': display_id,
             'title': title,
             'formats': formats,
             'thumbnail': video_data.get('thumbnailUrl'),
index d07fa1280dcc6e758c96ddae5985fd92168ecd99..665eb1cb78886d5a5446b643afd93f3a30933eb7 100644 (file)
@@ -5,14 +5,12 @@ from .imggaming import ImgGamingBaseIE
 
 
 class UFCTVIE(ImgGamingBaseIE):
-    _VALID_URL = ImgGamingBaseIE._VALID_URL_TEMPL % r'(?:www\.)?ufc\.tv'
+    _VALID_URL = ImgGamingBaseIE._VALID_URL_TEMPL % r'(?:ufc\.tv|(?:ufc)?fightpass\.com)'
     _NETRC_MACHINE = 'ufctv'
-    _DOMAIN = 'ufc.tv'
     _REALM = 'ufc'
 
 
 class UFCArabiaIE(ImgGamingBaseIE):
-    _VALID_URL = ImgGamingBaseIE._VALID_URL_TEMPL % r'app\.ufcarabia\.com'
+    _VALID_URL = ImgGamingBaseIE._VALID_URL_TEMPL % r'ufcarabia\.(?:ae|com)'
     _NETRC_MACHINE = 'ufcarabia'
-    _DOMAIN = 'app.ufcarabia.com'
     _REALM = 'admufc'