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