2 from __future__ import unicode_literals
7 from .common import InfoExtractor
14 class VKIE(InfoExtractor):
16 _VALID_URL = r'https?://vk\.com/(?:videos.*?\?.*?z=)?video(?P<id>.*?)(?:\?|%2F|$)'
19 'url': 'http://vk.com/videos-77521?z=video-77521_162222515%2Fclub77521',
20 'file': '162222515.flv',
21 'md5': '0deae91935c54e00003c2a00646315f0',
23 'title': 'ProtivoGunz - Хуёвая песня',
24 'uploader': 'Noize MC',
28 'url': 'http://vk.com/video4643923_163339118',
29 'file': '163339118.mp4',
30 'md5': 'f79bccb5cd182b1f43502ca5685b2b36',
32 'uploader': 'Elvira Dzhonik',
33 'title': 'Dream Theater - Hollow Years Live at Budokan 720*',
37 def _real_extract(self, url):
38 mobj = re.match(self._VALID_URL, url)
39 video_id = mobj.group('id')
40 info_url = 'http://vk.com/al_video.php?act=show&al=1&video=%s' % video_id
41 info_page = self._download_webpage(info_url, video_id)
42 m_yt = re.search(r'src="(http://www.youtube.com/.*?)"', info_page)
44 self.to_screen(u'Youtube video detected')
45 return self.url_result(m_yt.group(1), 'Youtube')
46 data_json = self._search_regex(r'var vars = ({.*?});', info_page, 'vars')
47 data = json.loads(data_json)
52 'width': int(k[len('url'):]),
53 } for k, v in data.items()
54 if k.startswith('url')]
55 self._sort_formats(formats)
58 'id': compat_str(data['vid']),
60 'title': unescapeHTML(data['md_title']),
61 'thumbnail': data.get('jpg'),
62 'uploader': data.get('md_author'),