]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/funnyordie.py
7c40e675398f7738bda09827031cfb99c620a17a
[youtubedl] / youtube_dl / extractor / funnyordie.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6
7
8 class FunnyOrDieIE(InfoExtractor):
9 _VALID_URL = r'^(?:https?://)?(?:www\.)?funnyordie\.com/videos/(?P<id>[0-9a-f]+)/.*$'
10 _TEST = {
11 'url': 'http://www.funnyordie.com/videos/0732f586d7/heart-shaped-box-literal-video-version',
12 'file': '0732f586d7.mp4',
13 'md5': 'f647e9e90064b53b6e046e75d0241fbd',
14 'info_dict': {
15 'description': ('Lyrics changed to match the video. Spoken cameo '
16 'by Obscurus Lupa (from ThatGuyWithTheGlasses.com). Based on a '
17 'concept by Dustin McLean (DustFilms.com). Performed, edited, '
18 'and written by David A. Scott.'),
19 'title': 'Heart-Shaped Box: Literal Video Version',
20 },
21 }
22
23 def _real_extract(self, url):
24 mobj = re.match(self._VALID_URL, url)
25
26 video_id = mobj.group('id')
27 webpage = self._download_webpage(url, video_id)
28
29 video_url = self._search_regex(
30 [r'type="video/mp4" src="(.*?)"', r'src="([^>]*?)" type=\'video/mp4\''],
31 webpage, 'video URL', flags=re.DOTALL)
32
33 return {
34 'id': video_id,
35 'url': video_url,
36 'ext': 'mp4',
37 'title': self._og_search_title(webpage),
38 'description': self._og_search_description(webpage),
39 }