spiegel.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from .common import InfoExtractor
  2. from .jwplatform import JWPlatformIE
  3. class SpiegelIE(InfoExtractor):
  4. _UUID_RE = r'[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}'
  5. _VALID_URL = rf'https?://(?:www\.)?(?:spiegel|manager-magazin)\.de(?:/[^/]+)+/[^/]*-(?P<id>[0-9]+|{_UUID_RE})(?:-embed|-iframe)?(?:\.html)?(?:$|[#?])'
  6. _TESTS = [{
  7. 'url': 'http://www.spiegel.de/video/vulkan-tungurahua-in-ecuador-ist-wieder-aktiv-video-1259285.html',
  8. 'md5': '50c7948883ec85a3e431a0a44b7ad1d6',
  9. 'info_dict': {
  10. 'id': 'II0BUyxY',
  11. 'display_id': '1259285',
  12. 'ext': 'mp4',
  13. 'title': 'Vulkan Tungurahua in Ecuador ist wieder aktiv - DER SPIEGEL - Wissenschaft',
  14. 'description': 'md5:8029d8310232196eb235d27575a8b9f4',
  15. 'duration': 48.0,
  16. 'upload_date': '20130311',
  17. 'timestamp': 1362997920,
  18. },
  19. }, {
  20. 'url': 'http://www.spiegel.de/video/schach-wm-videoanalyse-des-fuenften-spiels-video-1309159.html',
  21. 'only_matching': True,
  22. }, {
  23. 'url': 'https://www.spiegel.de/video/eifel-zoo-aufregung-um-ausgebrochene-raubtiere-video-99018031.html',
  24. 'only_matching': True,
  25. }, {
  26. 'url': 'https://www.spiegel.de/panorama/urteile-im-goldmuenzenprozess-haftstrafen-fuer-clanmitglieder-a-aae8df48-43c1-4c61-867d-23f0a2d254b7',
  27. 'only_matching': True,
  28. }, {
  29. 'url': 'http://www.spiegel.de/video/spiegel-tv-magazin-ueber-guellekrise-in-schleswig-holstein-video-99012776.html',
  30. 'only_matching': True,
  31. }, {
  32. 'url': 'http://www.spiegel.de/sport/sonst/badminton-wm-die-randsportart-soll-populaerer-werden-a-987092.html',
  33. 'only_matching': True,
  34. }]
  35. def _real_extract(self, url):
  36. video_id = self._match_id(url)
  37. webpage = self._download_webpage(url, video_id)
  38. media_id = self._html_search_regex(
  39. r'(&#34;|["\'])mediaId\1\s*:\s*(&#34;|["\'])(?P<id>(?:(?!\2).)+)\2',
  40. webpage, 'media id', group='id')
  41. return {
  42. '_type': 'url_transparent',
  43. 'id': video_id,
  44. 'display_id': video_id,
  45. 'url': f'jwplatform:{media_id}',
  46. 'title': self._og_search_title(webpage, default=None),
  47. 'ie_key': JWPlatformIE.ie_key(),
  48. }