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.

53 lines
1.6 KiB

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