3 from .common
import InfoExtractor
11 class XHamsterIE(InfoExtractor
):
12 """Information Extractor for xHamster"""
13 _VALID_URL
= r
'(?:http://)?(?:www.)?xhamster\.com/movies/(?P<id>[0-9]+)/.*\.html'
15 u
'url': u
'http://xhamster.com/movies/1509445/femaleagent_shy_beauty_takes_the_bait.html',
16 u
'file': u
'1509445.flv',
17 u
'md5': u
'9f48e0e8d58e3076bb236ff412ab62fa',
19 u
"upload_date": u
"20121014",
20 u
"uploader_id": u
"Ruseful2011",
21 u
"title": u
"FemaleAgent Shy beauty takes the bait"
25 def _real_extract(self
,url
):
26 mobj
= re
.match(self
._VALID
_URL
, url
)
28 video_id
= mobj
.group('id')
29 mrss_url
= 'http://xhamster.com/movies/%s/.html' % video_id
30 webpage
= self
._download
_webpage
(mrss_url
, video_id
)
32 mobj
= re
.search(r
'\'srv
\': \'(?P
<server
>[^
\']*)\',\s
*\'file\': \'(?P
<file>[^
\']+)\',', webpage)
34 raise ExtractorError(u'Unable to extract media URL
')
35 if len(mobj.group('server
')) == 0:
36 video_url = compat_urllib_parse.unquote(mobj.group('file'))
38 video_url = mobj.group('server
')+'/key
='+mobj.group('file')
39 video_extension = video_url.split('.')[-1]
41 video_title = self._html_search_regex(r'<title
>(?P
<title
>.+?
) - xHamster\
.com
</title
>',
44 # Can't see the description anywhere
in the UI
45 # video_description = self._html_search_regex(r'<span>Description: </span>(?P<description>[^<]+)',
46 # webpage, u'description', fatal=False)
47 # if video_description: video_description = unescapeHTML(video_description)
49 mobj
= re
.search(r
'hint=\'(?P
<upload_date_Y
>[0-9]{4}
)-(?P
<upload_date_m
>[0-9]{2}
)-(?P
<upload_date_d
>[0-9]{2}
) [0-9]{2}
:[0-9]{2}
:[0-9]{2}
[A
-Z
]{3,4}\'', webpage)
51 video_upload_date = mobj.group('upload_date_Y
')+mobj.group('upload_date_m
')+mobj.group('upload_date_d
')
53 video_upload_date = None
54 self._downloader.report_warning(u'Unable to extract upload date
')
56 video_uploader_id = self._html_search_regex(r'<a href
=\'/user
/[^
>]+>(?P
<uploader_id
>[^
<]+)',
57 webpage, u'uploader
id', default=u'anonymous
')
59 video_thumbnail = self._search_regex(r'\'image
\':\'(?P
<thumbnail
>[^
\']+)\'',
60 webpage, u'thumbnail
', fatal=False)
65 'ext
': video_extension,
67 # 'description
': video_description,
68 'upload_date
': video_upload_date,
69 'uploader_id
': video_uploader_id,
70 'thumbnail
': video_thumbnail