youtube-dl/youtube_dl/extractor/empflix.py

59 lines
1.8 KiB
Python
Raw Normal View History

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