]> jfr.im git - yt-dlp.git/blame - youtube_dlc/extractor/tenplay.py
Update to ytdl-2021.01.03
[yt-dlp.git] / youtube_dlc / extractor / tenplay.py
CommitLineData
dd90451f
RA
1# coding: utf-8
2from __future__ import unicode_literals
3
4from .common import InfoExtractor
5from ..utils import (
29f7c58a 6 HEADRequest,
dd90451f
RA
7 parse_age_limit,
8 parse_iso8601,
29f7c58a 9 # smuggle_url,
dd90451f
RA
10)
11
12
13class TenPlayIE(InfoExtractor):
c97f5e93
S
14 _VALID_URL = r'https?://(?:www\.)?10play\.com\.au/(?:[^/]+/)+(?P<id>tpv\d{6}[a-z]{5})'
15 _TESTS = [{
dd90451f
RA
16 'url': 'https://10play.com.au/masterchef/episodes/season-1/masterchef-s1-ep-1/tpv190718kwzga',
17 'info_dict': {
18 'id': '6060533435001',
19 'ext': 'mp4',
20 'title': 'MasterChef - S1 Ep. 1',
21 'description': 'md5:4fe7b78e28af8f2d900cd20d900ef95c',
22 'age_limit': 10,
23 'timestamp': 1240828200,
24 'upload_date': '20090427',
25 'uploader_id': '2199827728001',
26 },
27 'params': {
29f7c58a 28 # 'format': 'bestvideo',
dd90451f
RA
29 'skip_download': True,
30 }
c97f5e93
S
31 }, {
32 'url': 'https://10play.com.au/how-to-stay-married/web-extras/season-1/terrys-talks-ep-1-embracing-change/tpv190915ylupc',
33 'only_matching': True,
34 }]
29f7c58a 35 # BRIGHTCOVE_URL_TEMPLATE = 'https://players.brightcove.net/2199827728001/cN6vRtRQt_default/index.html?videoId=%s'
36 _GEO_BYPASS = False
37 _FASTLY_URL_TEMPL = 'https://10-selector.global.ssl.fastly.net/s/kYEXFC/media/%s?mbr=true&manifest=m3u&format=redirect'
dd90451f
RA
38
39 def _real_extract(self, url):
40 content_id = self._match_id(url)
41 data = self._download_json(
42 'https://10play.com.au/api/video/' + content_id, content_id)
43 video = data.get('video') or {}
44 metadata = data.get('metaData') or {}
45 brightcove_id = video.get('videoId') or metadata['showContentVideoId']
29f7c58a 46 # brightcove_url = smuggle_url(
47 # self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id,
48 # {'geo_countries': ['AU']})
49 m3u8_url = self._request_webpage(HEADRequest(
50 self._FASTLY_URL_TEMPL % brightcove_id), brightcove_id).geturl()
51 if '10play-not-in-oz' in m3u8_url:
52 self.raise_geo_restricted(countries=['AU'])
53 formats = self._extract_m3u8_formats(m3u8_url, brightcove_id, 'mp4')
54 self._sort_formats(formats)
dd90451f
RA
55
56 return {
29f7c58a 57 # '_type': 'url_transparent',
58 # 'url': brightcove_url,
59 'formats': formats,
60 'id': brightcove_id,
61 'title': video.get('title') or metadata.get('pageContentName') or metadata['showContentName'],
dd90451f
RA
62 'description': video.get('description'),
63 'age_limit': parse_age_limit(video.get('showRatingClassification') or metadata.get('showProgramClassification')),
64 'series': metadata.get('showName'),
65 'season': metadata.get('showContentSeason'),
66 'timestamp': parse_iso8601(metadata.get('contentPublishDate') or metadata.get('pageContentPublishDate')),
29f7c58a 67 'thumbnail': video.get('poster'),
68 'uploader_id': '2199827728001',
69 # 'ie_key': 'BrightcoveNew',
dd90451f 70 }