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.

50 lines
1.6 KiB

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