]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/teamcoco.py
Fix description of the modularization.
[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
12 def _real_extract(self, url):
13 mobj = re.match(self._VALID_URL, url)
14 if mobj is None:
15 raise ExtractorError(u'Invalid URL: %s' % url)
16 url_title = mobj.group('url_title')
17 webpage = self._download_webpage(url, url_title)
18
19 video_id = self._html_search_regex(r'<article class="video" data-id="(\d+?)"',
20 webpage, u'video id')
21
22 self.report_extraction(video_id)
23
24 video_title = self._html_search_regex(r'<meta property="og:title" content="(.+?)"',
25 webpage, u'title')
26
27 thumbnail = self._html_search_regex(r'<meta property="og:image" content="(.+?)"',
28 webpage, u'thumbnail', fatal=False)
29
30 video_description = self._html_search_regex(r'<meta property="og:description" content="(.*?)"',
31 webpage, u'description', fatal=False)
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': video_title,
44 'thumbnail': thumbnail,
45 'description': video_description,
46 }]