]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/teamcoco.py
2bf26d05682e8e2535d412c2718d78bec6077622
3 from .common
import InfoExtractor
9 class TeamcocoIE(InfoExtractor
):
10 _VALID_URL
= r
'http://teamcoco\.com/video/(?P<url_title>.*)'
12 u
'url': u
'http://teamcoco.com/video/louis-ck-interview-george-w-bush',
13 u
'file': u
'19705.mp4',
14 u
'md5': u
'cde9ba0fa3506f5f017ce11ead928f9a',
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"
21 def _real_extract(self
, url
):
22 mobj
= re
.match(self
._VALID
_URL
, url
)
24 raise ExtractorError(u
'Invalid URL: %s' % url
)
25 url_title
= mobj
.group('url_title')
26 webpage
= self
._download
_webpage
(url
, url_title
)
28 video_id
= self
._html
_search
_regex
(r
'<article class="video" data-id="(\d+?)"',
31 self
.report_extraction(video_id
)
33 data_url
= 'http://teamcoco.com/cvp/2.0/%s.xml' % video_id
34 data
= self
._download
_xml
(data_url
, video_id
, 'Downloading data webpage')
37 qualities
= ['500k', '480p', '1000k', '720p', '1080p']
39 for file in data
.findall('files/file'):
40 if file.attrib
.get('playmode') == 'all':
41 # it just duplicates one of the entries
44 m_format
= re
.search(r
'(\d+(k|p))\.mp4', file_url
)
45 if m_format
is not None:
46 format_id
= m_format
.group(1)
48 format_id
= file.attrib
['bitrate']
52 'format_id': format_id
,
56 return qualities
.index(f
['format_id'])
59 formats
.sort(key
=sort_key
)
61 raise ExtractorError(u
'Unable to extract video URL')
66 'title': self
._og
_search
_title
(webpage
),
67 'thumbnail': self
._og
_search
_thumbnail
(webpage
),
68 'description': self
._og
_search
_description
(webpage
),