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

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. decode_packed_codes,
  7. js_to_json,
  8. NO_DEFAULT,
  9. PACKED_CODES_RE,
  10. )
  11. class VidziIE(InfoExtractor):
  12. _VALID_URL = r'https?://(?:www\.)?vidzi\.(?:tv|cc|si|nu)/(?:embed-)?(?P<id>[0-9a-zA-Z]+)'
  13. _TESTS = [{
  14. 'url': 'http://vidzi.tv/cghql9yq6emu.html',
  15. 'md5': '4f16c71ca0c8c8635ab6932b5f3f1660',
  16. 'info_dict': {
  17. 'id': 'cghql9yq6emu',
  18. 'ext': 'mp4',
  19. 'title': 'youtube-dl test video 1\\\\2\'3/4<5\\\\6ä7↭',
  20. },
  21. 'params': {
  22. # m3u8 download
  23. 'skip_download': True,
  24. },
  25. }, {
  26. 'url': 'http://vidzi.tv/embed-4z2yb0rzphe9-600x338.html',
  27. 'only_matching': True,
  28. }, {
  29. 'url': 'http://vidzi.cc/cghql9yq6emu.html',
  30. 'only_matching': True,
  31. }, {
  32. 'url': 'https://vidzi.si/rph9gztxj1et.html',
  33. 'only_matching': True,
  34. }, {
  35. 'url': 'http://vidzi.nu/cghql9yq6emu.html',
  36. 'only_matching': True,
  37. }]
  38. def _real_extract(self, url):
  39. video_id = self._match_id(url)
  40. webpage = self._download_webpage(
  41. 'http://vidzi.tv/%s' % video_id, video_id)
  42. title = self._html_search_regex(
  43. r'(?s)<h2 class="video-title">(.*?)</h2>', webpage, 'title')
  44. codes = [webpage]
  45. codes.extend([
  46. decode_packed_codes(mobj.group(0)).replace('\\\'', '\'')
  47. for mobj in re.finditer(PACKED_CODES_RE, webpage)])
  48. for num, code in enumerate(codes, 1):
  49. jwplayer_data = self._parse_json(
  50. self._search_regex(
  51. r'setup\(([^)]+)\)', code, 'jwplayer data',
  52. default=NO_DEFAULT if num == len(codes) else '{}'),
  53. video_id, transform_source=lambda s: js_to_json(
  54. re.sub(r'\s*\+\s*window\[.+?\]', '', s)))
  55. if jwplayer_data:
  56. break
  57. info_dict = self._parse_jwplayer_data(jwplayer_data, video_id, require_title=False)
  58. info_dict['title'] = title
  59. return info_dict