lrt.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. thumbnail = self._og_search_thumbnail(webpage)
  29. description = self._og_search_description(webpage)
  30. duration = parse_duration(self._search_regex(
  31. r"var record_len = '([0-9]+:[0-9]+:[0-9]+)';", webpage, 'record_len', fatal=False, default=None))
  32. link = self._search_regex(r'file: "(.*)" \+ location\.hash\.substring\(1\)', webpage, 'link to m3u8')
  33. formats = self._extract_m3u8_formats(link, video_id, "mp4")
  34. return {
  35. 'id': video_id,
  36. 'title': title,
  37. 'formats': formats,
  38. 'thumbnail': thumbnail,
  39. 'description': description,
  40. 'duration': duration,
  41. }