]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/malemotion.py
Imported Upstream version 2014.12.01
[youtubedl] / 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
11 class MalemotionIE(InfoExtractor):
12 _VALID_URL = r'^(?:https?://)?malemotion\.com/video/(.+?)\.(?P<id>.+?)(#|$)'
13 _TEST = {
14 'url': 'http://malemotion.com/video/bien-dur.10ew',
15 'file': '10ew.mp4',
16 'md5': 'b3cc49f953b107e4a363cdff07d100ce',
17 'info_dict': {
18 "title": "Bien dur",
19 "age_limit": 18,
20 },
21 'skip': 'This video has been deleted.'
22 }
23
24 def _real_extract(self, url):
25 mobj = re.match(self._VALID_URL, url)
26 video_id = mobj.group("id")
27
28 webpage = self._download_webpage(url, video_id)
29
30 self.report_extraction(video_id)
31
32 # Extract video URL
33 video_url = compat_urllib_parse.unquote(
34 self._search_regex(r'<source type="video/mp4" src="(.+?)"', webpage, 'video URL'))
35
36 # Extract title
37 video_title = self._html_search_regex(
38 r'<title>(.*?)</title', webpage, 'title')
39
40 # Extract video thumbnail
41 video_thumbnail = self._search_regex(
42 r'<video .+?poster="(.+?)"', webpage, 'thumbnail', fatal=False)
43
44 formats = [{
45 'url': video_url,
46 'ext': 'mp4',
47 'format_id': 'mp4',
48 'preference': 1,
49 }]
50
51 return {
52 'id': video_id,
53 'formats': formats,
54 'uploader': None,
55 'upload_date': None,
56 'title': video_title,
57 'thumbnail': video_thumbnail,
58 'description': None,
59 'age_limit': 18,
60 }