X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Flifenews.py;h=42cb6e35f821256e90c8eef4f176812e3e0f42d0;hb=db3ca36403930063b7df3b228a3f297bf278b43c;hp=963f16e1ab317b652a4c9ed7dc771d98add35a0e;hpb=07d2921c6d13ce43adb9347677e50c36268fe54f;p=youtube-dl diff --git a/youtube_dl/extractor/lifenews.py b/youtube_dl/extractor/lifenews.py index 963f16e1a..42cb6e35f 100644 --- a/youtube_dl/extractor/lifenews.py +++ b/youtube_dl/extractor/lifenews.py @@ -4,7 +4,9 @@ from __future__ import unicode_literals import re from .common import InfoExtractor +from ..compat import compat_urlparse from ..utils import ( + determine_ext, int_or_none, unified_strdate, ExtractorError, @@ -14,7 +16,7 @@ from ..utils import ( class LifeNewsIE(InfoExtractor): IE_NAME = 'lifenews' IE_DESC = 'LIFE | NEWS' - _VALID_URL = r'http://lifenews\.ru/(?:mobile/)?news/(?P\d+)' + _VALID_URL = r'http://lifenews\.ru/(?:mobile/)?(?P
news|video)/(?P\d+)' _TESTS = [{ 'url': 'http://lifenews.ru/news/126342', @@ -50,17 +52,23 @@ class LifeNewsIE(InfoExtractor): 'upload_date': '20150505', 'uploader': 'embed.life.ru', } + }, { + 'url': 'http://lifenews.ru/video/13035', + 'only_matching': True, }] def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') + section = mobj.group('section') - webpage = self._download_webpage('http://lifenews.ru/news/%s' % video_id, video_id, 'Downloading page') + webpage = self._download_webpage( + 'http://lifenews.ru/%s/%s' % (section, video_id), + video_id, 'Downloading page') videos = re.findall(r'[^"]+)".*?src="(?P', webpage) iframe_link = self._html_search_regex( - ']+src="([^"]+)', webpage, 'iframe link', default=None) + ']+src=["\']([^"\']+)["\']', webpage, 'iframe link', default=None) if not videos and not iframe_link: raise ExtractorError('No media links available for %s' % video_id) @@ -99,8 +107,7 @@ class LifeNewsIE(InfoExtractor): return cur_info if iframe_link: - if iframe_link.startswith('//'): - iframe_link = 'http:' + iframe_link + iframe_link = self._proto_relative_url(iframe_link, 'http:') cur_info = dict(common_info) cur_info.update({ '_type': 'url_transparent', @@ -114,3 +121,49 @@ class LifeNewsIE(InfoExtractor): return make_entry(video_id, videos[0]) else: return [make_entry(video_id, media, video_number + 1) for video_number, media in enumerate(videos)] + + +class LifeEmbedIE(InfoExtractor): + IE_NAME = 'life:embed' + _VALID_URL = r'http://embed\.life\.ru/embed/(?P[\da-f]{32})' + + _TEST = { + 'url': 'http://embed.life.ru/embed/e50c2dec2867350528e2574c899b8291', + 'md5': 'b889715c9e49cb1981281d0e5458fbbe', + 'info_dict': { + 'id': 'e50c2dec2867350528e2574c899b8291', + 'ext': 'mp4', + 'title': 'e50c2dec2867350528e2574c899b8291', + 'thumbnail': 're:http://.*\.jpg', + } + } + + def _real_extract(self, url): + video_id = self._match_id(url) + + webpage = self._download_webpage(url, video_id) + + formats = [] + for video_url in re.findall(r'"file"\s*:\s*"([^"]+)', webpage): + video_url = compat_urlparse.urljoin(url, video_url) + ext = determine_ext(video_url) + if ext == 'm3u8': + formats.extend(self._extract_m3u8_formats( + video_url, video_id, 'mp4', m3u8_id='m3u8')) + else: + formats.append({ + 'url': video_url, + 'format_id': ext, + 'preference': 1, + }) + self._sort_formats(formats) + + thumbnail = self._search_regex( + r'"image"\s*:\s*"([^"]+)', webpage, 'thumbnail', default=None) + + return { + 'id': video_id, + 'title': video_id, + 'thumbnail': thumbnail, + 'formats': formats, + }