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.

59 lines
1.6 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. import string
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. ExtractorError,
  7. )
  8. translation_table = {
  9. 'a': 'h', 'd': 'e', 'e': 'v', 'f': 'o', 'g': 'f', 'i': 'd', 'l': 'n',
  10. 'm': 'a', 'n': 'm', 'p': 'u', 'q': 't', 'r': 's', 'v': 'p', 'x': 'r',
  11. 'y': 'l', 'z': 'i',
  12. '$': ':', '&': '.', '(': '=', '^': '&', '=': '/',
  13. }
  14. class CliphunterIE(InfoExtractor):
  15. IE_NAME = 'cliphunter'
  16. _VALID_URL = r'''(?x)http://(?:www\.)?cliphunter\.com/w/
  17. (?P<id>[0-9]+)/
  18. (?P<seo>.+?)(?:$|[#\?])
  19. '''
  20. _TEST = {
  21. 'url': 'http://www.cliphunter.com/w/1012420/Fun_Jynx_Maze_solo',
  22. 'file': '1012420.flv',
  23. 'md5': '15e7740f30428abf70f4223478dc1225',
  24. 'info_dict': {
  25. 'title': 'Fun Jynx Maze solo',
  26. }
  27. }
  28. def _real_extract(self, url):
  29. mobj = re.match(self._VALID_URL, url)
  30. video_id = mobj.group('id')
  31. webpage = self._download_webpage(url, video_id)
  32. pl_fiji = self._search_regex(
  33. r'pl_fiji = \'([^\']+)\'', webpage, 'video data')
  34. pl_c_qual = self._search_regex(
  35. r'pl_c_qual = "(.)"', webpage, 'video quality')
  36. video_title = self._search_regex(
  37. r'mediaTitle = "([^"]+)"', webpage, 'title')
  38. video_url = ''.join(translation_table.get(c, c) for c in pl_fiji)
  39. formats = [{
  40. 'url': video_url,
  41. 'format_id': pl_c_qual,
  42. }]
  43. return {
  44. 'id': video_id,
  45. 'title': video_title,
  46. 'formats': formats,
  47. }