]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/teamcoco.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
8 class TeamcocoIE(InfoExtractor
):
9 _VALID_URL
= r
'http://teamcoco\.com/video/(?P<video_id>[0-9]+)?/?(?P<display_id>.*)'
12 'url': 'http://teamcoco.com/video/80187/conan-becomes-a-mary-kay-beauty-consultant',
14 'md5': '3f7746aa0dc86de18df7539903d399ea',
16 'title': 'Conan Becomes A Mary Kay Beauty Consultant',
17 'description': 'Mary Kay is perhaps the most trusted name in female beauty, so of course Conan is a natural choice to sell their products.'
20 'url': 'http://teamcoco.com/video/louis-ck-interview-george-w-bush',
22 'md5': 'cde9ba0fa3506f5f017ce11ead928f9a',
24 "description": "Louis C.K. got starstruck by George W. Bush, so what? Part one.",
25 "title": "Louis C.K. Interview Pt. 1 11/3/11"
30 def _real_extract(self
, url
):
31 mobj
= re
.match(self
._VALID
_URL
, url
)
33 display_id
= mobj
.group('display_id')
34 webpage
= self
._download
_webpage
(url
, display_id
)
36 video_id
= mobj
.group("video_id")
38 video_id
= self
._html
_search
_regex
(
39 r
'data-node-id="(\d+?)"',
42 data_url
= 'http://teamcoco.com/cvp/2.0/%s.xml' % video_id
43 data
= self
._download
_xml
(
44 data_url
, display_id
, 'Downloading data webpage')
46 qualities
= ['500k', '480p', '1000k', '720p', '1080p']
48 for filed
in data
.findall('files/file'):
49 if filed
.attrib
.get('playmode') == 'all':
50 # it just duplicates one of the entries
53 m_format
= re
.search(r
'(\d+(k|p))\.mp4', file_url
)
54 if m_format
is not None:
55 format_id
= m_format
.group(1)
57 format_id
= filed
.attrib
['bitrate']
59 int(filed
.attrib
['bitrate'])
60 if filed
.attrib
['bitrate'].isdigit()
64 quality
= qualities
.index(format_id
)
71 'format_id': format_id
,
75 self
._sort
_formats
(formats
)
79 'display_id': display_id
,
81 'title': self
._og
_search
_title
(webpage
),
82 'thumbnail': self
._og
_search
_thumbnail
(webpage
),
83 'description': self
._og
_search
_description
(webpage
),