]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/funnyordie.py
4c4a87e2a3337bfb5de955a329c7edba2c338ad2
1 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..utils
import ExtractorError
10 class FunnyOrDieIE(InfoExtractor
):
11 _VALID_URL
= r
'https?://(?:www\.)?funnyordie\.com/(?P<type>embed|articles|videos)/(?P<id>[0-9a-f]+)(?:$|[?#/])'
13 'url': 'http://www.funnyordie.com/videos/0732f586d7/heart-shaped-box-literal-video-version',
14 'md5': 'bcd81e0c4f26189ee09be362ad6e6ba9',
18 'title': 'Heart-Shaped Box: Literal Video Version',
19 'description': 'md5:ea09a01bc9a1c46d9ab696c01747c338',
20 'thumbnail': 're:^http:.*\.jpg$',
23 'url': 'http://www.funnyordie.com/embed/e402820827',
27 'title': 'Please Use This Song (Jon Lajoie)',
28 'description': 'Please use this to sell something. www.jonlajoie.com',
29 'thumbnail': 're:^http:.*\.jpg$',
32 'url': 'http://www.funnyordie.com/articles/ebf5e34fc8/10-hours-of-walking-in-nyc-as-a-man',
33 'only_matching': True,
36 def _real_extract(self
, url
):
37 mobj
= re
.match(self
._VALID
_URL
, url
)
39 video_id
= mobj
.group('id')
40 webpage
= self
._download
_webpage
(url
, video_id
)
42 links
= re
.findall(r
'<source src="([^"]+/v)[^"]+\.([^"]+)" type=\'video
', webpage)
44 raise ExtractorError('No media links available
for %s' % video_id)
46 links.sort(key=lambda link: 1 if link[1] == 'mp4
' else 0)
48 m3u8_url = self._search_regex(
49 r'<source
[^
>]+src
=(["\'])(?P<url>.+?/master\.m3u8)\1',
50 webpage, 'm3u8 url', default=None, group='url')
54 formats.extend(self._extract_m3u8_formats(
55 m3u8_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False))
57 bitrates = [int(bitrate) for bitrate in re.findall(r'[,/]v(\d+)[,/]', m3u8_url)]
60 for bitrate in bitrates:
63 'url': self._proto_relative_url('%s%d.%s' % (link[0], bitrate, link[1])),
64 'format_id': '%s-%d' % (link[1], bitrate),
69 for src, src_lang in re.findall(r'<track kind="captions
" src="([^
"]+)" srclang
="([^"]+)"', webpage):
70 subtitles[src_lang] = [{
71 'ext': src.split('/')[-1],
72 'url': 'http://www.funnyordie.com%s' % src,
75 post_json = self._search_regex(
76 r'fb_post\s*=\s*(\{.*?\});', webpage, 'post details')
77 post = json.loads(post_json)
81 'title': post['name'],
82 'description': post.get('description'),
83 'thumbnail': post.get('picture'),
85 'subtitles': subtitles,