]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/xbef.py
1b4e883652667f2c2109d34014154c71fd443196
[youtubedl] / youtube_dl / extractor / xbef.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import (
7 compat_urllib_parse,
8 )
9
10
11 class XBefIE(InfoExtractor):
12 _VALID_URL = r'http://(?:www\.)?xbef\.com/video/(?P<id>[0-9]+)'
13 _TEST = {
14 'url': 'http://xbef.com/video/5119-glamourous-lesbians-smoking-drinking-and-fucking',
15 'md5': 'a478b565baff61634a98f5e5338be995',
16 'info_dict': {
17 'id': '5119',
18 'ext': 'mp4',
19 'title': 'md5:7358a9faef8b7b57acda7c04816f170e',
20 'age_limit': 18,
21 'thumbnail': 're:^http://.*\.jpg',
22 }
23 }
24
25 def _real_extract(self, url):
26 m = re.match(self._VALID_URL, url)
27 video_id = m.group('id')
28
29 webpage = self._download_webpage(url, video_id)
30 title = self._html_search_regex(
31 r'<h1[^>]*>(.*?)</h1>', webpage, 'title')
32
33 config_url_enc = self._download_webpage(
34 'http://xbef.com/Main/GetVideoURLEncoded/%s' % video_id, video_id,
35 note='Retrieving config URL')
36 config_url = compat_urllib_parse.unquote(config_url_enc)
37 config = self._download_xml(
38 config_url, video_id, note='Retrieving config')
39
40 video_url = config.find('./file').text
41 thumbnail = config.find('./image').text
42
43 return {
44 'id': video_id,
45 'url': video_url,
46 'title': title,
47 'thumbnail': thumbnail,
48 'age_limit': 18,
49 }