]>
Commit | Line | Data |
---|---|---|
dc5596ff | 1 | # encoding: utf-8 |
19bf2b4e PH |
2 | from __future__ import unicode_literals |
3 | ||
dc5596ff | 4 | from .common import InfoExtractor |
cfe9e5aa S |
5 | from ..utils import ( |
6 | int_or_none, | |
7 | parse_duration, | |
8 | parse_iso8601, | |
9 | ) | |
dc5596ff PH |
10 | |
11 | ||
12 | class ComCarCoffIE(InfoExtractor): | |
3c864e93 | 13 | _VALID_URL = r'http://(?:www\.)?comediansincarsgettingcoffee\.com/(?P<id>[a-z0-9\-]*)' |
dc5596ff PH |
14 | _TESTS = [{ |
15 | 'url': 'http://comediansincarsgettingcoffee.com/miranda-sings-happy-thanksgiving-miranda/', | |
16 | 'info_dict': { | |
17 | 'id': 'miranda-sings-happy-thanksgiving-miranda', | |
18 | 'ext': 'mp4', | |
19 | 'upload_date': '20141127', | |
20 | 'timestamp': 1417107600, | |
cfe9e5aa | 21 | 'duration': 1232, |
dc5596ff PH |
22 | 'title': 'Happy Thanksgiving Miranda', |
23 | 'description': 'Jerry Seinfeld and his special guest Miranda Sings cruise around town in search of coffee, complaining and apologizing along the way.', | |
24 | 'thumbnail': 'http://ccc.crackle.com/images/s5e4_thumb.jpg', | |
25 | }, | |
26 | 'params': { | |
27 | 'skip_download': 'requires ffmpeg', | |
28 | } | |
29 | }] | |
30 | ||
31 | def _real_extract(self, url): | |
32 | display_id = self._match_id(url) | |
3c864e93 PH |
33 | if not display_id: |
34 | display_id = 'comediansincarsgettingcoffee.com' | |
dc5596ff PH |
35 | webpage = self._download_webpage(url, display_id) |
36 | ||
4c24ed94 S |
37 | full_data = self._parse_json( |
38 | self._search_regex( | |
39 | r'window\.app\s*=\s*({.+?});\n', webpage, 'full data json'), | |
40 | display_id)['videoData'] | |
dc5596ff PH |
41 | |
42 | video_id = full_data['activeVideo']['video'] | |
5bdec59d | 43 | video_data = full_data.get('videos', {}).get(video_id) or full_data['singleshots'][video_id] |
dc5596ff PH |
44 | thumbnails = [{ |
45 | 'url': video_data['images']['thumb'], | |
46 | }, { | |
47 | 'url': video_data['images']['poster'], | |
48 | }] | |
49 | formats = self._extract_m3u8_formats( | |
50 | video_data['mediaUrl'], video_id, ext='mp4') | |
51 | ||
cfe9e5aa S |
52 | timestamp = int_or_none(video_data.get('pubDateTime')) or parse_iso8601( |
53 | video_data.get('pubDate')) | |
54 | duration = int_or_none(video_data.get('durationSeconds')) or parse_duration( | |
55 | video_data.get('duration')) | |
56 | ||
dc5596ff PH |
57 | return { |
58 | 'id': video_id, | |
59 | 'display_id': display_id, | |
60 | 'title': video_data['title'], | |
61 | 'description': video_data.get('description'), | |
cfe9e5aa S |
62 | 'timestamp': timestamp, |
63 | 'duration': duration, | |
dc5596ff PH |
64 | 'thumbnails': thumbnails, |
65 | 'formats': formats, | |
7668a2c5 | 66 | 'webpage_url': 'http://comediansincarsgettingcoffee.com/%s' % (video_data.get('urlSlug', video_data.get('slug'))), |
dc5596ff | 67 | } |