diff options
author | Remita Amine <remitamine@gmail.com> | 2018-05-26 15:34:36 +0100 |
---|---|---|
committer | Remita Amine <remitamine@gmail.com> | 2018-05-26 16:13:54 +0100 |
commit | ec2f3d2800185920629a7e6946701edebbf14dd6 (patch) | |
tree | a65eee85228778f75150e5791b0d2d4cffc06702 /youtube_dl | |
parent | 8b1da46e8f6dd0de790a54a4809d224041262537 (diff) |
[ufctv] add support for authentication(closes #16542)
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/extractor/ufctv.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/youtube_dl/extractor/ufctv.py b/youtube_dl/extractor/ufctv.py index ab823814b..f3eaee6b3 100644 --- a/youtube_dl/extractor/ufctv.py +++ b/youtube_dl/extractor/ufctv.py @@ -3,13 +3,16 @@ from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( + ExtractorError, parse_duration, parse_iso8601, + urlencode_postdata, ) class UFCTVIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?ufc\.tv/video/(?P<id>[^/]+)' + _NETRC_MACHINE = 'ufctv' _TEST = { 'url': 'https://www.ufc.tv/video/ufc-219-countdown-full-episode', '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): display_id = self._match_id(url) video_data = self._download_json(url, display_id, query={ |