]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/teamcoco.py
c910110ca9775d9ad03011238aacdc3c9ef4dae1
[youtubedl] / youtube_dl / extractor / teamcoco.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import (
5 ExtractorError,
6 )
7
8
9 class TeamcocoIE(InfoExtractor):
10 _VALID_URL = r'http://teamcoco\.com/video/(?P<url_title>.*)'
11 _TEST = {
12 u'url': u'http://teamcoco.com/video/louis-ck-interview-george-w-bush',
13 u'file': u'19705.mp4',
14 u'md5': u'27b6f7527da5acf534b15f21b032656e',
15 u'info_dict': {
16 u"description": u"Louis C.K. got starstruck by George W. Bush, so what? Part one.",
17 u"title": u"Louis C.K. Interview Pt. 1 11/3/11"
18 }
19 }
20
21 def _real_extract(self, url):
22 mobj = re.match(self._VALID_URL, url)
23 if mobj is None:
24 raise ExtractorError(u'Invalid URL: %s' % url)
25 url_title = mobj.group('url_title')
26 webpage = self._download_webpage(url, url_title)
27
28 video_id = self._html_search_regex(r'<article class="video" data-id="(\d+?)"',
29 webpage, u'video id')
30
31 self.report_extraction(video_id)
32
33 data_url = 'http://teamcoco.com/cvp/2.0/%s.xml' % video_id
34 data = self._download_webpage(data_url, video_id, 'Downloading data webpage')
35
36 video_url = self._html_search_regex(r'<file [^>]*type="high".*?>(.*?)</file>',
37 data, u'video URL')
38
39 return [{
40 'id': video_id,
41 'url': video_url,
42 'ext': 'mp4',
43 'title': self._og_search_title(webpage),
44 'thumbnail': self._og_search_thumbnail(webpage),
45 'description': self._og_search_description(webpage),
46 }]