yt-dlc/youtube_dl/extractor/alphaporno.py

78 lines
2.7 KiB
Python
Raw Normal View History

2014-12-26 15:17:35 +00:00
from __future__ import unicode_literals
from .common import InfoExtractor
2014-12-26 18:08:04 +00:00
from ..utils import (
parse_iso8601,
parse_duration,
parse_filesize,
int_or_none,
)
2014-12-26 15:17:35 +00:00
class AlphaPornoIE(InfoExtractor):
2014-12-26 18:08:04 +00:00
_VALID_URL = r'https?://(?:www\.)?alphaporno\.com/videos/(?P<id>[^/]+)'
2014-12-26 15:17:35 +00:00
_TEST = {
'url': 'http://www.alphaporno.com/videos/sensual-striptease-porn-with-samantha-alexandra/',
'md5': 'feb6d3bba8848cd54467a87ad34bd38e',
'info_dict': {
'id': '258807',
2014-12-26 18:08:04 +00:00
'display_id': 'sensual-striptease-porn-with-samantha-alexandra',
2014-12-26 15:17:35 +00:00
'ext': 'mp4',
2014-12-26 18:08:04 +00:00
'title': 'Sensual striptease porn with Samantha Alexandra',
'thumbnail': r're:https?://.*\.jpg$',
2014-12-26 18:08:04 +00:00
'timestamp': 1418694611,
'upload_date': '20141216',
'duration': 387,
'filesize_approx': 54120000,
'tbr': 1145,
'categories': list,
2014-12-26 15:17:35 +00:00
'age_limit': 18,
}
}
def _real_extract(self, url):
2014-12-26 18:08:04 +00:00
display_id = self._match_id(url)
2014-12-26 15:17:35 +00:00
2014-12-26 18:08:04 +00:00
webpage = self._download_webpage(url, display_id)
2014-12-26 15:17:35 +00:00
2014-12-26 18:08:04 +00:00
video_id = self._search_regex(
r"video_id\s*:\s*'([^']+)'", webpage, 'video id', default=None)
2014-12-26 15:17:35 +00:00
2014-12-26 18:08:04 +00:00
video_url = self._search_regex(
r"video_url\s*:\s*'([^']+)'", webpage, 'video url')
ext = self._html_search_meta(
'encodingFormat', webpage, 'ext', default='.mp4')[1:]
2014-12-26 15:17:35 +00:00
2014-12-26 18:08:04 +00:00
title = self._search_regex(
[r'<meta content="([^"]+)" itemprop="description">',
r'class="title" itemprop="name">([^<]+)<'],
webpage, 'title')
thumbnail = self._html_search_meta('thumbnail', webpage, 'thumbnail')
timestamp = parse_iso8601(self._html_search_meta(
'uploadDate', webpage, 'upload date'))
duration = parse_duration(self._html_search_meta(
'duration', webpage, 'duration'))
filesize_approx = parse_filesize(self._html_search_meta(
'contentSize', webpage, 'file size'))
bitrate = int_or_none(self._html_search_meta(
'bitrate', webpage, 'bitrate'))
categories = self._html_search_meta(
'keywords', webpage, 'categories', default='').split(',')
2014-12-26 15:17:35 +00:00
2014-12-26 18:08:04 +00:00
age_limit = self._rta_search(webpage)
2014-12-26 15:17:35 +00:00
return {
'id': video_id,
2014-12-26 18:08:04 +00:00
'display_id': display_id,
2014-12-26 15:17:35 +00:00
'url': video_url,
'ext': ext,
2014-12-26 18:08:04 +00:00
'title': title,
2014-12-26 15:17:35 +00:00
'thumbnail': thumbnail,
2014-12-26 18:08:04 +00:00
'timestamp': timestamp,
'duration': duration,
'filesize_approx': filesize_approx,
'tbr': bitrate,
2014-12-26 15:17:35 +00:00
'categories': categories,
2014-12-26 18:08:04 +00:00
'age_limit': age_limit,
2014-12-26 15:17:35 +00:00
}