clipfish.py 1.6 KB

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