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.

64 lines
2.2 KiB

10 years ago
9 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. self._sort_formats(formats)
  36. thumbnail = self._og_search_thumbnail(webpage)
  37. description = self._og_search_description(webpage)
  38. duration = parse_duration(self._search_regex(
  39. r'var\s+record_len\s*=\s*(["\'])(?P<duration>[0-9]+:[0-9]+:[0-9]+)\1',
  40. webpage, 'duration', default=None, group='duration'))
  41. view_count = int_or_none(self._html_search_regex(
  42. r'<div[^>]+class=(["\']).*?record-desc-seen.*?\1[^>]*>(?P<count>.+?)</div>',
  43. webpage, 'view count', fatal=False, group='count'))
  44. like_count = int_or_none(self._search_regex(
  45. r'<span[^>]+id=(["\'])flikesCount.*?\1>(?P<count>\d+)<',
  46. webpage, 'like count', fatal=False, group='count'))
  47. return {
  48. 'id': video_id,
  49. 'title': title,
  50. 'formats': formats,
  51. 'thumbnail': thumbnail,
  52. 'description': description,
  53. 'duration': duration,
  54. 'view_count': view_count,
  55. 'like_count': like_count,
  56. }