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

  1. import re
  2. import time
  3. import xml.etree.ElementTree
  4. from .common import InfoExtractor
  5. class ClipfishIE(InfoExtractor):
  6. IE_NAME = u'clipfish'
  7. _VALID_URL = r'^https?://(?:www\.)?clipfish\.de/.*?/video/(?P<id>[0-9]+)/'
  8. _TEST = {
  9. u'url': u'http://www.clipfish.de/special/supertalent/video/4028320/supertalent-2013-ivana-opacak-singt-nobodys-perfect/',
  10. u'file': u'4028320.f4v',
  11. u'md5': u'5e38bda8c329fbfb42be0386a3f5a382',
  12. u'info_dict': {
  13. u'title': u'Supertalent 2013: Ivana Opacak singt Nobody\'s Perfect',
  14. u'duration': 399,
  15. }
  16. }
  17. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url)
  19. video_id = mobj.group(1)
  20. info_url = ('http://www.clipfish.de/devxml/videoinfo/%s?ts=%d' %
  21. (video_id, int(time.time())))
  22. info_xml = self._download_webpage(
  23. info_url, video_id, note=u'Downloading info page')
  24. doc = xml.etree.ElementTree.fromstring(info_xml)
  25. title = doc.find('title').text
  26. video_url = doc.find('filename').text
  27. thumbnail = doc.find('imageurl').text
  28. duration_str = doc.find('duration').text
  29. m = re.match(
  30. r'^(?P<hours>[0-9]+):(?P<minutes>[0-9]{2}):(?P<seconds>[0-9]{2}):(?P<ms>[0-9]*)$',
  31. duration_str)
  32. if m:
  33. duration = (
  34. (int(m.group('hours')) * 60 * 60) +
  35. (int(m.group('minutes')) * 60) +
  36. (int(m.group('seconds')))
  37. )
  38. else:
  39. duration = None
  40. return {
  41. 'id': video_id,
  42. 'title': title,
  43. 'url': video_url,
  44. 'thumbnail': thumbnail,
  45. 'duration': duration,
  46. }