[ufctv] add support for more domains and remove compatibility code(closes #23332)

This commit is contained in:
Remita Amine 2019-12-06 11:04:12 +01:00
parent 7d53fa475a
commit 4067a23270
2 changed files with 6 additions and 20 deletions

View File

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

View File

@ -5,14 +5,12 @@ from .imggaming import ImgGamingBaseIE
class UFCTVIE(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' _NETRC_MACHINE = 'ufctv'
_DOMAIN = 'ufc.tv'
_REALM = 'ufc' _REALM = 'ufc'
class UFCArabiaIE(ImgGamingBaseIE): 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' _NETRC_MACHINE = 'ufcarabia'
_DOMAIN = 'app.ufcarabia.com'
_REALM = 'admufc' _REALM = 'admufc'