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