You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.8 KiB

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