logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

lenta.py (1682B)


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