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