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.

89 lines
3.3 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_iso8601,
  7. )
  8. class CWTVIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?cw(?:tv|seed)\.com/shows/(?:[^/]+/){2}\?play=(?P<id>[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12})'
  10. _TESTS = [{
  11. 'url': 'http://cwtv.com/shows/arrow/legends-of-yesterday/?play=6b15e985-9345-4f60-baf8-56e96be57c63',
  12. 'info_dict': {
  13. 'id': '6b15e985-9345-4f60-baf8-56e96be57c63',
  14. 'ext': 'mp4',
  15. 'title': 'Legends of Yesterday',
  16. '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.',
  17. 'duration': 2665,
  18. 'series': 'Arrow',
  19. 'season_number': 4,
  20. 'season': '4',
  21. 'episode_number': 8,
  22. 'upload_date': '20151203',
  23. 'timestamp': 1449122100,
  24. },
  25. 'params': {
  26. # m3u8 download
  27. 'skip_download': True,
  28. }
  29. }, {
  30. 'url': 'http://www.cwseed.com/shows/whose-line-is-it-anyway/jeff-davis-4/?play=24282b12-ead2-42f2-95ad-26770c2c6088',
  31. 'info_dict': {
  32. 'id': '24282b12-ead2-42f2-95ad-26770c2c6088',
  33. 'ext': 'mp4',
  34. 'title': 'Jeff Davis 4',
  35. 'description': 'Jeff Davis is back to make you laugh.',
  36. 'duration': 1263,
  37. 'series': 'Whose Line Is It Anyway?',
  38. 'season_number': 11,
  39. 'season': '11',
  40. 'episode_number': 20,
  41. 'upload_date': '20151006',
  42. 'timestamp': 1444107300,
  43. },
  44. 'params': {
  45. # m3u8 download
  46. 'skip_download': True,
  47. }
  48. }]
  49. def _real_extract(self, url):
  50. video_id = self._match_id(url)
  51. video_data = self._download_json(
  52. 'http://metaframe.digitalsmiths.tv/v2/CWtv/assets/%s/partner/132?format=json' % video_id, video_id)
  53. formats = self._extract_m3u8_formats(
  54. video_data['videos']['variantplaylist']['uri'], video_id, 'mp4')
  55. self._sort_formats(formats)
  56. thumbnails = [{
  57. 'url': image['uri'],
  58. 'width': image.get('width'),
  59. 'height': image.get('height'),
  60. } for image_id, image in video_data['images'].items() if image.get('uri')] if video_data.get('images') else None
  61. video_metadata = video_data['assetFields']
  62. subtitles = {
  63. 'en': [{
  64. 'url': video_metadata['UnicornCcUrl'],
  65. }],
  66. } if video_metadata.get('UnicornCcUrl') else None
  67. return {
  68. 'id': video_id,
  69. 'title': video_metadata['title'],
  70. 'description': video_metadata.get('description'),
  71. 'duration': int_or_none(video_metadata.get('duration')),
  72. 'series': video_metadata.get('seriesName'),
  73. 'season_number': int_or_none(video_metadata.get('seasonNumber')),
  74. 'season': video_metadata.get('seasonName'),
  75. 'episode_number': int_or_none(video_metadata.get('episodeNumber')),
  76. 'timestamp': parse_iso8601(video_data.get('startTime')),
  77. 'thumbnails': thumbnails,
  78. 'formats': formats,
  79. 'subtitles': subtitles,
  80. }