lenta.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from .common import InfoExtractor
  2. class LentaIE(InfoExtractor):
  3. _WORKING = False
  4. _VALID_URL = r'https?://(?:www\.)?lenta\.ru/[^/]+/\d+/\d+/\d+/(?P<id>[^/?#&]+)'
  5. _TESTS = [{
  6. 'url': 'https://lenta.ru/news/2018/03/22/savshenko_go/',
  7. 'info_dict': {
  8. 'id': '964400',
  9. 'ext': 'mp4',
  10. 'title': 'Надежду Савченко задержали',
  11. 'thumbnail': r're:^https?://.*\.jpg$',
  12. 'duration': 61,
  13. 'view_count': int,
  14. },
  15. 'params': {
  16. 'skip_download': True,
  17. },
  18. }, {
  19. # EaglePlatform iframe embed
  20. 'url': 'http://lenta.ru/news/2015/03/06/navalny/',
  21. 'info_dict': {
  22. 'id': '227304',
  23. 'ext': 'mp4',
  24. 'title': 'Навальный вышел на свободу',
  25. 'description': 'md5:d97861ac9ae77377f3f20eaf9d04b4f5',
  26. 'thumbnail': r're:^https?://.*\.jpg$',
  27. 'duration': 87,
  28. 'view_count': int,
  29. 'age_limit': 0,
  30. },
  31. 'params': {
  32. 'skip_download': True,
  33. },
  34. }]
  35. def _real_extract(self, url):
  36. display_id = self._match_id(url)
  37. webpage = self._download_webpage(url, display_id)
  38. video_id = self._search_regex(
  39. r'vid\s*:\s*["\']?(\d+)', webpage, 'eagleplatform id',
  40. default=None)
  41. if video_id:
  42. return self.url_result(
  43. f'eagleplatform:lentaru.media.eagleplatform.com:{video_id}',
  44. ie='EaglePlatform', video_id=video_id)
  45. return self.url_result(url, ie='Generic')