]> gitweb @ CieloNegro.org - youtube-dl.git/blob - youtube_dl/extractor/ku6.py
[ign] Fix extraction of video in articles
[youtube-dl.git] / youtube_dl / extractor / ku6.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6
7
8 class Ku6IE(InfoExtractor):
9     _VALID_URL = r'http://v\.ku6\.com/show/(?P<id>[a-zA-Z0-9\-\_]+)(?:\.)*html'
10     _TEST = {
11         'url': 'http://v.ku6.com/show/JG-8yS14xzBr4bCn1pu0xw...html',
12         'md5': '01203549b9efbb45f4b87d55bdea1ed1',
13         'info_dict': {
14             'id': 'JG-8yS14xzBr4bCn1pu0xw',
15             'ext': 'f4v',
16             'title': 'techniques test',
17         }
18     }
19
20     def _real_extract(self, url):
21         mobj = re.match(self._VALID_URL, url)
22         video_id = mobj.group('id')
23
24         webpage = self._download_webpage(url, video_id)
25         title = self._search_regex(r'<h1 title=.*>(.*?)</h1>', webpage, 'title')
26         dataUrl = 'http://v.ku6.com/fetchVideo4Player/%s.html' % video_id
27         jsonData = self._download_json(dataUrl, video_id)
28         downloadUrl = jsonData['data']['f']
29
30         return {
31             'id': video_id,
32             'title': title,
33             'url': downloadUrl
34         }
35