aeonco.py 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. from .common import InfoExtractor
  2. from .vimeo import VimeoIE
  3. from ..utils import ExtractorError, traverse_obj, url_or_none
  4. class AeonCoIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?aeon\.co/videos/(?P<id>[^/?]+)'
  6. _TESTS = [{
  7. 'url': 'https://aeon.co/videos/raw-solar-storm-footage-is-the-punk-rock-antidote-to-sleek-james-webb-imagery',
  8. 'md5': 'e5884d80552c9b6ea8d268a258753362',
  9. 'info_dict': {
  10. 'id': '1284717',
  11. 'ext': 'mp4',
  12. 'title': 'Brilliant Noise',
  13. 'thumbnail': 'https://i.vimeocdn.com/video/21006315-1a1e49da8b07fd908384a982b4ba9ff0268c509a474576ebdf7b1392f4acae3b-d_960',
  14. 'uploader': 'Semiconductor',
  15. 'uploader_id': 'semiconductor',
  16. 'uploader_url': 'https://vimeo.com/semiconductor',
  17. 'duration': 348,
  18. },
  19. }, {
  20. 'url': 'https://aeon.co/videos/dazzling-timelapse-shows-how-microbes-spoil-our-food-and-sometimes-enrich-it',
  21. 'md5': '03582d795382e49f2fd0b427b55de409',
  22. 'info_dict': {
  23. 'id': '759576926',
  24. 'ext': 'mp4',
  25. 'title': 'Wrought',
  26. 'thumbnail': 'https://i.vimeocdn.com/video/1525599692-84614af88e446612f49ca966cf8f80eab2c73376bedd80555741c521c26f9a3e-d_1280',
  27. 'uploader': 'Aeon Video',
  28. 'uploader_id': 'aeonvideo',
  29. 'uploader_url': 'https://vimeo.com/aeonvideo',
  30. 'duration': 1344,
  31. },
  32. }, {
  33. 'url': 'https://aeon.co/videos/chew-over-the-prisoners-dilemma-and-see-if-you-can-find-the-rational-path-out',
  34. 'md5': '1cfda0bf3ae24df17d00f2c0cb6cc21b',
  35. 'info_dict': {
  36. 'id': 'emyi4z-O0ls',
  37. 'ext': 'mp4',
  38. 'title': 'How to outsmart the Prisoner’s Dilemma - Lucas Husted',
  39. 'thumbnail': 'https://i.ytimg.com/vi_webp/emyi4z-O0ls/maxresdefault.webp',
  40. 'uploader': 'TED-Ed',
  41. 'uploader_id': '@TEDEd',
  42. 'uploader_url': 'https://www.youtube.com/@TEDEd',
  43. 'duration': 344,
  44. 'upload_date': '20200827',
  45. 'channel_id': 'UCsooa4yRKGN_zEE8iknghZA',
  46. 'playable_in_embed': True,
  47. 'description': 'md5:c0959524f08cb60f96fd010f3dfb17f3',
  48. 'categories': ['Education'],
  49. 'like_count': int,
  50. 'channel': 'TED-Ed',
  51. 'chapters': 'count:7',
  52. 'channel_url': 'https://www.youtube.com/channel/UCsooa4yRKGN_zEE8iknghZA',
  53. 'tags': 'count:26',
  54. 'availability': 'public',
  55. 'channel_follower_count': int,
  56. 'view_count': int,
  57. 'age_limit': 0,
  58. 'live_status': 'not_live',
  59. 'comment_count': int,
  60. },
  61. }]
  62. def _real_extract(self, url):
  63. video_id = self._match_id(url)
  64. webpage = self._download_webpage(url, video_id)
  65. embed_url = traverse_obj(self._yield_json_ld(webpage, video_id), (
  66. lambda _, v: v['@type'] == 'VideoObject', 'embedUrl', {url_or_none}), get_all=False)
  67. if not embed_url:
  68. raise ExtractorError('No embed URL found in webpage')
  69. if 'player.vimeo.com' in embed_url:
  70. embed_url = VimeoIE._smuggle_referrer(embed_url, 'https://aeon.co/')
  71. return self.url_result(embed_url)