aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor
diff options
context:
space:
mode:
authorRemita Amine <remitamine@gmail.com>2017-12-30 00:30:15 +0100
committerRemita Amine <remitamine@gmail.com>2017-12-30 00:30:41 +0100
commitd97cb84b313f94da76bff0520392334e753e2238 (patch)
tree9443536afa71b0de32cc72d09d5356e31bcebfc1 /youtube_dl/extractor
parent2c8e11b4af253fec9096a800ccd26b4daef521a1 (diff)
[ufctv] Add new extractor(closes #14520)
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r--youtube_dl/extractor/extractors.py1
-rw-r--r--youtube_dl/extractor/ufctv.py55
2 files changed, 56 insertions, 0 deletions
diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py
index e7b93a699..5ed031833 100644
--- a/youtube_dl/extractor/extractors.py
+++ b/youtube_dl/extractor/extractors.py
@@ -1145,6 +1145,7 @@ from .udemy import (
UdemyCourseIE
)
from .udn import UDNEmbedIE
+from .ufctv import UFCTVIE
from .uktvplay import UKTVPlayIE
from .digiteka import DigitekaIE
from .umg import UMGDeIE
diff --git a/youtube_dl/extractor/ufctv.py b/youtube_dl/extractor/ufctv.py
new file mode 100644
index 000000000..ab823814b
--- /dev/null
+++ b/youtube_dl/extractor/ufctv.py
@@ -0,0 +1,55 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+from ..utils import (
+ parse_duration,
+ parse_iso8601,
+)
+
+
+class UFCTVIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?ufc\.tv/video/(?P<id>[^/]+)'
+ _TEST = {
+ 'url': 'https://www.ufc.tv/video/ufc-219-countdown-full-episode',
+ 'info_dict': {
+ 'id': '34167',
+ 'ext': 'mp4',
+ 'title': 'UFC 219 Countdown: Full Episode',
+ 'description': 'md5:26d4e8bf4665ae5878842d7050c3c646',
+ 'timestamp': 1513962360,
+ 'upload_date': '20171222',
+ },
+ 'params': {
+ # m3u8 download
+ 'skip_download': True,
+ }
+ }
+
+ def _real_extract(self, url):
+ display_id = self._match_id(url)
+ video_data = self._download_json(url, display_id, query={
+ 'format': 'json',
+ })
+ video_id = str(video_data['id'])
+ title = video_data['name']
+ m3u8_url = self._download_json(
+ 'https://www.ufc.tv/service/publishpoint', video_id, query={
+ 'type': 'video',
+ 'format': 'json',
+ 'id': video_id,
+ }, headers={
+ 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0_1 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A402 Safari/604.1',
+ })['path']
+ m3u8_url = m3u8_url.replace('_iphone.', '.')
+ formats = self._extract_m3u8_formats(m3u8_url, video_id, 'mp4')
+ self._sort_formats(formats)
+
+ return {
+ 'id': video_id,
+ 'title': title,
+ 'description': video_data.get('description'),
+ 'duration': parse_duration(video_data.get('runtime')),
+ 'timestamp': parse_iso8601(video_data.get('releaseDate')),
+ 'formats': formats,
+ }