youtube-dl/youtube_dl/extractor/empflix.py

57 lines
1.7 KiB
Python
Raw Normal View History

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