]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/keek.py
[SpankBang] Use python2.6 compatible string formatting spec
[youtube-dl] / youtube_dl / extractor / keek.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4
5
6 class KeekIE(InfoExtractor):
7     _VALID_URL = r'https?://(?:www\.)?keek\.com/(?:!|\w+/keeks/)(?P<id>\w+)'
8     IE_NAME = 'keek'
9     _TEST = {
10         'url': 'https://www.keek.com/ytdl/keeks/NODfbab',
11         'md5': '09c5c109067536c1cec8bac8c21fea05',
12         'info_dict': {
13             'id': 'NODfbab',
14             'ext': 'mp4',
15             'uploader': 'youtube-dl project',
16             'uploader_id': 'ytdl',
17             'title': 'test chars: "\'/\\\u00e4<>This is a test video for youtube-dl.For more information, contact phihag@phihag.de .',
18         },
19     }
20
21     def _real_extract(self, url):
22         video_id = self._match_id(url)
23
24         video_url = 'http://cdn.keek.com/keek/video/%s' % video_id
25         thumbnail = 'http://cdn.keek.com/keek/thumbnail/%s/w100/h75' % video_id
26         webpage = self._download_webpage(url, video_id)
27
28         raw_desc = self._html_search_meta('description', webpage)
29         if raw_desc:
30             uploader = self._html_search_regex(
31                 r'Watch (.*?)\s+\(', raw_desc, 'uploader', fatal=False)
32             uploader_id = self._html_search_regex(
33                 r'Watch .*?\(@(.+?)\)', raw_desc, 'uploader_id', fatal=False)
34         else:
35             uploader = None
36             uploader_id = None
37
38         return {
39             'id': video_id,
40             'url': video_url,
41             'ext': 'mp4',
42             'title': self._og_search_title(webpage),
43             'thumbnail': thumbnail,
44             'uploader': uploader,
45             'uploader_id': uploader_id,
46         }