]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/funnyordie.py
3045978f1b35cff1552b9b0dbf12f7a7ff522989
[youtubedl] / youtube_dl / extractor / funnyordie.py
1 import re
2
3 from .common import InfoExtractor
4
5
6 class FunnyOrDieIE(InfoExtractor):
7 _VALID_URL = r'^(?:https?://)?(?:www\.)?funnyordie\.com/videos/(?P<id>[0-9a-f]+)/.*$'
8
9 def _real_extract(self, url):
10 mobj = re.match(self._VALID_URL, url)
11
12 video_id = mobj.group('id')
13 webpage = self._download_webpage(url, video_id)
14
15 video_url = self._html_search_regex(r'<video[^>]*>\s*<source[^>]*>\s*<source src="(?P<url>[^"]+)"',
16 webpage, u'video URL', flags=re.DOTALL)
17
18 title = self._html_search_regex((r"<h1 class='player_page_h1'.*?>(?P<title>.*?)</h1>",
19 r'<title>(?P<title>[^<]+?)</title>'), webpage, 'title', flags=re.DOTALL)
20
21 video_description = self._html_search_regex(r'<meta property="og:description" content="(?P<desc>.*?)"',
22 webpage, u'description', fatal=False, flags=re.DOTALL)
23
24 info = {
25 'id': video_id,
26 'url': video_url,
27 'ext': 'mp4',
28 'title': title,
29 'description': video_description,
30 }
31 return [info]