You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
2.1 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. parse_age_limit,
  6. parse_iso8601,
  7. smuggle_url,
  8. )
  9. class TenPlayIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?10play\.com\.au/[^/]+/episodes/[^/]+/[^/]+/(?P<id>tpv\d{6}[a-z]{5})'
  11. _TEST = {
  12. 'url': 'https://10play.com.au/masterchef/episodes/season-1/masterchef-s1-ep-1/tpv190718kwzga',
  13. 'info_dict': {
  14. 'id': '6060533435001',
  15. 'ext': 'mp4',
  16. 'title': 'MasterChef - S1 Ep. 1',
  17. 'description': 'md5:4fe7b78e28af8f2d900cd20d900ef95c',
  18. 'age_limit': 10,
  19. 'timestamp': 1240828200,
  20. 'upload_date': '20090427',
  21. 'uploader_id': '2199827728001',
  22. },
  23. 'params': {
  24. 'format': 'bestvideo',
  25. 'skip_download': True,
  26. }
  27. }
  28. BRIGHTCOVE_URL_TEMPLATE = 'https://players.brightcove.net/2199827728001/cN6vRtRQt_default/index.html?videoId=%s'
  29. def _real_extract(self, url):
  30. content_id = self._match_id(url)
  31. data = self._download_json(
  32. 'https://10play.com.au/api/video/' + content_id, content_id)
  33. video = data.get('video') or {}
  34. metadata = data.get('metaData') or {}
  35. brightcove_id = video.get('videoId') or metadata['showContentVideoId']
  36. brightcove_url = smuggle_url(
  37. self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id,
  38. {'geo_countries': ['AU']})
  39. return {
  40. '_type': 'url_transparent',
  41. 'url': brightcove_url,
  42. 'id': content_id,
  43. 'title': video.get('title') or metadata.get('pageContentName') or metadata.get('showContentName'),
  44. 'description': video.get('description'),
  45. 'age_limit': parse_age_limit(video.get('showRatingClassification') or metadata.get('showProgramClassification')),
  46. 'series': metadata.get('showName'),
  47. 'season': metadata.get('showContentSeason'),
  48. 'timestamp': parse_iso8601(metadata.get('contentPublishDate') or metadata.get('pageContentPublishDate')),
  49. 'ie_key': 'BrightcoveNew',
  50. }