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