From 72c65d39ff4cfadba5eb5021c8dfd99e69c3e3a4 Mon Sep 17 00:00:00 2001 From: peugeot Date: Sat, 30 Aug 2014 18:37:45 +0200 Subject: [PATCH 1/4] Add support for AnySex --- youtube_dl/extractor/__init__.py | 1 + youtube_dl/extractor/anysex.py | 42 ++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 youtube_dl/extractor/anysex.py diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 1479d998a2..84f601cefb 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -4,6 +4,7 @@ from .adultswim import AdultSwimIE from .aftonbladet import AftonbladetIE from .anitube import AnitubeIE +from .anysex import AnySexIE from .aol import AolIE from .allocine import AllocineIE from .aparat import AparatIE diff --git a/youtube_dl/extractor/anysex.py b/youtube_dl/extractor/anysex.py new file mode 100644 index 0000000000..ef74805dd3 --- /dev/null +++ b/youtube_dl/extractor/anysex.py @@ -0,0 +1,42 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor + +class AnySexIE(InfoExtractor): + _VALID_URL = r'http?://(?:www\.)?anysex\.com/(?P\d+)/?' + _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', + 'duration': 270 + } + } + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + video_id = mobj.group('id') + + webpage = self._download_webpage(url, video_id) + title = self._html_search_regex(r'(.*?)', webpage, 'title') + video_url = self._html_search_regex(r'video_url: \'(.*?)\',', webpage, 'video_url') + thumbnail = self._html_search_regex(r'preview_url: \'(.*?)\',', webpage, 'thumbnail') + + mobj = re.search(r'Duration: (?P\d+):(?P\d+)<', webpage) + duration = int(mobj.group('minutes')) * 60 + int(mobj.group('seconds')) if mobj else None + + view_count = self._html_search_regex(r'Views: (\d+)', webpage, 'view count', fatal=False) + + return { + 'id': video_id, + 'ext': 'mp4', + 'url': video_url, + 'title': title, + 'duration': duration, + 'view_count': view_count + } From 0bafcf6f468985df5dfd3d402815a73e69193e2d Mon Sep 17 00:00:00 2001 From: peugeot Date: Sat, 30 Aug 2014 20:46:25 +0200 Subject: [PATCH 2/4] forgot to test view count --- youtube_dl/extractor/anysex.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/anysex.py b/youtube_dl/extractor/anysex.py index ef74805dd3..bfc7eb3c54 100644 --- a/youtube_dl/extractor/anysex.py +++ b/youtube_dl/extractor/anysex.py @@ -4,6 +4,7 @@ import re from .common import InfoExtractor +from ..utils import int_or_none class AnySexIE(InfoExtractor): _VALID_URL = r'http?://(?:www\.)?anysex\.com/(?P\d+)/?' @@ -14,7 +15,8 @@ class AnySexIE(InfoExtractor): 'id': '156592', 'ext': 'mp4', 'title': 'Busty and sexy blondie in her bikini strips for you', - 'duration': 270 + 'duration': 270, + 'view_count': 3652 } } @@ -38,5 +40,5 @@ def _real_extract(self, url): 'url': video_url, 'title': title, 'duration': duration, - 'view_count': view_count + 'view_count': int_or_none(view_count), } From 17b0b8a1661e0f51e17d1ed74307d79eaab1ccfd Mon Sep 17 00:00:00 2001 From: peugeot Date: Sat, 30 Aug 2014 20:55:42 +0200 Subject: [PATCH 3/4] testing view count is stupid --- youtube_dl/extractor/anysex.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/youtube_dl/extractor/anysex.py b/youtube_dl/extractor/anysex.py index bfc7eb3c54..d578a17122 100644 --- a/youtube_dl/extractor/anysex.py +++ b/youtube_dl/extractor/anysex.py @@ -16,7 +16,6 @@ class AnySexIE(InfoExtractor): 'ext': 'mp4', 'title': 'Busty and sexy blondie in her bikini strips for you', 'duration': 270, - 'view_count': 3652 } } @@ -39,6 +38,6 @@ def _real_extract(self, url): 'ext': 'mp4', 'url': video_url, 'title': title, - 'duration': duration, + 'duration': int_or_none(duration), 'view_count': int_or_none(view_count), } From 35241d05d11f713849678577b4d6ccdd25baedb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Sun, 31 Aug 2014 07:05:53 +0700 Subject: [PATCH 4/4] [anysex] Simplify and extract more metadata --- youtube_dl/extractor/anysex.py | 39 ++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/youtube_dl/extractor/anysex.py b/youtube_dl/extractor/anysex.py index d578a17122..adeacba01b 100644 --- a/youtube_dl/extractor/anysex.py +++ b/youtube_dl/extractor/anysex.py @@ -1,13 +1,16 @@ -# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor -from ..utils import int_or_none +from ..utils import ( + parse_duration, + int_or_none, +) + class AnySexIE(InfoExtractor): - _VALID_URL = r'http?://(?:www\.)?anysex\.com/(?P\d+)/?' + _VALID_URL = r'https?://(?:www\.)?anysex\.com/(?P\d+)' _TEST = { 'url': 'http://anysex.com/156592/', 'md5': '023e9fbb7f7987f5529a394c34ad3d3d', @@ -15,6 +18,8 @@ class AnySexIE(InfoExtractor): 'id': '156592', 'ext': 'mp4', 'title': 'Busty and sexy blondie in her bikini strips for you', + 'description': 'md5:de9e418178e2931c10b62966474e1383', + 'categories': ['Erotic'], 'duration': 270, } } @@ -24,20 +29,32 @@ def _real_extract(self, 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') + title = self._html_search_regex(r'(.*?)', webpage, 'title') - video_url = self._html_search_regex(r'video_url: \'(.*?)\',', webpage, 'video_url') - thumbnail = self._html_search_regex(r'preview_url: \'(.*?)\',', webpage, 'thumbnail') + description = self._html_search_regex( + r'
([^<]+)
', webpage, 'description', fatal=False) + thumbnail = self._html_search_regex( + r'preview_url\s*:\s*\'(.*?)\'', webpage, 'thumbnail', fatal=False) - mobj = re.search(r'Duration: (?P\d+):(?P\d+)<', webpage) - duration = int(mobj.group('minutes')) * 60 + int(mobj.group('seconds')) if mobj else None + categories = re.findall( + r'([^<]+)', webpage) - view_count = self._html_search_regex(r'Views: (\d+)', webpage, 'view count', fatal=False) + duration = parse_duration(self._search_regex( + r'Duration: (\d+:\d+)', webpage, 'duration', fatal=False)) + + view_count = int_or_none(self._html_search_regex( + r'Views: (\d+)', webpage, 'view count', fatal=False)) return { 'id': video_id, - 'ext': 'mp4', 'url': video_url, + 'ext': 'mp4', 'title': title, - 'duration': int_or_none(duration), - 'view_count': int_or_none(view_count), + 'description': description, + 'thumbnail': thumbnail, + 'categories': categories, + 'duration': duration, + 'view_count': view_count, }