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.

62 lines
2.1 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. int_or_none,
  5. unified_strdate,
  6. )
  7. class ClipfishIE(InfoExtractor):
  8. _VALID_URL = r'https?://(?:www\.)?clipfish\.de/(?:[^/]+/)+video/(?P<id>[0-9]+)'
  9. _TEST = {
  10. 'url': 'http://www.clipfish.de/special/game-trailer/video/3966754/fifa-14-e3-2013-trailer/',
  11. 'md5': '79bc922f3e8a9097b3d68a93780fd475',
  12. 'info_dict': {
  13. 'id': '3966754',
  14. 'ext': 'mp4',
  15. 'title': 'FIFA 14 - E3 2013 Trailer',
  16. 'description': 'Video zu FIFA 14: E3 2013 Trailer',
  17. 'upload_date': '20130611',
  18. 'duration': 82,
  19. 'view_count': int,
  20. }
  21. }
  22. def _real_extract(self, url):
  23. video_id = self._match_id(url)
  24. video_info = self._download_json(
  25. 'http://www.clipfish.de/devapi/id/%s?format=json&apikey=hbbtv' % video_id,
  26. video_id)['items'][0]
  27. formats = []
  28. m3u8_url = video_info.get('media_videourl_hls')
  29. if m3u8_url:
  30. formats.append({
  31. 'url': m3u8_url.replace('de.hls.fra.clipfish.de', 'hls.fra.clipfish.de'),
  32. 'ext': 'mp4',
  33. 'format_id': 'hls',
  34. })
  35. mp4_url = video_info.get('media_videourl')
  36. if mp4_url:
  37. formats.append({
  38. 'url': mp4_url,
  39. 'format_id': 'mp4',
  40. 'width': int_or_none(video_info.get('width')),
  41. 'height': int_or_none(video_info.get('height')),
  42. 'tbr': int_or_none(video_info.get('bitrate')),
  43. })
  44. return {
  45. 'id': video_id,
  46. 'title': video_info['title'],
  47. 'description': video_info.get('descr'),
  48. 'formats': formats,
  49. 'thumbnail': video_info.get('media_content_thumbnail_large') or video_info.get('media_thumbnail'),
  50. 'duration': int_or_none(video_info.get('media_length')),
  51. 'upload_date': unified_strdate(video_info.get('pubDate')),
  52. 'view_count': int_or_none(video_info.get('media_views'))
  53. }