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.

67 lines
2.3 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. unified_strdate,
  7. )
  8. class ClipfishIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?clipfish\.de/(?:[^/]+/)+video/(?P<id>[0-9]+)'
  10. _TEST = {
  11. 'url': 'http://www.clipfish.de/special/ugly-americans/video/4343170/s01-e01-ugly-americans-date-in-der-hoelle/',
  12. 'md5': '720563e467b86374c194bdead08d207d',
  13. 'info_dict': {
  14. 'id': '4343170',
  15. 'ext': 'mp4',
  16. 'title': 'S01 E01 - Ugly Americans - Date in der Hölle',
  17. 'description': 'Mark Lilly arbeitet im Sozialdienst der Stadt New York und soll Immigranten bei ihrer Einbürgerung in die USA zur Seite stehen.',
  18. 'upload_date': '20161005',
  19. 'duration': 1291,
  20. 'view_count': int,
  21. }
  22. }
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. video_info = self._download_json(
  26. 'http://www.clipfish.de/devapi/id/%s?format=json&apikey=hbbtv' % video_id,
  27. video_id)['items'][0]
  28. formats = []
  29. m3u8_url = video_info.get('media_videourl_hls')
  30. if m3u8_url:
  31. formats.append({
  32. 'url': m3u8_url.replace('de.hls.fra.clipfish.de', 'hls.fra.clipfish.de'),
  33. 'ext': 'mp4',
  34. 'format_id': 'hls',
  35. })
  36. mp4_url = video_info.get('media_videourl')
  37. if mp4_url:
  38. formats.append({
  39. 'url': mp4_url,
  40. 'format_id': 'mp4',
  41. 'width': int_or_none(video_info.get('width')),
  42. 'height': int_or_none(video_info.get('height')),
  43. 'tbr': int_or_none(video_info.get('bitrate')),
  44. })
  45. descr = video_info.get('descr')
  46. if descr:
  47. descr = descr.strip()
  48. return {
  49. 'id': video_id,
  50. 'title': video_info['title'],
  51. 'description': descr,
  52. 'formats': formats,
  53. 'thumbnail': video_info.get('media_content_thumbnail_large') or video_info.get('media_thumbnail'),
  54. 'duration': int_or_none(video_info.get('media_length')),
  55. 'upload_date': unified_strdate(video_info.get('pubDate')),
  56. 'view_count': int_or_none(video_info.get('media_views'))
  57. }