]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/fivetv.py
[ie/matchtv] Fix extractor (#10190)
[yt-dlp.git] / yt_dlp / extractor / fivetv.py
1 from .common import InfoExtractor
2 from ..utils import int_or_none
3
4
5 class FiveTVIE(InfoExtractor):
6 _VALID_URL = r'''(?x)
7 https?://
8 (?:www\.)?5-tv\.ru/
9 (?:
10 (?:[^/]+/)+(?P<id>\d+)|
11 (?P<path>[^/?#]+)(?:[/?#])?
12 )
13 '''
14
15 _TESTS = [{
16 'url': 'http://5-tv.ru/news/96814/',
17 'md5': 'bbff554ad415ecf5416a2f48c22d9283',
18 'info_dict': {
19 'id': '96814',
20 'ext': 'mp4',
21 'title': 'Россияне выбрали имя для общенациональной платежной системы',
22 'description': 'md5:a8aa13e2b7ad36789e9f77a74b6de660',
23 'thumbnail': r're:^https?://.*\.jpg$',
24 'duration': 180,
25 },
26 }, {
27 'url': 'http://5-tv.ru/video/1021729/',
28 'info_dict': {
29 'id': '1021729',
30 'ext': 'mp4',
31 'title': '3D принтер',
32 'description': 'md5:d76c736d29ef7ec5c0cf7d7c65ffcb41',
33 'thumbnail': r're:^https?://.*\.jpg$',
34 'duration': 180,
35 },
36 }, {
37 # redirect to https://www.5-tv.ru/projects/1000095/izvestia-glavnoe/
38 'url': 'http://www.5-tv.ru/glavnoe/#itemDetails',
39 'info_dict': {
40 'id': 'glavnoe',
41 'ext': 'mp4',
42 'title': r're:^Итоги недели с \d+ по \d+ \w+ \d{4} года$',
43 'thumbnail': r're:^https?://.*\.jpg$',
44 },
45 'skip': 'redirect to «Известия. Главное» project page',
46 }, {
47 'url': 'http://www.5-tv.ru/glavnoe/broadcasts/508645/',
48 'only_matching': True,
49 }, {
50 'url': 'http://5-tv.ru/films/1507502/',
51 'only_matching': True,
52 }, {
53 'url': 'http://5-tv.ru/programs/broadcast/508713/',
54 'only_matching': True,
55 }, {
56 'url': 'http://5-tv.ru/angel/',
57 'only_matching': True,
58 }, {
59 'url': 'http://www.5-tv.ru/schedule/?iframe=true&width=900&height=450',
60 'only_matching': True,
61 }]
62
63 def _real_extract(self, url):
64 mobj = self._match_valid_url(url)
65 video_id = mobj.group('id') or mobj.group('path')
66
67 webpage = self._download_webpage(url, video_id)
68
69 video_url = self._search_regex(
70 [r'<div[^>]+?class="(?:flow)?player[^>]+?data-href="([^"]+)"',
71 r'<a[^>]+?href="([^"]+)"[^>]+?class="videoplayer"'],
72 webpage, 'video url')
73
74 title = self._generic_title('', webpage)
75 duration = int_or_none(self._og_search_property(
76 'video:duration', webpage, 'duration', default=None))
77
78 return {
79 'id': video_id,
80 'url': video_url,
81 'title': title,
82 'description': self._og_search_description(webpage, default=None),
83 'thumbnail': self._og_search_thumbnail(webpage, default=None),
84 'duration': duration,
85 }