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.

93 lines
3.6 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. parse_age_limit,
  7. parse_iso8601,
  8. smuggle_url,
  9. str_or_none,
  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': 'http://cwtv.com/shows/arrow/legends-of-yesterday/?play=6b15e985-9345-4f60-baf8-56e96be57c63',
  15. 'info_dict': {
  16. 'id': '6b15e985-9345-4f60-baf8-56e96be57c63',
  17. 'ext': 'mp4',
  18. 'title': 'Legends of Yesterday',
  19. '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.',
  20. 'duration': 2665,
  21. 'series': 'Arrow',
  22. 'season_number': 4,
  23. 'season': '4',
  24. 'episode_number': 8,
  25. 'upload_date': '20151203',
  26. 'timestamp': 1449122100,
  27. },
  28. 'params': {
  29. # m3u8 download
  30. 'skip_download': True,
  31. },
  32. 'skip': 'redirect to http://cwtv.com/shows/arrow/',
  33. }, {
  34. 'url': 'http://www.cwseed.com/shows/whose-line-is-it-anyway/jeff-davis-4/?play=24282b12-ead2-42f2-95ad-26770c2c6088',
  35. 'info_dict': {
  36. 'id': '24282b12-ead2-42f2-95ad-26770c2c6088',
  37. 'ext': 'mp4',
  38. 'title': 'Jeff Davis 4',
  39. 'description': 'Jeff Davis is back to make you laugh.',
  40. 'duration': 1263,
  41. 'series': 'Whose Line Is It Anyway?',
  42. 'season_number': 11,
  43. 'episode_number': 20,
  44. 'upload_date': '20151006',
  45. 'timestamp': 1444107300,
  46. 'age_limit': 14,
  47. 'uploader': 'CWTV',
  48. },
  49. 'params': {
  50. # m3u8 download
  51. 'skip_download': True,
  52. },
  53. }, {
  54. 'url': 'http://cwtv.com/thecw/chroniclesofcisco/?play=8adebe35-f447-465f-ab52-e863506ff6d6',
  55. 'only_matching': True,
  56. }, {
  57. 'url': 'http://cwtvpr.com/the-cw/video?watch=9eee3f60-ef4e-440b-b3b2-49428ac9c54e',
  58. 'only_matching': True,
  59. }, {
  60. 'url': 'http://cwtv.com/shows/arrow/legends-of-yesterday/?watch=6b15e985-9345-4f60-baf8-56e96be57c63',
  61. 'only_matching': True,
  62. }]
  63. def _real_extract(self, url):
  64. video_id = self._match_id(url)
  65. video_data = self._download_json(
  66. 'http://images.cwtv.com/feed/mobileapp/video-meta/apiversion_8/guid_' + video_id,
  67. video_id)['video']
  68. title = video_data['title']
  69. mpx_url = video_data.get('mpx_url') or 'http://link.theplatform.com/s/cwtv/media/guid/2703454149/%s?formats=M3U' % video_id
  70. season = str_or_none(video_data.get('season'))
  71. episode = str_or_none(video_data.get('episode'))
  72. if episode and season:
  73. episode = episode.lstrip(season)
  74. return {
  75. '_type': 'url_transparent',
  76. 'id': video_id,
  77. 'title': title,
  78. 'url': smuggle_url(mpx_url, {'force_smil_url': True}),
  79. 'description': video_data.get('description_long'),
  80. 'duration': int_or_none(video_data.get('duration_secs')),
  81. 'series': video_data.get('series_name'),
  82. 'season_number': int_or_none(season),
  83. 'episode_number': int_or_none(episode),
  84. 'timestamp': parse_iso8601(video_data.get('start_time')),
  85. 'age_limit': parse_age_limit(video_data.get('rating')),
  86. 'ie_key': 'ThePlatform',
  87. }