]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/teamcoco.py
Imported Upstream version 2013.07.10
[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 video_title = self._html_search_regex(r'<meta property="og:title" content="(.+?)"',
34 webpage, u'title')
35
36 thumbnail = self._html_search_regex(r'<meta property="og:image" content="(.+?)"',
37 webpage, u'thumbnail', fatal=False)
38
39 video_description = self._html_search_regex(r'<meta property="og:description" content="(.*?)"',
40 webpage, u'description', fatal=False)
41
42 data_url = 'http://teamcoco.com/cvp/2.0/%s.xml' % video_id
43 data = self._download_webpage(data_url, video_id, 'Downloading data webpage')
44
45 video_url = self._html_search_regex(r'<file type="high".*?>(.*?)</file>',
46 data, u'video URL')
47
48 return [{
49 'id': video_id,
50 'url': video_url,
51 'ext': 'mp4',
52 'title': video_title,
53 'thumbnail': thumbnail,
54 'description': video_description,
55 }]