logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

tenplay.py (2984B)


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