lrt.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. parse_duration,
  6. remove_end,
  7. )
  8. class LRTIE(InfoExtractor):
  9. IE_NAME = 'lrt.lt'
  10. _VALID_URL = r'https?://(?:www\.)?lrt\.lt/mediateka/irasas/(?P<id>[0-9]+)'
  11. _TEST = {
  12. 'url': 'http://www.lrt.lt/mediateka/irasas/54391/',
  13. 'info_dict': {
  14. 'id': '54391',
  15. 'ext': 'mp4',
  16. 'title': 'Septynios Kauno dienos',
  17. 'description': 'md5:24d84534c7dc76581e59f5689462411a',
  18. 'duration': 1783,
  19. },
  20. 'params': {
  21. 'skip_download': True, # m3u8 download
  22. },
  23. }
  24. def _real_extract(self, url):
  25. video_id = self._match_id(url)
  26. webpage = self._download_webpage(url, video_id)
  27. title = remove_end(self._og_search_title(webpage), ' - LRT')
  28. m3u8_url = self._search_regex(
  29. r'file\s*:\s*(["\'])(?P<url>.+?)\1\s*\+\s*location\.hash\.substring\(1\)',
  30. webpage, 'm3u8 url', group='url')
  31. formats = self._extract_m3u8_formats(m3u8_url, video_id, 'mp4')
  32. thumbnail = self._og_search_thumbnail(webpage)
  33. description = self._og_search_description(webpage)
  34. duration = parse_duration(self._search_regex(
  35. r'var\s+record_len\s*=\s*(["\'])(?P<duration>[0-9]+:[0-9]+:[0-9]+)\1',
  36. webpage, 'duration', default=None, group='duration'))
  37. return {
  38. 'id': video_id,
  39. 'title': title,
  40. 'formats': formats,
  41. 'thumbnail': thumbnail,
  42. 'description': description,
  43. 'duration': duration,
  44. }