]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/comcarcoff.py
debian/changelog: Initiate new release.
[youtubedl] / youtube_dl / extractor / comcarcoff.py
1 # encoding: utf-8
2 from __future__ import unicode_literals
3
4 import json
5
6 from .common import InfoExtractor
7 from ..utils import parse_iso8601
8
9
10 class ComCarCoffIE(InfoExtractor):
11 _VALID_URL = r'http://(?:www\.)?comediansincarsgettingcoffee\.com/(?P<id>[a-z0-9\-]*)'
12 _TESTS = [{
13 'url': 'http://comediansincarsgettingcoffee.com/miranda-sings-happy-thanksgiving-miranda/',
14 'info_dict': {
15 'id': 'miranda-sings-happy-thanksgiving-miranda',
16 'ext': 'mp4',
17 'upload_date': '20141127',
18 'timestamp': 1417107600,
19 'title': 'Happy Thanksgiving Miranda',
20 'description': 'Jerry Seinfeld and his special guest Miranda Sings cruise around town in search of coffee, complaining and apologizing along the way.',
21 'thumbnail': 'http://ccc.crackle.com/images/s5e4_thumb.jpg',
22 },
23 'params': {
24 'skip_download': 'requires ffmpeg',
25 }
26 }]
27
28 def _real_extract(self, url):
29 display_id = self._match_id(url)
30 if not display_id:
31 display_id = 'comediansincarsgettingcoffee.com'
32 webpage = self._download_webpage(url, display_id)
33
34 full_data = json.loads(self._search_regex(
35 r'<script type="application/json" id="videoData">(?P<json>.+?)</script>',
36 webpage, 'full data json'))
37
38 video_id = full_data['activeVideo']['video']
39 video_data = full_data['videos'][video_id]
40 thumbnails = [{
41 'url': video_data['images']['thumb'],
42 }, {
43 'url': video_data['images']['poster'],
44 }]
45 formats = self._extract_m3u8_formats(
46 video_data['mediaUrl'], video_id, ext='mp4')
47
48 return {
49 'id': video_id,
50 'display_id': display_id,
51 'title': video_data['title'],
52 'description': video_data.get('description'),
53 'timestamp': parse_iso8601(video_data.get('pubDate')),
54 'thumbnails': thumbnails,
55 'formats': formats,
56 'webpage_url': 'http://comediansincarsgettingcoffee.com/%s' % (video_data.get('urlSlug', video_data.get('slug'))),
57 }