From 1986025d2b90abbbb2b71a489ec67b5759e1dfab Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Sun, 23 Mar 2014 14:04:36 +0100 Subject: [PATCH] [xbef] (Add extractor) --- youtube_dl/extractor/__init__.py | 1 + youtube_dl/extractor/xbef.py | 50 ++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 youtube_dl/extractor/xbef.py diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 35f6e3358..b5c8ef682 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -285,6 +285,7 @@ from .weibo import WeiboIE from .wimp import WimpIE from .wistia import WistiaIE from .worldstarhiphop import WorldStarHipHopIE +from .xbef import XBefIE from .xhamster import XHamsterIE from .xnxx import XNXXIE from .xvideos import XVideosIE diff --git a/youtube_dl/extractor/xbef.py b/youtube_dl/extractor/xbef.py new file mode 100644 index 000000000..71bd7c463 --- /dev/null +++ b/youtube_dl/extractor/xbef.py @@ -0,0 +1,50 @@ +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..utils import ( + compat_urllib_parse, +) + + +class XBefIE(InfoExtractor): + _VALID_URL = r'http://(?:www\.)?xbef\.com/video/(?P[0-9]+)' + _TEST = { + 'url': 'http://xbef.com/video/5119-glamourous-lesbians-smoking-drinking-and-fucking', + 'md5': 'a478b565baff61634a98f5e5338be995', + 'info_dict': { + 'id': '5119', + 'ext': 'mp4', + 'title': 'md5:7358a9faef8b7b57acda7c04816f170e', + 'age_limit': 18, + 'thumbnail': 're:^http://.*\.jpg', + } + } + + def _real_extract(self, url): + m = re.match(self._VALID_URL, url) + video_id = m.group('id') + + webpage = self._download_webpage(url, video_id) + title = self._html_search_regex( + r']*>(.*?)', webpage, 'title') + + config_url_enc = self._download_webpage( + 'http://xbef.com/Main/GetVideoURLEncoded/%s' % video_id, video_id, + note='Retrieving config URL') + config_url = compat_urllib_parse.unquote(config_url_enc) + config = self._download_xml( + config_url, video_id, note='Retrieving config') + + video_url = config.find('./file').text + thumbnail = config.find('./image').text + + return { + 'id': video_id, + 'url': video_url, + 'title': title, + 'thumbnail': thumbnail, + 'age_limit': 18, + } + -- 2.22.2