]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/youjizz.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
14 class YouJizzIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:\w+\.)?youjizz\.com/videos/(?:[^/#?]*-(?P<id>\d+)\.html|embed/(?P<embed_id>\d+))'
17 'url': 'http://www.youjizz.com/videos/zeichentrick-1-2189178.html',
18 'md5': 'b1e1dfaa8bb9537d8b84eeda9cf4acf4',
22 'title': 'Zeichentrick 1',
27 'url': 'http://www.youjizz.com/videos/-2189178.html',
28 'only_matching': True,
30 'url': 'https://www.youjizz.com/videos/embed/31991001',
31 'only_matching': True,
34 def _real_extract(self
, url
):
35 mobj
= re
.match(self
._VALID
_URL
, url
)
36 video_id
= mobj
.group('id') or mobj
.group('embed_id')
38 webpage
= self
._download
_webpage
(url
, video_id
)
40 title
= self
._html
_search
_regex
(
41 r
'<title>(.+?)</title>', webpage
, 'title')
45 encodings
= self
._parse
_json
(
47 r
'[Ee]ncodings\s*=\s*(\[.+?\]);\n', webpage
, 'encodings',
49 video_id
, fatal
=False)
50 for encoding
in encodings
:
51 if not isinstance(encoding
, dict):
53 format_url
= url_or_none(encoding
.get('filename'))
56 if determine_ext(format_url
) == 'm3u8':
57 formats
.extend(self
._extract
_m
3u8_formats
(
58 format_url
, video_id
, 'mp4', entry_protocol
='m3u8_native',
59 m3u8_id
='hls', fatal
=False))
61 format_id
= encoding
.get('name') or encoding
.get('quality')
62 height
= int_or_none(self
._search
_regex
(
63 r
'^(\d+)[pP]', format_id
, 'height', default
=None))
66 'format_id': format_id
,
75 # YouJizz's HTML5 player has invalid HTML
76 webpage
= webpage
.replace('"controls', '" controls')
77 info_dict
= self
._parse
_html
5_media
_entries
(
78 url
, webpage
, video_id
)[0]
80 duration
= parse_duration(self
._search
_regex
(
81 r
'<strong>Runtime:</strong>([^<]+)', webpage
, 'duration',
83 uploader
= self
._search
_regex
(
84 r
'<strong>Uploaded By:.*?<a[^>]*>([^<]+)', webpage
, 'uploader',
90 'age_limit': self
._rta
_search
(webpage
),