]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/collegehumor.py
1 from __future__
import unicode_literals
6 from .common
import InfoExtractor
9 class CollegeHumorIE(InfoExtractor
):
10 _VALID_URL
= r
'^(?:https?://)?(?:www\.)?collegehumor\.com/(video|embed|e)/(?P<videoid>[0-9]+)/?(?P<shorttitle>.*)$'
13 'url': 'http://www.collegehumor.com/video/6902724/comic-con-cosplay-catastrophe',
14 'file': '6902724.mp4',
15 'md5': 'dcc0f5c1c8be98dc33889a191f4c26bd',
17 'title': 'Comic-Con Cosplay Catastrophe',
18 'description': 'Fans get creative this year at San Diego. Too',
23 'url': 'http://www.collegehumor.com/video/3505939/font-conference',
24 'file': '3505939.mp4',
25 'md5': '72fa701d8ef38664a4dbb9e2ab721816',
27 'title': 'Font Conference',
28 'description': 'This video wasn\'t long enough, so we made it double-spaced.',
33 def _real_extract(self
, url
):
34 mobj
= re
.match(self
._VALID
_URL
, url
)
35 video_id
= mobj
.group('videoid')
37 jsonUrl
= 'http://www.collegehumor.com/moogaloop/video/' + video_id
+ '.json'
38 data
= json
.loads(self
._download
_webpage
(
39 jsonUrl
, video_id
, 'Downloading info JSON'))
42 AGE_LIMITS
= {'nc17': 18, 'r': 18, 'pg13': 13, 'pg': 10, 'g': 0}
43 rating
= vdata
.get('rating')
45 age_limit
= AGE_LIMITS
.get(rating
.lower())
47 age_limit
= None # None = No idea
49 PREFS
= {'high_quality': 2, 'low_quality': 0}
51 for format_key
in ('mp4', 'webm'):
52 for qname
, qurl
in vdata
[format_key
].items():
54 'format_id': format_key
+ '_' + qname
,
57 'preference': PREFS
.get(qname
),
59 self
._sort
_formats
(formats
)
63 'title': vdata
['title'],
64 'description': vdata
.get('description'),
65 'thumbnail': vdata
.get('thumbnail'),
67 'age_limit': age_limit
,