]> Raphaƫl G. Git Repositories - youtubedl/blobdiff - youtube_dl/extractor/ufctv.py
debian/control: Update list of extractors in long description.
[youtubedl] / youtube_dl / extractor / ufctv.py
index ab823814bfe47ee4d5aa16947aea7450d91829ed..f3eaee6b3f45b71dadb0a1d3310aa3bf9cebf073 100644 (file)
@@ -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={