]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/gazeta.py
Prepare for upload.
[youtubedl] / youtube_dl / extractor / gazeta.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7
8
9 class GazetaIE(InfoExtractor):
10 _VALID_URL = r'(?P<url>https?://(?:www\.)?gazeta\.ru/(?:[^/]+/)?video/(?:(?:main|\d{4}/\d{2}/\d{2})/)?(?P<id>[A-Za-z0-9-_.]+)\.s?html)'
11 _TESTS = [{
12 'url': 'http://www.gazeta.ru/video/main/zadaite_vopros_vladislavu_yurevichu.shtml',
13 'md5': 'd49c9bdc6e5a7888f27475dc215ee789',
14 'info_dict': {
15 'id': '205566',
16 'ext': 'mp4',
17 'title': '«70–80 процентов гражданских в Донецке на грани голода»',
18 'description': 'md5:38617526050bd17b234728e7f9620a71',
19 'thumbnail': 're:^https?://.*\.jpg',
20 },
21 }, {
22 'url': 'http://www.gazeta.ru/lifestyle/video/2015/03/08/master-klass_krasivoi_byt._delaem_vesennii_makiyazh.shtml',
23 'only_matching': True,
24 }]
25
26 def _real_extract(self, url):
27 mobj = re.match(self._VALID_URL, url)
28
29 display_id = mobj.group('id')
30 embed_url = '%s?p=embed' % mobj.group('url')
31 embed_page = self._download_webpage(
32 embed_url, display_id, 'Downloading embed page')
33
34 video_id = self._search_regex(
35 r'<div[^>]*?class="eagleplayer"[^>]*?data-id="([^"]+)"', embed_page, 'video id')
36
37 return self.url_result(
38 'eagleplatform:gazeta.media.eagleplatform.com:%s' % video_id, 'EaglePlatform')