1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-09 03:34:32 +01:00
youtube-dl/youtube_dl/extractor/cliphunter.py

57 lines
1.5 KiB
Python
Raw Normal View History

2014-01-27 07:55:30 +01:00
from __future__ import unicode_literals
2014-01-25 01:46:52 +01:00
import re
from .common import InfoExtractor
2014-02-02 12:03:36 +01:00
2014-01-25 01:46:52 +01:00
2014-01-27 12:39:39 +01:00
translation_table = {
'a': 'h', 'd': 'e', 'e': 'v', 'f': 'o', 'g': 'f', 'i': 'd', 'l': 'n',
'm': 'a', 'n': 'm', 'p': 'u', 'q': 't', 'r': 's', 'v': 'p', 'x': 'r',
'y': 'l', 'z': 'i',
'$': ':', '&': '.', '(': '=', '^': '&', '=': '/',
}
2014-01-25 01:46:52 +01:00
class CliphunterIE(InfoExtractor):
2014-01-27 07:55:30 +01:00
IE_NAME = 'cliphunter'
2014-01-25 01:46:52 +01:00
2014-01-27 12:39:39 +01:00
_VALID_URL = r'''(?x)http://(?:www\.)?cliphunter\.com/w/
(?P<id>[0-9]+)/
(?P<seo>.+?)(?:$|[#\?])
'''
_TEST = {
2014-01-27 07:55:30 +01:00
'url': 'http://www.cliphunter.com/w/1012420/Fun_Jynx_Maze_solo',
'file': '1012420.flv',
'md5': '15e7740f30428abf70f4223478dc1225',
'info_dict': {
'title': 'Fun Jynx Maze solo',
2014-01-25 01:46:52 +01:00
}
2014-01-27 07:55:30 +01:00
}
2014-01-25 01:46:52 +01:00
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id')
webpage = self._download_webpage(url, video_id)
2014-01-27 12:39:39 +01:00
pl_fiji = self._search_regex(
r'pl_fiji = \'([^\']+)\'', webpage, 'video data')
pl_c_qual = self._search_regex(
r'pl_c_qual = "(.)"', webpage, 'video quality')
video_title = self._search_regex(
r'mediaTitle = "([^"]+)"', webpage, 'title')
2014-01-25 01:46:52 +01:00
2014-01-27 12:39:39 +01:00
video_url = ''.join(translation_table.get(c, c) for c in pl_fiji)
2014-01-25 01:46:52 +01:00
formats = [{
'url': video_url,
'format_id': pl_c_qual,
}]
return {
'id': video_id,
'title': video_title,
'formats': formats,
}