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.

97 lines
3.5 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. import base64
  4. import json
  5. from .common import InfoExtractor
  6. from ..utils import (
  7. clean_html,
  8. ExtractorError
  9. )
  10. class ChilloutzoneIE(InfoExtractor):
  11. _VALID_URL = r'https?://(?:www\.)?chilloutzone\.net/video/(?P<id>[\w|-]+)\.html'
  12. _TESTS = [{
  13. 'url': 'http://www.chilloutzone.net/video/enemene-meck-alle-katzen-weg.html',
  14. 'md5': 'a76f3457e813ea0037e5244f509e66d1',
  15. 'info_dict': {
  16. 'id': 'enemene-meck-alle-katzen-weg',
  17. 'ext': 'mp4',
  18. 'title': 'Enemene Meck - Alle Katzen weg',
  19. 'description': 'Ist das der Umkehrschluss des Niesenden Panda-Babys?',
  20. },
  21. }, {
  22. 'note': 'Video hosted at YouTube',
  23. 'url': 'http://www.chilloutzone.net/video/eine-sekunde-bevor.html',
  24. 'info_dict': {
  25. 'id': '1YVQaAgHyRU',
  26. 'ext': 'mp4',
  27. 'title': '16 Photos Taken 1 Second Before Disaster',
  28. 'description': 'md5:58a8fcf6a459fe0a08f54140f0ad1814',
  29. 'uploader': 'BuzzFeedVideo',
  30. 'uploader_id': 'BuzzFeedVideo',
  31. 'upload_date': '20131105',
  32. },
  33. }, {
  34. 'note': 'Video hosted at Vimeo',
  35. 'url': 'http://www.chilloutzone.net/video/icon-blending.html',
  36. 'md5': '2645c678b8dc4fefcc0e1b60db18dac1',
  37. 'info_dict': {
  38. 'id': '85523671',
  39. 'ext': 'mp4',
  40. 'title': 'The Sunday Times - Icons',
  41. 'description': 're:(?s)^Watch the making of - makingoficons.com.{300,}',
  42. 'uploader': 'Us',
  43. 'uploader_id': 'usfilms',
  44. 'upload_date': '20140131'
  45. },
  46. }]
  47. def _real_extract(self, url):
  48. mobj = re.match(self._VALID_URL, url)
  49. video_id = mobj.group('id')
  50. webpage = self._download_webpage(url, video_id)
  51. base64_video_info = self._html_search_regex(
  52. r'var cozVidData = "(.+?)";', webpage, 'video data')
  53. decoded_video_info = base64.b64decode(base64_video_info).decode("utf-8")
  54. video_info_dict = json.loads(decoded_video_info)
  55. # get video information from dict
  56. video_url = video_info_dict['mediaUrl']
  57. description = clean_html(video_info_dict.get('description'))
  58. title = video_info_dict['title']
  59. native_platform = video_info_dict['nativePlatform']
  60. native_video_id = video_info_dict['nativeVideoId']
  61. source_priority = video_info_dict['sourcePriority']
  62. # If nativePlatform is None a fallback mechanism is used (i.e. youtube embed)
  63. if native_platform is None:
  64. youtube_url = self._html_search_regex(
  65. r'<iframe.* src="((?:https?:)?//(?:[^.]+\.)?youtube\.com/.+?)"',
  66. webpage, 'fallback video URL', default=None)
  67. if youtube_url is not None:
  68. return self.url_result(youtube_url, ie='Youtube')
  69. # Non Fallback: Decide to use native source (e.g. youtube or vimeo) or
  70. # the own CDN
  71. if source_priority == 'native':
  72. if native_platform == 'youtube':
  73. return self.url_result(native_video_id, ie='Youtube')
  74. if native_platform == 'vimeo':
  75. return self.url_result(
  76. 'http://vimeo.com/' + native_video_id, ie='Vimeo')
  77. if not video_url:
  78. raise ExtractorError('No video found')
  79. return {
  80. 'id': video_id,
  81. 'url': video_url,
  82. 'ext': 'mp4',
  83. 'title': title,
  84. 'description': description,
  85. }