3 from .common import InfoExtractor
5 compat_urllib_parse_urlparse,
12 class CollegeHumorIE(InfoExtractor):
13 _VALID_URL = r'^(?:https?://)?(?:www\.)?collegehumor\.com/(video|embed|e)/(?P<videoid>[0-9]+)/?(?P<shorttitle>.*)$'
16 u'url': u'http://www.collegehumor.com/video/6902724/comic-con-cosplay-catastrophe',
17 u'file': u'6902724.mp4',
18 u'md5': u'1264c12ad95dca142a9f0bf7968105a0',
20 u'title': u'Comic-Con Cosplay Catastrophe',
21 u'description': u'Fans get creative this year at San Diego. Too creative. And yes, that\'s really Joss Whedon.',
25 u'url': u'http://www.collegehumor.com/video/3505939/font-conference',
26 u'file': u'3505939.mp4',
27 u'md5': u'c51ca16b82bb456a4397987791a835f5',
29 u'title': u'Font Conference',
30 u'description': u'This video wasn\'t long enough, so we made it double-spaced.',
34 def _real_extract(self, url):
35 mobj = re.match(self._VALID_URL, url)
37 raise ExtractorError(u'Invalid URL: %s' % url)
38 video_id = mobj.group('videoid')
46 self.report_extraction(video_id)
47 xmlUrl = 'http://www.collegehumor.com/moogaloop/video/' + video_id
48 mdoc = self._download_xml(xmlUrl, video_id,
49 u'Downloading info XML',
50 u'Unable to download video info XML')
53 videoNode = mdoc.findall('./video')[0]
54 youtubeIdNode = videoNode.find('./youtubeID')
55 if youtubeIdNode is not None:
56 return self.url_result(youtubeIdNode.text, 'Youtube')
57 info['description'] = videoNode.findall('./description')[0].text
58 info['title'] = videoNode.findall('./caption')[0].text
59 info['thumbnail'] = videoNode.findall('./thumbnail')[0].text
60 next_url = videoNode.findall('./file')[0].text
62 raise ExtractorError(u'Invalid metadata XML file')
64 if next_url.endswith(u'manifest.f4m'):
65 manifest_url = next_url + '?hdcore=2.10.3'
66 adoc = self._download_xml(manifest_url, video_id,
67 u'Downloading XML manifest',
68 u'Unable to download video info XML')
71 video_id = adoc.findall('./{http://ns.adobe.com/f4m/1.0}id')[0].text
73 raise ExtractorError(u'Invalid manifest file')
74 url_pr = compat_urllib_parse_urlparse(info['thumbnail'])
75 info['url'] = url_pr.scheme + '://' + url_pr.netloc + video_id[:-2].replace('.csmil','').replace(',','')
78 # Old-style direct links
79 info['url'] = next_url
80 info['ext'] = determine_ext(info['url'])