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.

77 lines
2.3 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import int_or_none
  4. _translation_table = {
  5. 'a': 'h', 'd': 'e', 'e': 'v', 'f': 'o', 'g': 'f', 'i': 'd', 'l': 'n',
  6. 'm': 'a', 'n': 'm', 'p': 'u', 'q': 't', 'r': 's', 'v': 'p', 'x': 'r',
  7. 'y': 'l', 'z': 'i',
  8. '$': ':', '&': '.', '(': '=', '^': '&', '=': '/',
  9. }
  10. def _decode(s):
  11. return ''.join(_translation_table.get(c, c) for c in s)
  12. class CliphunterIE(InfoExtractor):
  13. IE_NAME = 'cliphunter'
  14. _VALID_URL = r'''(?x)https?://(?:www\.)?cliphunter\.com/w/
  15. (?P<id>[0-9]+)/
  16. (?P<seo>.+?)(?:$|[#\?])
  17. '''
  18. _TEST = {
  19. 'url': 'http://www.cliphunter.com/w/1012420/Fun_Jynx_Maze_solo',
  20. 'md5': 'b7c9bbd4eb3a226ab91093714dcaa480',
  21. 'info_dict': {
  22. 'id': '1012420',
  23. 'ext': 'flv',
  24. 'title': 'Fun Jynx Maze solo',
  25. 'thumbnail': 're:^https?://.*\.jpg$',
  26. 'age_limit': 18,
  27. }
  28. }
  29. def _real_extract(self, url):
  30. video_id = self._match_id(url)
  31. webpage = self._download_webpage(url, video_id)
  32. video_title = self._search_regex(
  33. r'mediaTitle = "([^"]+)"', webpage, 'title')
  34. gexo_files = self._parse_json(
  35. self._search_regex(
  36. r'var\s+gexoFiles\s*=\s*({.+?});', webpage, 'gexo files'),
  37. video_id)
  38. formats = []
  39. for format_id, f in gexo_files.items():
  40. video_url = f.get('url')
  41. if not video_url:
  42. continue
  43. fmt = f.get('fmt')
  44. height = f.get('h')
  45. format_id = '%s_%sp' % (fmt, height) if fmt and height else format_id
  46. formats.append({
  47. 'url': _decode(video_url),
  48. 'format_id': format_id,
  49. 'width': int_or_none(f.get('w')),
  50. 'height': int_or_none(height),
  51. 'tbr': int_or_none(f.get('br')),
  52. })
  53. self._sort_formats(formats)
  54. thumbnail = self._search_regex(
  55. r"var\s+mov_thumb\s*=\s*'([^']+)';",
  56. webpage, 'thumbnail', fatal=False)
  57. return {
  58. 'id': video_id,
  59. 'title': video_title,
  60. 'formats': formats,
  61. 'age_limit': self._rta_search(webpage),
  62. 'thumbnail': thumbnail,
  63. }