willow.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. from ..utils import ExtractorError
  2. from .common import InfoExtractor
  3. class WillowIE(InfoExtractor):
  4. _VALID_URL = r'https?://(www\.)?willow\.tv/videos/(?P<id>[0-9a-z-_]+)'
  5. _GEO_COUNTRIES = ['US']
  6. _TESTS = [{
  7. 'url': 'http://willow.tv/videos/d5winning-moment-eng-vs-ind-streaming-online-4th-test-india-tour-of-england-2021',
  8. 'info_dict': {
  9. 'id': '169662',
  10. 'display_id': 'd5winning-moment-eng-vs-ind-streaming-online-4th-test-india-tour-of-england-2021',
  11. 'ext': 'mp4',
  12. 'title': 'Winning Moment: 4th Test, England vs India',
  13. 'thumbnail': 'https://aimages.willow.tv/ytThumbnails/6748_D5winning_moment.jpg',
  14. 'duration': 233,
  15. 'timestamp': 1630947954,
  16. 'upload_date': '20210906',
  17. 'location': 'Kennington Oval, London',
  18. 'series': 'India tour of England 2021',
  19. },
  20. 'params': {
  21. 'skip_download': True, # AES-encrypted m3u8
  22. },
  23. }, {
  24. 'url': 'http://willow.tv/videos/highlights-short-ind-vs-nz-streaming-online-2nd-t20i-new-zealand-tour-of-india-2021',
  25. 'only_matching': True,
  26. }]
  27. def _real_extract(self, url):
  28. video_id = self._match_id(url)
  29. webpage = self._download_webpage(url, video_id)
  30. video_data = self._parse_json(self._html_search_regex(
  31. r'var\s+data_js\s*=\s*JSON\.parse\(\'(.+)\'\)', webpage,
  32. 'data_js'), video_id)
  33. video = next((v for v in video_data.get('trending_videos') or []
  34. if v.get('secureurl')), None)
  35. if not video:
  36. raise ExtractorError('No videos found')
  37. formats = self._extract_m3u8_formats(video['secureurl'], video_id, 'mp4')
  38. return {
  39. 'id': str(video.get('content_id')),
  40. 'display_id': video.get('video_slug'),
  41. 'title': video.get('video_name') or self._html_search_meta('twitter:title', webpage),
  42. 'formats': formats,
  43. 'thumbnail': video.get('yt_thumb_url') or self._html_search_meta(
  44. 'twitter:image', webpage, default=None),
  45. 'duration': video.get('duration_seconds'),
  46. 'timestamp': video.get('created_date'),
  47. 'location': video.get('venue'),
  48. 'series': video.get('series_name'),
  49. }