vidzi.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .jwplatform import JWPlatformBaseIE
  4. from ..utils import (
  5. decode_packed_codes,
  6. js_to_json,
  7. )
  8. class VidziIE(JWPlatformBaseIE):
  9. _VALID_URL = r'https?://(?:www\.)?vidzi\.tv/(?P<id>\w+)'
  10. _TEST = {
  11. 'url': 'http://vidzi.tv/cghql9yq6emu.html',
  12. 'md5': '4f16c71ca0c8c8635ab6932b5f3f1660',
  13. 'info_dict': {
  14. 'id': 'cghql9yq6emu',
  15. 'ext': 'mp4',
  16. 'title': 'youtube-dl test video 1\\\\2\'3/4<5\\\\6ä7↭',
  17. },
  18. 'params': {
  19. # m3u8 download
  20. 'skip_download': True,
  21. },
  22. }
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. webpage = self._download_webpage(url, video_id)
  26. title = self._html_search_regex(
  27. r'(?s)<h2 class="video-title">(.*?)</h2>', webpage, 'title')
  28. code = decode_packed_codes(webpage).replace('\\\'', '\'')
  29. jwplayer_data = self._parse_json(
  30. self._search_regex(r'setup\(([^)]+)\)', code, 'jwplayer data'),
  31. video_id, transform_source=js_to_json)
  32. info_dict = self._parse_jwplayer_data(jwplayer_data, video_id, require_title=False)
  33. info_dict['title'] = title
  34. return info_dict