]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/firsttv.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from ..compat
import compat_xpath
17 class FirstTVIE(InfoExtractor
):
19 IE_DESC
= 'Первый канал'
20 _VALID_URL
= r
'https?://(?:www\.)?1tv\.ru/(?:[^/]+/)+p?(?P<id>\d+)'
23 # single format via video_materials.json API
24 'url': 'http://www.1tv.ru/prj/inprivate/vypusk/35930',
25 'md5': '82a2777648acae812d58b3f5bd42882b',
29 'title': 'Гость Людмила Сенчина. Наедине со всеми. Выпуск от 12.02.2015',
30 'description': 'md5:357933adeede13b202c7c21f91b871b2',
31 'thumbnail': 're:^https?://.*\.(?:jpg|JPG)$',
32 'upload_date': '20150212',
36 # multiple formats via video_materials.json API
37 'url': 'http://www.1tv.ru/video_archive/projects/dobroeutro/p113641',
41 'title': 'Весенняя аллергия. Доброе утро. Фрагмент выпуска от 07.04.2016',
42 'description': 'md5:8dcebb3dded0ff20fade39087fd1fee2',
43 'thumbnail': 're:^https?://.*\.(?:jpg|JPG)$',
44 'upload_date': '20160407',
46 'formats': 'mincount:3',
49 'skip_download': True,
52 # single format only available via ONE_ONLINE_VIDEOS.archive_single_xml API
53 'url': 'http://www.1tv.ru/video_archive/series/f7552/p47038',
54 'md5': '519d306c5b5669761fd8906c39dbee23',
58 'title': '"Побег". Второй сезон. 3 серия',
59 'description': 'md5:3abf8f6b9bce88201c33e9a3d794a00b',
60 'thumbnail': 're:^https?://.*\.(?:jpg|JPG)$',
61 'upload_date': '20120516',
65 'url': 'http://www.1tv.ru/videoarchive/9967',
66 'only_matching': True,
69 def _real_extract(self
, url
):
70 video_id
= self
._match
_id
(url
)
72 # Videos with multiple formats only available via this API
73 video
= self
._download
_json
(
74 'http://www.1tv.ru/video_materials.json?legacy_id=%s' % video_id
,
75 video_id
, fatal
=False)
77 description
, thumbnail
, upload_date
, duration
= [None] * 4
82 quality
= qualities(('ld', 'sd', 'hd', ))
85 'format_id': f
.get('name'),
86 'quality': quality(f
.get('name')),
87 } for f
in item
['mbr'] if f
.get('src')]
88 thumbnail
= item
.get('poster')
90 # Some videos are not available via video_materials.json
91 video
= self
._download
_xml
(
92 'http://www.1tv.ru/owa/win/ONE_ONLINE_VIDEOS.archive_single_xml?pid=%s' % video_id
,
96 'media': 'http://search.yahoo.com/mrss/',
99 item
= xpath_element(video
, './channel/item', fatal
=True)
100 title
= xpath_text(item
, './title', fatal
=True)
102 'url': content
.attrib
['url'],
103 } for content
in item
.findall(
104 compat_xpath(xpath_with_ns('./media:content', NS_MAP
))) if content
.attrib
.get('url')]
105 thumbnail
= xpath_attr(
106 item
, xpath_with_ns('./media:thumbnail', NS_MAP
), 'url')
108 self
._sort
_formats
(formats
)
110 webpage
= self
._download
_webpage
(url
, video_id
, 'Downloading page', fatal
=False)
112 title
= self
._html
_search
_regex
(
113 (r
'<div class="tv_translation">\s*<h1><a href="[^"]+">([^<]*)</a>',
114 r
"'title'\s*:\s*'([^']+)'"),
115 webpage
, 'title', default
=None) or title
116 description
= self
._html
_search
_regex
(
117 r
'<div class="descr">\s*<div> </div>\s*<p>([^<]*)</p></div>',
118 webpage
, 'description', default
=None) or self
._html
_search
_meta
(
119 'description', webpage
, 'description')
120 thumbnail
= thumbnail
or self
._og
_search
_thumbnail
(webpage
)
121 duration
= int_or_none(self
._html
_search
_meta
(
122 'video:duration', webpage
, 'video duration', fatal
=False))
123 upload_date
= unified_strdate(self
._html
_search
_meta
(
124 'ya:ovs:upload_date', webpage
, 'upload date', fatal
=False))
128 'thumbnail': thumbnail
,
130 'description': description
,
131 'upload_date': upload_date
,
132 'duration': int_or_none(duration
),