1
0
mirror of https://github.com/l1ving/youtube-dl synced 2024-11-25 11:12:53 +08:00
youtube-dl/youtube_dl/extractor/clipsyndicate.py

55 lines
1.8 KiB
Python
Raw Normal View History

2014-03-27 09:30:00 +08:00
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
find_xpath_attr,
2014-01-21 05:11:34 +08:00
fix_xml_ampersands
)
class ClipsyndicateIE(InfoExtractor):
_VALID_URL = r'http://(?:chic|www)\.clipsyndicate\.com/video/play(list/\d+)?/(?P<id>\d+)'
_TESTS = [{
2014-03-27 09:30:00 +08:00
'url': 'http://www.clipsyndicate.com/video/play/4629301/brick_briscoe',
'md5': '4d7d549451bad625e0ff3d7bd56d776c',
'info_dict': {
'id': '4629301',
'ext': 'mp4',
'title': 'Brick Briscoe',
'duration': 612,
'thumbnail': 're:^https?://.+\.jpg',
},
}, {
'url': 'http://chic.clipsyndicate.com/video/play/5844117/shark_attack',
'only_matching': True,
}]
def _real_extract(self, url):
2015-07-08 13:43:23 +08:00
video_id = self._match_id(url)
js_player = self._download_webpage(
'http://eplayer.clipsyndicate.com/embed/player.js?va_id=%s' % video_id,
2014-03-27 09:30:00 +08:00
video_id, 'Downlaoding player')
# it includes a required token
2014-03-27 09:30:00 +08:00
flvars = self._search_regex(r'flvars: "(.*?)"', js_player, 'flvars')
2013-12-11 04:03:53 +08:00
pdoc = self._download_xml(
'http://eplayer.clipsyndicate.com/osmf/playlist?%s' % flvars,
2014-03-27 09:30:00 +08:00
video_id, 'Downloading video info',
2014-01-21 05:11:34 +08:00
transform_source=fix_xml_ampersands)
track_doc = pdoc.find('trackList/track')
2014-11-24 03:41:03 +08:00
def find_param(name):
node = find_xpath_attr(track_doc, './/param', 'name', name)
if node is not None:
return node.attrib['value']
return {
'id': video_id,
'title': find_param('title'),
'url': track_doc.find('location').text,
'thumbnail': find_param('thumbnail'),
'duration': int(find_param('duration')),
}