clipsyndicate.py 1.7 KB

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