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.

52 lines
1.7 KiB

  1. import re
  2. import xml.etree.ElementTree
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. find_xpath_attr,
  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. playlist_page = self._download_webpage(
  28. 'http://eplayer.clipsyndicate.com/osmf/playlist?%s' % flvars,
  29. video_id, u'Downloading video info')
  30. # Fix broken xml
  31. playlist_page = re.sub('&', '&amp;', playlist_page)
  32. pdoc = xml.etree.ElementTree.fromstring(playlist_page.encode('utf-8'))
  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. }