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

cwtv.py (5021B)


  1. from .common import InfoExtractor
  2. from ..utils import (
  3. ExtractorError,
  4. int_or_none,
  5. parse_age_limit,
  6. parse_iso8601,
  7. smuggle_url,
  8. str_or_none,
  9. update_url_query,
  10. )
  11. class CWTVIE(InfoExtractor):
  12. _VALID_URL = r'https?://(?:www\.)?cw(?:tv(?:pr)?|seed)\.com/(?:shows/)?(?:[^/]+/)+[^?]*\?.*\b(?:play|watch)=(?P<id>[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12})'
  13. _TESTS = [{
  14. 'url': 'https://www.cwtv.com/shows/all-american-homecoming/ready-or-not/?play=d848488f-f62a-40fd-af1f-6440b1821aab',
  15. 'info_dict': {
  16. 'id': 'd848488f-f62a-40fd-af1f-6440b1821aab',
  17. 'ext': 'mp4',
  18. 'title': 'Ready Or Not',
  19. 'description': 'Simone is concerned about changes taking place at Bringston; JR makes a decision about his future.',
  20. 'thumbnail': r're:^https?://.*\.jpe?g$',
  21. 'duration': 2547,
  22. 'timestamp': 1720519200,
  23. 'uploader': 'CWTV',
  24. 'chapters': 'count:6',
  25. 'series': 'All American: Homecoming',
  26. 'season_number': 3,
  27. 'episode_number': 1,
  28. 'age_limit': 0,
  29. 'upload_date': '20240709',
  30. 'season': 'Season 3',
  31. 'episode': 'Episode 1',
  32. },
  33. 'params': {
  34. # m3u8 download
  35. 'skip_download': True,
  36. },
  37. }, {
  38. 'url': 'http://cwtv.com/shows/arrow/legends-of-yesterday/?play=6b15e985-9345-4f60-baf8-56e96be57c63',
  39. 'info_dict': {
  40. 'id': '6b15e985-9345-4f60-baf8-56e96be57c63',
  41. 'ext': 'mp4',
  42. 'title': 'Legends of Yesterday',
  43. 'description': 'Oliver and Barry Allen take Kendra Saunders and Carter Hall to a remote location to keep them hidden from Vandal Savage while they figure out how to defeat him.',
  44. 'duration': 2665,
  45. 'series': 'Arrow',
  46. 'season_number': 4,
  47. 'season': '4',
  48. 'episode_number': 8,
  49. 'upload_date': '20151203',
  50. 'timestamp': 1449122100,
  51. },
  52. 'params': {
  53. # m3u8 download
  54. 'skip_download': True,
  55. },
  56. 'skip': 'redirect to http://cwtv.com/shows/arrow/',
  57. }, {
  58. 'url': 'http://www.cwseed.com/shows/whose-line-is-it-anyway/jeff-davis-4/?play=24282b12-ead2-42f2-95ad-26770c2c6088',
  59. 'info_dict': {
  60. 'id': '24282b12-ead2-42f2-95ad-26770c2c6088',
  61. 'ext': 'mp4',
  62. 'title': 'Jeff Davis 4',
  63. 'description': 'Jeff Davis is back to make you laugh.',
  64. 'duration': 1263,
  65. 'series': 'Whose Line Is It Anyway?',
  66. 'season_number': 11,
  67. 'episode_number': 20,
  68. 'upload_date': '20151006',
  69. 'timestamp': 1444107300,
  70. 'age_limit': 14,
  71. 'uploader': 'CWTV',
  72. 'thumbnail': r're:^https?://.*\.jpe?g$',
  73. 'chapters': 'count:4',
  74. 'episode': 'Episode 20',
  75. 'season': 'Season 11',
  76. },
  77. 'params': {
  78. # m3u8 download
  79. 'skip_download': True,
  80. },
  81. }, {
  82. 'url': 'http://cwtv.com/thecw/chroniclesofcisco/?play=8adebe35-f447-465f-ab52-e863506ff6d6',
  83. 'only_matching': True,
  84. }, {
  85. 'url': 'http://cwtvpr.com/the-cw/video?watch=9eee3f60-ef4e-440b-b3b2-49428ac9c54e',
  86. 'only_matching': True,
  87. }, {
  88. 'url': 'http://cwtv.com/shows/arrow/legends-of-yesterday/?watch=6b15e985-9345-4f60-baf8-56e96be57c63',
  89. 'only_matching': True,
  90. }]
  91. def _real_extract(self, url):
  92. video_id = self._match_id(url)
  93. data = self._download_json(
  94. f'https://images.cwtv.com/feed/mobileapp/video-meta/apiversion_12/guid_{video_id}', video_id)
  95. if data.get('result') != 'ok':
  96. raise ExtractorError(data['msg'], expected=True)
  97. video_data = data['video']
  98. title = video_data['title']
  99. mpx_url = update_url_query(
  100. video_data.get('mpx_url') or f'https://link.theplatform.com/s/cwtv/media/guid/2703454149/{video_id}',
  101. {'formats': 'M3U+none'})
  102. season = str_or_none(video_data.get('season'))
  103. episode = str_or_none(video_data.get('episode'))
  104. if episode and season:
  105. episode = episode[len(season):]
  106. return {
  107. '_type': 'url_transparent',
  108. 'id': video_id,
  109. 'title': title,
  110. 'url': smuggle_url(mpx_url, {'force_smil_url': True}),
  111. 'description': video_data.get('description_long'),
  112. 'duration': int_or_none(video_data.get('duration_secs')),
  113. 'series': video_data.get('series_name'),
  114. 'season_number': int_or_none(season),
  115. 'episode_number': int_or_none(episode),
  116. 'timestamp': parse_iso8601(video_data.get('start_time')),
  117. 'age_limit': parse_age_limit(video_data.get('rating')),
  118. 'ie_key': 'ThePlatform',
  119. 'thumbnail': video_data.get('large_thumbnail'),
  120. }