]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/clipsyndicate.py
60644432105f472988a599638563079f4765b39d
[yt-dlp.git] / yt_dlp / extractor / clipsyndicate.py
1 from .common import InfoExtractor
2 from ..utils import (
3 find_xpath_attr,
4 fix_xml_ampersands
5 )
6
7
8 class ClipsyndicateIE(InfoExtractor):
9 _VALID_URL = r'https?://(?:chic|www)\.clipsyndicate\.com/video/play(list/\d+)?/(?P<id>\d+)'
10
11 _TESTS = [{
12 'url': 'http://www.clipsyndicate.com/video/play/4629301/brick_briscoe',
13 'md5': '4d7d549451bad625e0ff3d7bd56d776c',
14 'info_dict': {
15 'id': '4629301',
16 'ext': 'mp4',
17 'title': 'Brick Briscoe',
18 'duration': 612,
19 'thumbnail': r're:^https?://.+\.jpg',
20 },
21 }, {
22 'url': 'http://chic.clipsyndicate.com/video/play/5844117/shark_attack',
23 'only_matching': True,
24 }]
25
26 def _real_extract(self, url):
27 video_id = self._match_id(url)
28 js_player = self._download_webpage(
29 'http://eplayer.clipsyndicate.com/embed/player.js?va_id=%s' % video_id,
30 video_id, 'Downlaoding player')
31 # it includes a required token
32 flvars = self._search_regex(r'flvars: "(.*?)"', js_player, 'flvars')
33
34 pdoc = self._download_xml(
35 'http://eplayer.clipsyndicate.com/osmf/playlist?%s' % flvars,
36 video_id, 'Downloading video info',
37 transform_source=fix_xml_ampersands)
38
39 track_doc = pdoc.find('trackList/track')
40
41 def find_param(name):
42 node = find_xpath_attr(track_doc, './/param', 'name', name)
43 if node is not None:
44 return node.attrib['value']
45
46 return {
47 'id': video_id,
48 'title': find_param('title'),
49 'url': track_doc.find('location').text,
50 'thumbnail': find_param('thumbnail'),
51 'duration': int(find_param('duration')),
52 }