youtube-dl/youtube_dl/extractor/empflix.py

61 lines
1.9 KiB
Python
Raw Normal View History

2014-05-13 01:14:05 -07:00
from __future__ import unicode_literals
2014-05-12 04:10:29 -07:00
import re
from .common import InfoExtractor
2014-05-13 01:14:05 -07:00
2014-05-12 04:10:29 -07:00
class EmpflixIE(InfoExtractor):
2014-05-13 01:14:05 -07:00
_VALID_URL = r'^https?://www\.empflix\.com/videos/.*?-(?P<id>[0-9]+)\.html'
2014-05-12 04:10:29 -07:00
_TEST = {
2014-05-13 01:14:05 -07:00
'url': 'http://www.empflix.com/videos/Amateur-Finger-Fuck-33051.html',
2014-05-23 11:06:03 -07:00
'md5': 'b1bc15b6412d33902d6e5952035fcabc',
2014-05-13 01:14:05 -07:00
'info_dict': {
'id': '33051',
2014-05-23 11:06:03 -07:00
'ext': 'mp4',
2014-05-13 01:14:05 -07:00
'title': 'Amateur Finger Fuck',
2014-05-23 11:06:03 -07:00
'description': 'Amateur solo finger fucking.',
2014-05-13 01:14:05 -07:00
'age_limit': 18,
2014-05-12 04:10:29 -07:00
}
}
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
2014-05-13 01:14:05 -07:00
video_id = mobj.group('id')
2014-05-12 04:10:29 -07:00
webpage = self._download_webpage(url, video_id)
age_limit = self._rta_search(webpage)
2014-05-13 01:14:05 -07:00
video_title = self._html_search_regex(
r'name="title" value="(?P<title>[^"]*)"', webpage, 'title')
2014-05-23 11:06:03 -07:00
video_description = self._html_search_regex(
r'name="description" value="([^"]*)"', webpage, 'description', fatal=False)
2014-05-12 04:10:29 -07:00
2014-05-13 01:14:05 -07:00
cfg_url = self._html_search_regex(
r'flashvars\.config = escape\("([^"]+)"',
webpage, 'flashvars.config')
2014-05-12 04:10:29 -07:00
# XML is malformed
cfg_xml = self._download_webpage(
2014-05-13 01:14:05 -07:00
cfg_url, video_id, note='Downloading metadata')
2014-05-23 11:06:03 -07:00
formats = [
{
'url': item[1],
'format_id': item[0],
} for item in re.findall(
r'<item>\s*<res>([^>]+)</res>\s*<videoLink>([^<]+)</videoLink>\s*</item>', cfg_xml)
2014-05-23 11:06:03 -07:00
]
2014-05-12 04:10:29 -07:00
2014-08-26 06:10:36 -07:00
thumbnail = self._html_search_regex(
r'<startThumb>([^<]+)</startThumb>', cfg_xml, 'thumbnail', fatal=False)
2014-05-13 01:14:05 -07:00
return {
'id': video_id,
'title': video_title,
2014-05-23 11:06:03 -07:00
'description': video_description,
2014-08-26 06:10:36 -07:00
'thumbnail': thumbnail,
2014-05-23 11:06:03 -07:00
'formats': formats,
2014-05-13 01:14:05 -07:00
'age_limit': age_limit,
}