1
0
mirror of https://github.com/l1ving/youtube-dl synced 2024-11-30 23:02:53 +08:00
youtube-dl/youtube_dl/extractor/empflix.py

55 lines
1.7 KiB
Python
Raw Normal View History

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