]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/malemotion.py
debian/patches: Removed, they came from upstream.
[youtubedl] / youtube_dl / extractor / malemotion.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..compat import compat_urllib_parse_unquote
6
7
8 class MalemotionIE(InfoExtractor):
9 _VALID_URL = r'https?://malemotion\.com/video/(.+?)\.(?P<id>.+?)(#|$)'
10 _TEST = {
11 'url': 'http://malemotion.com/video/bete-de-concours.ltc',
12 'md5': '3013e53a0afbde2878bc39998c33e8a5',
13 'info_dict': {
14 'id': 'ltc',
15 'ext': 'mp4',
16 'title': 'Bête de Concours',
17 'age_limit': 18,
18 },
19 }
20
21 def _real_extract(self, url):
22 video_id = self._match_id(url)
23 webpage = self._download_webpage(url, video_id)
24
25 video_url = compat_urllib_parse_unquote(self._search_regex(
26 r'<source type="video/mp4" src="(.+?)"', webpage, 'video URL'))
27 video_title = self._html_search_regex(
28 r'<title>(.*?)</title', webpage, 'title')
29 video_thumbnail = self._search_regex(
30 r'<video .+?poster="(.+?)"', webpage, 'thumbnail', fatal=False)
31
32 formats = [{
33 'url': video_url,
34 'ext': 'mp4',
35 'format_id': 'mp4',
36 'preference': 1,
37 }]
38 self._sort_formats(formats)
39
40 return {
41 'id': video_id,
42 'formats': formats,
43 'title': video_title,
44 'thumbnail': video_thumbnail,
45 'age_limit': 18,
46 }