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.7 KiB

10 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. find_xpath_attr,
  6. fix_xml_ampersands
  7. )
  8. class ClipsyndicateIE(InfoExtractor):
  9. _VALID_URL = r'http://www\.clipsyndicate\.com/video/play(list/\d+)?/(?P<id>\d+)'
  10. _TEST = {
  11. 'url': 'http://www.clipsyndicate.com/video/play/4629301/brick_briscoe',
  12. 'md5': '4d7d549451bad625e0ff3d7bd56d776c',
  13. 'info_dict': {
  14. 'id': '4629301',
  15. 'ext': 'mp4',
  16. 'title': 'Brick Briscoe',
  17. 'duration': 612,
  18. 'thumbnail': 're:^https?://.+\.jpg',
  19. },
  20. }
  21. def _real_extract(self, url):
  22. mobj = re.match(self._VALID_URL, url)
  23. video_id = mobj.group('id')
  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. }