magellantv.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. from .common import InfoExtractor
  2. from ..utils import parse_age_limit, parse_duration, traverse_obj
  3. class MagellanTVIE(InfoExtractor):
  4. _VALID_URL = r'https?://(?:www\.)?magellantv\.com/(?:watch|video)/(?P<id>[\w-]+)'
  5. _TESTS = [{
  6. 'url': 'https://www.magellantv.com/watch/my-dads-on-death-row?type=v',
  7. 'info_dict': {
  8. 'id': 'my-dads-on-death-row',
  9. 'ext': 'mp4',
  10. 'title': 'My Dad\'s On Death Row',
  11. 'description': 'md5:33ba23b9f0651fc4537ed19b1d5b0d7a',
  12. 'duration': 3780.0,
  13. 'age_limit': 14,
  14. 'tags': ['Justice', 'Reality', 'United States', 'True Crime'],
  15. },
  16. 'params': {'skip_download': 'm3u8'},
  17. }, {
  18. 'url': 'https://www.magellantv.com/video/james-bulger-the-new-revelations',
  19. 'info_dict': {
  20. 'id': 'james-bulger-the-new-revelations',
  21. 'ext': 'mp4',
  22. 'title': 'James Bulger: The New Revelations',
  23. 'description': 'md5:7b97922038bad1d0fe8d0470d8a189f2',
  24. 'duration': 2640.0,
  25. 'age_limit': 0,
  26. 'tags': ['Investigation', 'True Crime', 'Justice', 'Europe'],
  27. },
  28. 'params': {'skip_download': 'm3u8'},
  29. }, {
  30. 'url': 'https://www.magellantv.com/watch/celebration-nation',
  31. 'info_dict': {
  32. 'id': 'celebration-nation',
  33. 'ext': 'mp4',
  34. 'tags': ['Art & Culture', 'Human Interest', 'Anthropology', 'China', 'History'],
  35. 'duration': 2640.0,
  36. 'title': 'Ancestors',
  37. },
  38. 'params': {'skip_download': 'm3u8'},
  39. }]
  40. def _real_extract(self, url):
  41. video_id = self._match_id(url)
  42. webpage = self._download_webpage(url, video_id)
  43. data = traverse_obj(self._search_nextjs_data(webpage, video_id), (
  44. 'props', 'pageProps', 'reactContext',
  45. (('video', 'detail'), ('series', 'currentEpisode')), {dict}), get_all=False)
  46. formats, subtitles = self._extract_m3u8_formats_and_subtitles(data['jwpVideoUrl'], video_id)
  47. return {
  48. 'id': video_id,
  49. 'formats': formats,
  50. 'subtitles': subtitles,
  51. **traverse_obj(data, {
  52. 'title': ('title', {str}),
  53. 'description': ('metadata', 'description', {str}),
  54. 'duration': ('duration', {parse_duration}),
  55. 'age_limit': ('ratingCategory', {parse_age_limit}),
  56. 'tags': ('tags', ..., {str}),
  57. }),
  58. }