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.

57 lines
1.8 KiB

  1. import re
  2. import time
  3. import xml.etree.ElementTree
  4. from .common import InfoExtractor
  5. from ..utils import ExtractorError
  6. class ClipfishIE(InfoExtractor):
  7. IE_NAME = u'clipfish'
  8. _VALID_URL = r'^https?://(?:www\.)?clipfish\.de/.*?/video/(?P<id>[0-9]+)/'
  9. _TEST = {
  10. u'url': u'http://www.clipfish.de/special/game-trailer/video/3966754/fifa-14-e3-2013-trailer/',
  11. u'file': u'3966754.mp4',
  12. u'md5': u'2521cd644e862936cf2e698206e47385',
  13. u'info_dict': {
  14. u'title': u'FIFA 14 - E3 2013 Trailer',
  15. u'duration': 82,
  16. }
  17. }
  18. def _real_extract(self, url):
  19. mobj = re.match(self._VALID_URL, url)
  20. video_id = mobj.group(1)
  21. info_url = ('http://www.clipfish.de/devxml/videoinfo/%s?ts=%d' %
  22. (video_id, int(time.time())))
  23. doc = self._download_xml(
  24. info_url, video_id, note=u'Downloading info page')
  25. title = doc.find('title').text
  26. video_url = doc.find('filename').text
  27. if video_url is None:
  28. xml_bytes = xml.etree.ElementTree.tostring(doc)
  29. raise ExtractorError(u'Cannot find video URL in document %r' %
  30. xml_bytes)
  31. thumbnail = doc.find('imageurl').text
  32. duration_str = doc.find('duration').text
  33. m = re.match(
  34. r'^(?P<hours>[0-9]+):(?P<minutes>[0-9]{2}):(?P<seconds>[0-9]{2}):(?P<ms>[0-9]*)$',
  35. duration_str)
  36. if m:
  37. duration = (
  38. (int(m.group('hours')) * 60 * 60) +
  39. (int(m.group('minutes')) * 60) +
  40. (int(m.group('seconds')))
  41. )
  42. else:
  43. duration = None
  44. return {
  45. 'id': video_id,
  46. 'title': title,
  47. 'url': video_url,
  48. 'thumbnail': thumbnail,
  49. 'duration': duration,
  50. }