]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/teamcoco.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
11 class TeamcocoIE(InfoExtractor
):
12 _VALID_URL
= r
'http://teamcoco\.com/video/(?P<video_id>\d*)?/?(?P<url_title>.*)'
14 'url': 'http://teamcoco.com/video/louis-ck-interview-george-w-bush',
16 'md5': 'cde9ba0fa3506f5f017ce11ead928f9a',
18 "description": "Louis C.K. got starstruck by George W. Bush, so what? Part one.",
19 "title": "Louis C.K. Interview Pt. 1 11/3/11"
23 def _real_extract(self
, url
):
24 mobj
= re
.match(self
._VALID
_URL
, url
)
26 raise ExtractorError('Invalid URL: %s' % url
)
27 url_title
= mobj
.group('url_title')
28 webpage
= self
._download
_webpage
(url
, url_title
)
30 video_id
= mobj
.group("video_id")
32 video_id
= self
._html
_search
_regex
(
33 r
'<article class="video" data-id="(\d+?)"',
36 self
.report_extraction(video_id
)
38 data_url
= 'http://teamcoco.com/cvp/2.0/%s.xml' % video_id
39 data
= self
._download
_xml
(data_url
, video_id
, 'Downloading data webpage')
41 qualities
= ['500k', '480p', '1000k', '720p', '1080p']
43 for filed
in data
.findall('files/file'):
44 if filed
.attrib
.get('playmode') == 'all':
45 # it just duplicates one of the entries
48 m_format
= re
.search(r
'(\d+(k|p))\.mp4', file_url
)
49 if m_format
is not None:
50 format_id
= m_format
.group(1)
52 format_id
= filed
.attrib
['bitrate']
54 int(filed
.attrib
['bitrate'])
55 if filed
.attrib
['bitrate'].isdigit()
59 quality
= qualities
.index(format_id
)
66 'format_id': format_id
,
70 self
._sort
_formats
(formats
)
75 'title': self
._og
_search
_title
(webpage
),
76 'thumbnail': self
._og
_search
_thumbnail
(webpage
),
77 'description': self
._og
_search
_description
(webpage
),