You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.2 KiB

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