diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2014-02-08 19:20:11 +0100 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2014-02-08 19:20:23 +0100 |
commit | 9766538124384b75c6b6cdfd8cb03ddce30136dc (patch) | |
tree | d56ae6dec3de43a0b14cd7a6a6ea14005aa430ad /youtube_dl/extractor | |
parent | 98dbee86815cad4d1fe1befab328033a16c56df6 (diff) |
[jadorecettepub] Add extractor (Fixes #2148)
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r-- | youtube_dl/extractor/__init__.py | 1 | ||||
-rw-r--r-- | youtube_dl/extractor/jadorecettepub.py | 49 | ||||
-rw-r--r-- | youtube_dl/extractor/youtube.py | 7 |
3 files changed, 54 insertions, 3 deletions
diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index bc1e57aff..4678cf06c 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -105,6 +105,7 @@ from .ivi import ( IviIE, IviCompilationIE ) +from .jadorecettepub import JadoreCettePubIE from .jeuxvideo import JeuxVideoIE from .jukebox import JukeboxIE from .justintv import JustinTVIE diff --git a/youtube_dl/extractor/jadorecettepub.py b/youtube_dl/extractor/jadorecettepub.py new file mode 100644 index 000000000..d918fff81 --- /dev/null +++ b/youtube_dl/extractor/jadorecettepub.py @@ -0,0 +1,49 @@ +# coding: utf-8 + +from __future__ import unicode_literals + +import json +import re + +from .common import InfoExtractor +from .youtube import YoutubeIE + + +class JadoreCettePubIE(InfoExtractor): + _VALID_URL = r'http://(?:www\.)?jadorecettepub\.com/[0-9]{4}/[0-9]{2}/(?P<id>.*?)\.html' + + _TEST = { + 'url': 'http://www.jadorecettepub.com/2010/12/star-wars-massacre-par-les-japonais.html', + 'md5': '401286a06067c70b44076044b66515de', + 'info_dict': { + 'id': 'jLMja3tr7a4', + 'ext': 'mp4', + 'title': 'La pire utilisation de Star Wars', + 'description': "Jadorecettepub.com vous a gratifié de plusieurs pubs géniales utilisant Star Wars et Dark Vador plus particulièrement... Mais l'heure est venue de vous proposer une version totalement massacrée, venue du Japon. Quand les Japonais détruisent l'image de Star Wars pour vendre du thon en boite, ça promet...", + }, + } + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + display_id = mobj.group('id') + + webpage = self._download_webpage(url, display_id) + + title = self._html_search_regex( + r'<span style="font-size: x-large;"><b>(.*?)</b></span>', + webpage, 'title') + description = self._html_search_regex( + r'(?s)<div id="fb-root">(.*?)<script>', webpage, 'description', + fatal=False) + real_url = self._search_regex( + r'\[/postlink\](.*)endofvid', webpage, 'video URL') + video_id = YoutubeIE.extract_id(real_url) + + return { + '_type': 'url_transparent', + 'url': real_url, + 'id': video_id, + 'title': title, + 'description': description, + } + diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index 765c690f1..e038c7752 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -1085,8 +1085,9 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor): self._downloader.report_warning(err_msg) return {} - def _extract_id(self, url): - mobj = re.match(self._VALID_URL, url, re.VERBOSE) + @classmethod + def extract_id(cls, url): + mobj = re.match(cls._VALID_URL, url, re.VERBOSE) if mobj is None: raise ExtractorError(u'Invalid URL: %s' % url) video_id = mobj.group(2) @@ -1115,7 +1116,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor): mobj = re.search(self._NEXT_URL_RE, url) if mobj: url = 'https://www.youtube.com/' + compat_urllib_parse.unquote(mobj.group(1)).lstrip('/') - video_id = self._extract_id(url) + video_id = self.extract_id(url) # Get video webpage url = 'https://www.youtube.com/watch?v=%s&gl=US&hl=en&has_verified=1' % video_id |