]> jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/malemotion.py
Merge remote-tracking branch 'sahutd/master'
[yt-dlp.git] / youtube_dl / extractor / malemotion.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import (
7 compat_urllib_parse,
8 )
9
10 class MalemotionIE(InfoExtractor):
11 _VALID_URL = r'^(?:https?://)?malemotion\.com/video/(.+?)\.(?P<id>.+?)(#|$)'
12 _TEST = {
13 'url': 'http://malemotion.com/video/bien-dur.10ew',
14 'file': '10ew.mp4',
15 'md5': 'b3cc49f953b107e4a363cdff07d100ce',
16 'info_dict': {
17 "title": "Bien dur",
18 "age_limit": 18,
19 }
20 }
21
22 def _real_extract(self, url):
23 mobj = re.match(self._VALID_URL, url)
24 video_id = mobj.group("id")
25
26 webpage = self._download_webpage(url, video_id)
27
28 self.report_extraction(video_id)
29
30 # Extract video URL
31 video_url = compat_urllib_parse.unquote(
32 self._search_regex(r'<source type="video/mp4" src="(.+?)"', webpage, 'video URL'))
33
34 # Extract title
35 video_title = self._html_search_regex(
36 r'<title>(.*?)</title', webpage, 'title')
37
38 # Extract video thumbnail
39 video_thumbnail = self._search_regex(
40 r'<video .+?poster="(.+?)"', webpage, 'thumbnail', fatal=False)
41
42 formats = [{
43 'url': video_url,
44 'ext': 'mp4',
45 'format_id': 'mp4',
46 'preference': 1,
47 }]
48
49 return {
50 'id': video_id,
51 'formats': formats,
52 'uploader': None,
53 'upload_date': None,
54 'title': video_title,
55 'thumbnail': video_thumbnail,
56 'description': None,
57 'age_limit': 18,
58 }