mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2024-11-22 16:44:32 +01:00
[ufctv] add support for authentication(closes #16542)
This commit is contained in:
parent
8b1da46e8f
commit
ec2f3d2800
@ -3,13 +3,16 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
ExtractorError,
|
||||||
parse_duration,
|
parse_duration,
|
||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
|
urlencode_postdata,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class UFCTVIE(InfoExtractor):
|
class UFCTVIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?ufc\.tv/video/(?P<id>[^/]+)'
|
_VALID_URL = r'https?://(?:www\.)?ufc\.tv/video/(?P<id>[^/]+)'
|
||||||
|
_NETRC_MACHINE = 'ufctv'
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'https://www.ufc.tv/video/ufc-219-countdown-full-episode',
|
'url': 'https://www.ufc.tv/video/ufc-219-countdown-full-episode',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
@ -26,6 +29,21 @@ class UFCTVIE(InfoExtractor):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _real_initialize(self):
|
||||||
|
username, password = self._get_login_info()
|
||||||
|
if username is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
code = self._download_json(
|
||||||
|
'https://www.ufc.tv/secure/authenticate',
|
||||||
|
None, 'Logging in', data=urlencode_postdata({
|
||||||
|
'username': username,
|
||||||
|
'password': password,
|
||||||
|
'format': 'json',
|
||||||
|
})).get('code')
|
||||||
|
if code and code != 'loginsuccess':
|
||||||
|
raise ExtractorError(code, expected=True)
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
display_id = self._match_id(url)
|
display_id = self._match_id(url)
|
||||||
video_data = self._download_json(url, display_id, query={
|
video_data = self._download_json(url, display_id, query={
|
||||||
|
Loading…
Reference in New Issue
Block a user