]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/lrt.py
[lrt] Improve
[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 (
4dc19c09
NJ
6 parse_duration,
7 remove_end,
8)
9
10
11class LRTIE(InfoExtractor):
12 IE_NAME = 'lrt.lt'
13 _VALID_URL = r'https?://(?:www\.)?lrt\.lt/mediateka/irasas/(?P<id>[0-9]+)'
14 _TEST = {
15 'url': 'http://www.lrt.lt/mediateka/irasas/54391/',
16 'info_dict': {
17 'id': '54391',
18 'ext': 'mp4',
19 'title': 'Septynios Kauno dienos',
9a76f416 20 'description': 'md5:24d84534c7dc76581e59f5689462411a',
4dc19c09
NJ
21 'duration': 1783,
22 },
23 'params': {
339b1944 24 'skip_download': True, # m3u8 download
4dc19c09 25 },
4dc19c09
NJ
26 }
27
28 def _real_extract(self, url):
8112d4b2 29 video_id = self._match_id(url)
4dc19c09
NJ
30 webpage = self._download_webpage(url, video_id)
31
32 title = remove_end(self._og_search_title(webpage), ' - LRT')
f7e1d82d
S
33 m3u8_url = self._search_regex(
34 r'file\s*:\s*(["\'])(?P<url>.+?)\1\s*\+\s*location\.hash\.substring\(1\)',
35 webpage, 'm3u8 url', group='url')
36 formats = self._extract_m3u8_formats(m3u8_url, video_id, 'mp4')
37
4dc19c09
NJ
38 thumbnail = self._og_search_thumbnail(webpage)
39 description = self._og_search_description(webpage)
40 duration = parse_duration(self._search_regex(
f7e1d82d
S
41 r'var\s+record_len\s*=\s*(["\'])(?P<duration>[0-9]+:[0-9]+:[0-9]+)\1',
42 webpage, 'duration', default=None, group='duration'))
4dc19c09
NJ
43
44 return {
45 'id': video_id,
46 'title': title,
47 'formats': formats,
48 'thumbnail': thumbnail,
49 'description': description,
50 'duration': duration,
51 }