]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/clipsyndicate.py
debian/NEWS: Fix oversight with version and distribution.
[youtubedl] / youtube_dl / extractor / clipsyndicate.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import (
5 find_xpath_attr,
6 fix_xml_ampersands
7 )
8
9
10 class ClipsyndicateIE(InfoExtractor):
11 _VALID_URL = r'http://www\.clipsyndicate\.com/video/play(list/\d+)?/(?P<id>\d+)'
12
13 _TEST = {
14 u'url': u'http://www.clipsyndicate.com/video/play/4629301/brick_briscoe',
15 u'md5': u'4d7d549451bad625e0ff3d7bd56d776c',
16 u'info_dict': {
17 u'id': u'4629301',
18 u'ext': u'mp4',
19 u'title': u'Brick Briscoe',
20 u'duration': 612,
21 },
22 }
23
24 def _real_extract(self, url):
25 mobj = re.match(self._VALID_URL, url)
26 video_id = mobj.group('id')
27 js_player = self._download_webpage(
28 'http://eplayer.clipsyndicate.com/embed/player.js?va_id=%s' % video_id,
29 video_id, u'Downlaoding player')
30 # it includes a required token
31 flvars = self._search_regex(r'flvars: "(.*?)"', js_player, u'flvars')
32
33 pdoc = self._download_xml(
34 'http://eplayer.clipsyndicate.com/osmf/playlist?%s' % flvars,
35 video_id, u'Downloading video info',
36 transform_source=fix_xml_ampersands)
37
38 track_doc = pdoc.find('trackList/track')
39 def find_param(name):
40 node = find_xpath_attr(track_doc, './/param', 'name', name)
41 if node is not None:
42 return node.attrib['value']
43
44 return {
45 'id': video_id,
46 'title': find_param('title'),
47 'url': track_doc.find('location').text,
48 'thumbnail': find_param('thumbnail'),
49 'duration': int(find_param('duration')),
50 }