1
0
mirror of https://github.com/l1ving/youtube-dl synced 2024-11-30 15:32:52 +08:00
youtube-dl/youtube_dl/extractor/anysex.py

62 lines
2.0 KiB
Python
Raw Normal View History

2014-08-31 00:37:45 +08:00
from __future__ import unicode_literals
import re
from .common import InfoExtractor
from ..utils import (
parse_duration,
int_or_none,
)
2014-08-31 00:37:45 +08:00
class AnySexIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?anysex\.com/(?P<id>\d+)'
2014-08-31 00:37:45 +08:00
_TEST = {
'url': 'http://anysex.com/156592/',
'md5': '023e9fbb7f7987f5529a394c34ad3d3d',
'info_dict': {
'id': '156592',
'ext': 'mp4',
'title': 'Busty and sexy blondie in her bikini strips for you',
'description': 'md5:de9e418178e2931c10b62966474e1383',
'categories': ['Erotic'],
2014-08-31 02:46:25 +08:00
'duration': 270,
2014-09-02 04:58:59 +08:00
'age_limit': 18,
2014-08-31 00:37:45 +08:00
}
}
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id')
webpage = self._download_webpage(url, video_id)
video_url = self._html_search_regex(r"video_url\s*:\s*'([^']+)'", webpage, 'video URL')
2014-08-31 00:37:45 +08:00
title = self._html_search_regex(r'<title>(.*?)</title>', webpage, 'title')
description = self._html_search_regex(
2014-09-27 23:29:27 +08:00
r'<div class="description"[^>]*>([^<]+)</div>', webpage, 'description', fatal=False)
thumbnail = self._html_search_regex(
r'preview_url\s*:\s*\'(.*?)\'', webpage, 'thumbnail', fatal=False)
2014-08-31 00:37:45 +08:00
categories = re.findall(
r'<a href="http://anysex\.com/categories/[^"]+" title="[^"]*">([^<]+)</a>', webpage)
2014-08-31 00:37:45 +08:00
duration = parse_duration(self._search_regex(
2014-09-27 23:29:27 +08:00
r'<b>Duration:</b> (?:<q itemprop="duration">)?(\d+:\d+)', webpage, 'duration', fatal=False))
view_count = int_or_none(self._html_search_regex(
r'<b>Views:</b> (\d+)', webpage, 'view count', fatal=False))
2014-08-31 00:37:45 +08:00
return {
'id': video_id,
'url': video_url,
'ext': 'mp4',
2014-08-31 00:37:45 +08:00
'title': title,
'description': description,
'thumbnail': thumbnail,
'categories': categories,
'duration': duration,
'view_count': view_count,
2014-09-02 04:58:59 +08:00
'age_limit': 18,
2014-08-31 00:37:45 +08:00
}