From 4cda41ac7be1af03cb5fc4e9bbfcbf944925ab63 Mon Sep 17 00:00:00 2001 From: peugeot Date: Fri, 26 Dec 2014 16:17:35 +0100 Subject: [PATCH 1/2] [alphaporno] new extractor --- youtube_dl/extractor/__init__.py | 1 + youtube_dl/extractor/alphaporno.py | 54 ++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 youtube_dl/extractor/alphaporno.py diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index fd0ebffe3..3fd0240c3 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -7,6 +7,7 @@ from .adobetv import AdobeTVIE from .adultswim import AdultSwimIE from .aftonbladet import AftonbladetIE from .aljazeera import AlJazeeraIE +from .alphaporno import AlphaPornoIE from .anitube import AnitubeIE from .anysex import AnySexIE from .aol import AolIE diff --git a/youtube_dl/extractor/alphaporno.py b/youtube_dl/extractor/alphaporno.py new file mode 100644 index 000000000..c8eaf837f --- /dev/null +++ b/youtube_dl/extractor/alphaporno.py @@ -0,0 +1,54 @@ +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor + +class AlphaPornoIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?alphaporno\.com/videos/(?P[^/]+)' + _TEST = { + 'url': 'http://www.alphaporno.com/videos/sensual-striptease-porn-with-samantha-alexandra/', + 'md5': 'feb6d3bba8848cd54467a87ad34bd38e', + 'info_dict': { + 'id': '258807', + 'ext': 'mp4', + 'title': 'Sensual striptease porn with Samantha Alexandra - Striptease Porn', + 'description': 'md5:c4447dc80e5be4c5f2711f7806e45424', + 'categories': list, # NSFW + 'thumbnail': 're:https?://.*\.jpg$', + 'age_limit': 18, + } + } + + def _real_extract(self, url): + webpage = self._download_webpage(url, 'main') + + video_id = self._html_search_regex(r'video_id:\s*\'([^\']+)\'', webpage, 'id') + + video_url = self._html_search_regex(r'video_url:\s*\'([^\']+)\'', webpage, 'video_url') + + ext = self._html_search_meta('encodingFormat', webpage, 'ext')[1:] + + title = self._html_search_regex( + r'([^<]+)', webpage, 'title') + + description = self._html_search_meta('description', webpage, 'description', fatal=False) + + thumbnail = self._html_search_meta('thumbnail', webpage, 'thumbnail', fatal=False) + + categories_str = self._html_search_meta( + 'keywords', webpage, 'categories', fatal=False) + categories = ( + None if categories_str is None + else categories_str.split(',')) + + return { + 'id': video_id, + 'url': video_url, + 'title': title, + 'ext': ext, + 'description': description, + 'thumbnail': thumbnail, + 'categories': categories, + 'age_limit': 18, + } From e82def52a97faf85eeeedcac1266c27a565e2f21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Sat, 27 Dec 2014 00:08:04 +0600 Subject: [PATCH 2/2] [alphaporno] Improve --- youtube_dl/extractor/alphaporno.py | 71 ++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/youtube_dl/extractor/alphaporno.py b/youtube_dl/extractor/alphaporno.py index c8eaf837f..c34719d1f 100644 --- a/youtube_dl/extractor/alphaporno.py +++ b/youtube_dl/extractor/alphaporno.py @@ -1,54 +1,77 @@ from __future__ import unicode_literals -import re - from .common import InfoExtractor +from ..utils import ( + parse_iso8601, + parse_duration, + parse_filesize, + int_or_none, +) + class AlphaPornoIE(InfoExtractor): - _VALID_URL = r'https?://(?:www\.)?alphaporno\.com/videos/(?P[^/]+)' + _VALID_URL = r'https?://(?:www\.)?alphaporno\.com/videos/(?P[^/]+)' _TEST = { 'url': 'http://www.alphaporno.com/videos/sensual-striptease-porn-with-samantha-alexandra/', 'md5': 'feb6d3bba8848cd54467a87ad34bd38e', 'info_dict': { 'id': '258807', + 'display_id': 'sensual-striptease-porn-with-samantha-alexandra', 'ext': 'mp4', - 'title': 'Sensual striptease porn with Samantha Alexandra - Striptease Porn', - 'description': 'md5:c4447dc80e5be4c5f2711f7806e45424', - 'categories': list, # NSFW + 'title': 'Sensual striptease porn with Samantha Alexandra', 'thumbnail': 're:https?://.*\.jpg$', + 'timestamp': 1418694611, + 'upload_date': '20141216', + 'duration': 387, + 'filesize_approx': 54120000, + 'tbr': 1145, + 'categories': list, 'age_limit': 18, } } def _real_extract(self, url): - webpage = self._download_webpage(url, 'main') - - video_id = self._html_search_regex(r'video_id:\s*\'([^\']+)\'', webpage, 'id') - - video_url = self._html_search_regex(r'video_url:\s*\'([^\']+)\'', webpage, 'video_url') + display_id = self._match_id(url) - ext = self._html_search_meta('encodingFormat', webpage, 'ext')[1:] + webpage = self._download_webpage(url, display_id) - title = self._html_search_regex( - r'([^<]+)', webpage, 'title') + video_id = self._search_regex( + r"video_id\s*:\s*'([^']+)'", webpage, 'video id', default=None) - description = self._html_search_meta('description', webpage, 'description', fatal=False) + video_url = self._search_regex( + r"video_url\s*:\s*'([^']+)'", webpage, 'video url') + ext = self._html_search_meta( + 'encodingFormat', webpage, 'ext', default='.mp4')[1:] - thumbnail = self._html_search_meta('thumbnail', webpage, 'thumbnail', fatal=False) + title = self._search_regex( + [r'', + 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(',') - categories_str = self._html_search_meta( - 'keywords', webpage, 'categories', fatal=False) - categories = ( - None if categories_str is None - else categories_str.split(',')) + age_limit = self._rta_search(webpage) return { 'id': video_id, + 'display_id': display_id, 'url': video_url, - 'title': title, 'ext': ext, - 'description': description, + 'title': title, 'thumbnail': thumbnail, + 'timestamp': timestamp, + 'duration': duration, + 'filesize_approx': filesize_approx, + 'tbr': bitrate, 'categories': categories, - 'age_limit': 18, + 'age_limit': age_limit, }