logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

tenplay.py (6345B)


  1. import itertools
  2. from .common import InfoExtractor
  3. from ..networking import HEADRequest
  4. from ..utils import int_or_none, traverse_obj, url_or_none, urljoin
  5. class TenPlayIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?10play\.com\.au/(?:[^/]+/)+(?P<id>tpv\d{6}[a-z]{5})'
  7. _NETRC_MACHINE = '10play'
  8. _TESTS = [{
  9. 'url': 'https://10play.com.au/neighbours/web-extras/season-41/heres-a-first-look-at-mischa-bartons-neighbours-debut/tpv230911hyxnz',
  10. 'info_dict': {
  11. 'id': '6336940246112',
  12. 'ext': 'mp4',
  13. 'title': 'Here\'s A First Look At Mischa Barton\'s Neighbours Debut',
  14. 'alt_title': 'Here\'s A First Look At Mischa Barton\'s Neighbours Debut',
  15. 'description': 'Neighbours Premieres Monday, September 18 At 4:30pm On 10 And 10 Play And 6:30pm On 10 Peach',
  16. 'duration': 74,
  17. 'season': 'Season 41',
  18. 'season_number': 41,
  19. 'series': 'Neighbours',
  20. 'thumbnail': r're:https://.*\.jpg',
  21. 'uploader': 'Channel 10',
  22. 'age_limit': 15,
  23. 'timestamp': 1694386800,
  24. 'upload_date': '20230910',
  25. 'uploader_id': '2199827728001',
  26. },
  27. 'params': {
  28. 'skip_download': True,
  29. },
  30. 'skip': 'Only available in Australia',
  31. }, {
  32. 'url': 'https://10play.com.au/neighbours/episodes/season-42/episode-9107/tpv240902nzqyp',
  33. 'info_dict': {
  34. 'id': '9000000000091177',
  35. 'ext': 'mp4',
  36. 'title': 'Neighbours - S42 Ep. 9107',
  37. 'alt_title': 'Thu 05 Sep',
  38. 'description': 'md5:37a1f4271be34b9ee2b533426a5fbaef',
  39. 'duration': 1388,
  40. 'episode': 'Episode 9107',
  41. 'episode_number': 9107,
  42. 'season': 'Season 42',
  43. 'season_number': 42,
  44. 'series': 'Neighbours',
  45. 'thumbnail': r're:https://.*\.jpg',
  46. 'age_limit': 15,
  47. 'timestamp': 1725517860,
  48. 'upload_date': '20240905',
  49. 'uploader': 'Channel 10',
  50. 'uploader_id': '2199827728001',
  51. },
  52. 'params': {
  53. 'skip_download': True,
  54. },
  55. 'skip': 'Only available in Australia',
  56. }, {
  57. 'url': 'https://10play.com.au/how-to-stay-married/web-extras/season-1/terrys-talks-ep-1-embracing-change/tpv190915ylupc',
  58. 'only_matching': True,
  59. }]
  60. _GEO_BYPASS = False
  61. _AUS_AGES = {
  62. 'G': 0,
  63. 'PG': 15,
  64. 'M': 15,
  65. 'MA': 15,
  66. 'MA15+': 15,
  67. 'R': 18,
  68. 'X': 18,
  69. }
  70. def _real_extract(self, url):
  71. content_id = self._match_id(url)
  72. data = self._download_json(
  73. 'https://10play.com.au/api/v1/videos/' + content_id, content_id)
  74. video_data = self._download_json(
  75. f'https://vod.ten.com.au/api/videos/bcquery?command=find_videos_by_id&video_id={data["altId"]}',
  76. content_id, 'Downloading video JSON')
  77. m3u8_url = self._request_webpage(
  78. HEADRequest(video_data['items'][0]['HLSURL']),
  79. content_id, 'Checking stream URL').url
  80. if '10play-not-in-oz' in m3u8_url:
  81. self.raise_geo_restricted(countries=['AU'])
  82. # Attempt to get a higher quality stream
  83. m3u8_url = m3u8_url.replace(',150,75,55,0000', ',300,150,75,55,0000')
  84. formats = self._extract_m3u8_formats(m3u8_url, content_id, 'mp4')
  85. return {
  86. 'id': content_id,
  87. 'formats': formats,
  88. 'subtitles': {'en': [{'url': data['captionUrl']}]} if url_or_none(data.get('captionUrl')) else None,
  89. 'uploader': 'Channel 10',
  90. 'uploader_id': '2199827728001',
  91. **traverse_obj(data, {
  92. 'id': ('altId', {str}),
  93. 'duration': ('duration', {int_or_none}),
  94. 'title': ('subtitle', {str}),
  95. 'alt_title': ('title', {str}),
  96. 'description': ('description', {str}),
  97. 'age_limit': ('classification', {self._AUS_AGES.get}),
  98. 'series': ('tvShow', {str}),
  99. 'season_number': ('season', {int_or_none}),
  100. 'episode_number': ('episode', {int_or_none}),
  101. 'timestamp': ('published', {int_or_none}),
  102. 'thumbnail': ('imageUrl', {url_or_none}),
  103. }),
  104. }
  105. class TenPlaySeasonIE(InfoExtractor):
  106. _VALID_URL = r'https?://(?:www\.)?10play\.com\.au/(?P<show>[^/?#]+)/episodes/(?P<season>[^/?#]+)/?(?:$|[?#])'
  107. _TESTS = [{
  108. 'url': 'https://10play.com.au/masterchef/episodes/season-14',
  109. 'info_dict': {
  110. 'title': 'Season 14',
  111. 'id': 'MjMyOTIy',
  112. },
  113. 'playlist_mincount': 64,
  114. }, {
  115. 'url': 'https://10play.com.au/the-bold-and-the-beautiful-fast-tracked/episodes/season-2022',
  116. 'info_dict': {
  117. 'title': 'Season 2022',
  118. 'id': 'Mjc0OTIw',
  119. },
  120. 'playlist_mincount': 256,
  121. }]
  122. def _entries(self, load_more_url, display_id=None):
  123. skip_ids = []
  124. for page in itertools.count(1):
  125. episodes_carousel = self._download_json(
  126. load_more_url, display_id, query={'skipIds[]': skip_ids},
  127. note=f'Fetching episodes page {page}')
  128. episodes_chunk = episodes_carousel['items']
  129. skip_ids.extend(ep['id'] for ep in episodes_chunk)
  130. for ep in episodes_chunk:
  131. yield ep['cardLink']
  132. if not episodes_carousel['hasMore']:
  133. break
  134. def _real_extract(self, url):
  135. show, season = self._match_valid_url(url).group('show', 'season')
  136. season_info = self._download_json(
  137. f'https://10play.com.au/api/shows/{show}/episodes/{season}', f'{show}/{season}')
  138. episodes_carousel = traverse_obj(season_info, (
  139. 'content', 0, 'components', (
  140. lambda _, v: v['title'].lower() == 'episodes',
  141. (..., {dict}),
  142. )), get_all=False) or {}
  143. playlist_id = episodes_carousel['tpId']
  144. return self.playlist_from_matches(
  145. self._entries(urljoin(url, episodes_carousel['loadMoreUrl']), playlist_id),
  146. playlist_id, traverse_obj(season_info, ('content', 0, 'title', {str})),
  147. getter=urljoin(url))