youtube-dl

Another place where youtube-dl lives on
git clone git://git.oshgnacknak.de/youtube-dl.git
Log | Files | Refs | README | LICENSE

tenplay.py (2984B)


      1 # coding: utf-8
      2 from __future__ import unicode_literals
      3 
      4 from .common import InfoExtractor
      5 from ..utils import (
      6     HEADRequest,
      7     parse_age_limit,
      8     parse_iso8601,
      9     # smuggle_url,
     10 )
     11 
     12 
     13 class TenPlayIE(InfoExtractor):
     14     _VALID_URL = r'https?://(?:www\.)?10play\.com\.au/(?:[^/]+/)+(?P<id>tpv\d{6}[a-z]{5})'
     15     _TESTS = [{
     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': {
     28             # 'format': 'bestvideo',
     29             'skip_download': True,
     30         }
     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     }]
     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'
     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']
     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)
     55 
     56         return {
     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'],
     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')),
     67             'thumbnail': video.get('poster'),
     68             'uploader_id': '2199827728001',
     69             # 'ie_key': 'BrightcoveNew',
     70         }