2 from __future__ import unicode_literals
6 from .common import InfoExtractor
13 _x = lambda p: xpath_with_ns(p, {'xspf': 'http://xspf.org/ns/0/'})
14 _find = lambda el, p: el.find(_x(p)).text.strip()
17 class NosVideoIE(InfoExtractor):
18 _VALID_URL = r'https?://(?:www\.)?nosvideo\.com/' + \
19 '(?:embed/|\?v=)(?P<id>[A-Za-z0-9]{12})/?'
20 _PLAYLIST_URL = 'http://nosvideo.com/xml/{xml_id:s}.xml'
22 'url': 'http://nosvideo.com/?v=drlp6s40kg54',
23 'md5': '4b4ac54c6ad5d70ab88f2c2c6ccec71c',
27 'title': 'big_buck_bunny_480p_surround-fix.avi.mp4',
28 'thumbnail': 're:^https?://.*\.jpg$',
32 def _real_extract(self, url):
33 mobj = re.match(self._VALID_URL, url)
34 video_id = mobj.group('id')
39 'method_free': 'Continue to Video',
41 post = compat_urllib_parse.urlencode(fields)
42 req = compat_urllib_request.Request(url, post)
43 req.add_header('Content-type', 'application/x-www-form-urlencoded')
44 webpage = self._download_webpage(req, video_id,
45 'Downloading download page')
46 xml_id = self._search_regex(r'php\|([^\|]+)\|', webpage, 'XML ID')
47 playlist_url = self._PLAYLIST_URL.format(xml_id=xml_id)
48 playlist = self._download_xml(playlist_url, video_id)
50 track = playlist.find(_x('.//xspf:track'))
51 title = _find(track, './xspf:title')
52 url = _find(track, './xspf:file')
53 thumbnail = _find(track, './xspf:image')
63 'thumbnail': thumbnail,