chilloutzone.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import base64
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. clean_html,
  5. int_or_none,
  6. traverse_obj,
  7. )
  8. class ChilloutzoneIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?chilloutzone\.net/video/(?P<id>[\w-]+)\.html'
  10. _TESTS = [{
  11. 'url': 'https://www.chilloutzone.net/video/enemene-meck-alle-katzen-weg.html',
  12. 'md5': 'a76f3457e813ea0037e5244f509e66d1',
  13. 'info_dict': {
  14. 'id': 'enemene-meck-alle-katzen-weg',
  15. 'ext': 'mp4',
  16. 'title': 'Enemene Meck - Alle Katzen weg',
  17. 'description': 'Ist das der Umkehrschluss des Niesenden Panda-Babys?',
  18. 'duration': 24,
  19. },
  20. }, {
  21. 'note': 'Video hosted at YouTube',
  22. 'url': 'https://www.chilloutzone.net/video/eine-sekunde-bevor.html',
  23. 'info_dict': {
  24. 'id': '1YVQaAgHyRU',
  25. 'ext': 'mp4',
  26. 'title': '16 Photos Taken 1 Second Before Disaster',
  27. 'description': 'md5:58a8fcf6a459fe0a08f54140f0ad1814',
  28. 'uploader': 'BuzzFeedVideo',
  29. 'uploader_id': '@BuzzFeedVideo',
  30. 'upload_date': '20131105',
  31. 'availability': 'public',
  32. 'thumbnail': 'https://i.ytimg.com/vi/1YVQaAgHyRU/maxresdefault.jpg',
  33. 'tags': 'count:41',
  34. 'like_count': int,
  35. 'playable_in_embed': True,
  36. 'channel_url': 'https://www.youtube.com/channel/UCpko_-a4wgz2u_DgDgd9fqA',
  37. 'chapters': 'count:6',
  38. 'live_status': 'not_live',
  39. 'view_count': int,
  40. 'categories': ['Entertainment'],
  41. 'age_limit': 0,
  42. 'channel_id': 'UCpko_-a4wgz2u_DgDgd9fqA',
  43. 'duration': 100,
  44. 'uploader_url': 'http://www.youtube.com/@BuzzFeedVideo',
  45. 'channel_follower_count': int,
  46. 'channel': 'BuzzFeedVideo',
  47. },
  48. }, {
  49. 'url': 'https://www.chilloutzone.net/video/icon-blending.html',
  50. 'md5': '2f9d6850ec567b24f0f4fa143b9aa2f9',
  51. 'info_dict': {
  52. 'id': 'LLNkHpSjBfc',
  53. 'ext': 'mp4',
  54. 'title': 'The Sunday Times Making of Icons',
  55. 'description': 'md5:b9259fcf63a1669e42001e5db677f02a',
  56. 'uploader': 'MadFoxUA',
  57. 'uploader_id': '@MadFoxUA',
  58. 'upload_date': '20140204',
  59. 'channel_id': 'UCSZa9Y6-Vl7c11kWMcbAfCw',
  60. 'channel_url': 'https://www.youtube.com/channel/UCSZa9Y6-Vl7c11kWMcbAfCw',
  61. 'comment_count': int,
  62. 'uploader_url': 'http://www.youtube.com/@MadFoxUA',
  63. 'duration': 66,
  64. 'live_status': 'not_live',
  65. 'channel_follower_count': int,
  66. 'playable_in_embed': True,
  67. 'view_count': int,
  68. 'like_count': int,
  69. 'thumbnail': 'https://i.ytimg.com/vi/LLNkHpSjBfc/maxresdefault.jpg',
  70. 'categories': ['Comedy'],
  71. 'availability': 'public',
  72. 'tags': [],
  73. 'channel': 'MadFoxUA',
  74. 'age_limit': 0,
  75. },
  76. }, {
  77. 'url': 'https://www.chilloutzone.net/video/ordentlich-abgeschuettelt.html',
  78. 'info_dict': {
  79. 'id': 'ordentlich-abgeschuettelt',
  80. 'ext': 'mp4',
  81. 'title': 'Ordentlich abgeschüttelt',
  82. 'description': 'md5:d41541966b75d3d1e8ea77a94ea0d329',
  83. 'duration': 18,
  84. },
  85. }]
  86. def _real_extract(self, url):
  87. video_id = self._match_id(url)
  88. webpage = self._download_webpage(url, video_id)
  89. b64_data = self._html_search_regex(
  90. r'var cozVidData\s*=\s*"([^"]+)"', webpage, 'video data')
  91. info = self._parse_json(base64.b64decode(b64_data).decode(), video_id)
  92. video_url = info.get('mediaUrl')
  93. native_platform = info.get('nativePlatform')
  94. if native_platform and info.get('sourcePriority') == 'native':
  95. native_video_id = info['nativeVideoId']
  96. if native_platform == 'youtube':
  97. return self.url_result(native_video_id, 'Youtube')
  98. elif native_platform == 'vimeo':
  99. return self.url_result(f'https://vimeo.com/{native_video_id}', 'Vimeo')
  100. elif not video_url:
  101. # Possibly a standard youtube embed?
  102. # TODO: Investigate if site still does this (there are no tests for it)
  103. return self.url_result(url, 'Generic')
  104. return {
  105. 'id': video_id,
  106. 'url': video_url,
  107. 'ext': 'mp4',
  108. **traverse_obj(info, {
  109. 'title': 'title',
  110. 'description': ('description', {clean_html}),
  111. 'duration': ('videoLength', {int_or_none}),
  112. 'width': ('videoWidth', {int_or_none}),
  113. 'height': ('videoHeight', {int_or_none}),
  114. }),
  115. }