]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/clipsyndicate.py
[ie/box] Fix formats extraction (#8649)
[yt-dlp.git] / yt_dlp / extractor / clipsyndicate.py
CommitLineData
3862402f
JMF
1from .common import InfoExtractor
2from ..utils import (
3 find_xpath_attr,
5aafe895 4 fix_xml_ampersands
3862402f
JMF
5)
6
7
8class ClipsyndicateIE(InfoExtractor):
5886b38d 9 _VALID_URL = r'https?://(?:chic|www)\.clipsyndicate\.com/video/play(list/\d+)?/(?P<id>\d+)'
3862402f 10
cbc1fadd 11 _TESTS = [{
e9c076c3
PH
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,
ec85ded8 19 'thumbnail': r're:^https?://.+\.jpg',
3862402f 20 },
cbc1fadd
YCH
21 }, {
22 'url': 'http://chic.clipsyndicate.com/video/play/5844117/shark_attack',
23 'only_matching': True,
24 }]
3862402f
JMF
25
26 def _real_extract(self, url):
1316b549 27 video_id = self._match_id(url)
3862402f
JMF
28 js_player = self._download_webpage(
29 'http://eplayer.clipsyndicate.com/embed/player.js?va_id=%s' % video_id,
e9c076c3 30 video_id, 'Downlaoding player')
3862402f 31 # it includes a required token
e9c076c3 32 flvars = self._search_regex(r'flvars: "(.*?)"', js_player, 'flvars')
3862402f 33
18258362 34 pdoc = self._download_xml(
3862402f 35 'http://eplayer.clipsyndicate.com/osmf/playlist?%s' % flvars,
e9c076c3 36 video_id, 'Downloading video info',
5aafe895 37 transform_source=fix_xml_ampersands)
3862402f
JMF
38
39 track_doc = pdoc.find('trackList/track')
5f6a1245 40
3862402f
JMF
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 }