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.

68 lines
2.1 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. determine_ext,
  6. int_or_none,
  7. js_to_json,
  8. parse_iso8601,
  9. remove_end,
  10. )
  11. class ClipfishIE(InfoExtractor):
  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': '79bc922f3e8a9097b3d68a93780fd475',
  16. 'info_dict': {
  17. 'id': '3966754',
  18. 'ext': 'mp4',
  19. 'title': 'FIFA 14 - E3 2013 Trailer',
  20. 'timestamp': 1370938118,
  21. 'upload_date': '20130611',
  22. 'duration': 82,
  23. }
  24. }
  25. def _real_extract(self, url):
  26. video_id = self._match_id(url)
  27. webpage = self._download_webpage(url, video_id)
  28. video_info = self._parse_json(
  29. js_to_json(self._html_search_regex(
  30. '(?s)videoObject\s*=\s*({.+?});', webpage, 'video object')),
  31. video_id)
  32. formats = []
  33. for video_url in re.findall(r'var\s+videourl\s*=\s*"([^"]+)"', webpage):
  34. ext = determine_ext(video_url)
  35. if ext == 'm3u8':
  36. formats.append({
  37. 'url': video_url.replace('de.hls.fra.clipfish.de', 'hls.fra.clipfish.de'),
  38. 'ext': 'mp4',
  39. 'format_id': 'hls',
  40. })
  41. else:
  42. formats.append({
  43. 'url': video_url,
  44. 'format_id': ext,
  45. })
  46. self._sort_formats(formats)
  47. title = remove_end(self._og_search_title(webpage), ' - Video')
  48. thumbnail = self._og_search_thumbnail(webpage)
  49. duration = int_or_none(video_info.get('length'))
  50. timestamp = parse_iso8601(self._html_search_meta('uploadDate', webpage, 'upload date'))
  51. return {
  52. 'id': video_id,
  53. 'title': title,
  54. 'formats': formats,
  55. 'thumbnail': thumbnail,
  56. 'duration': duration,
  57. 'timestamp': timestamp,
  58. }