]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/comcarcoff.py
Add support for https for all extractors as preventive and future-proof measure
[yt-dlp.git] / youtube_dl / extractor / comcarcoff.py
CommitLineData
dc5596ff 1# encoding: utf-8
19bf2b4e
PH
2from __future__ import unicode_literals
3
dc5596ff 4from .common import InfoExtractor
80f772c2 5from ..compat import compat_str
cfe9e5aa
S
6from ..utils import (
7 int_or_none,
8 parse_duration,
9 parse_iso8601,
10)
dc5596ff
PH
11
12
13class ComCarCoffIE(InfoExtractor):
5886b38d 14 _VALID_URL = r'https?://(?:www\.)?comediansincarsgettingcoffee\.com/(?P<id>[a-z0-9\-]*)'
dc5596ff
PH
15 _TESTS = [{
16 'url': 'http://comediansincarsgettingcoffee.com/miranda-sings-happy-thanksgiving-miranda/',
17 'info_dict': {
80f772c2 18 'id': '2494164',
dc5596ff
PH
19 'ext': 'mp4',
20 'upload_date': '20141127',
21 'timestamp': 1417107600,
cfe9e5aa 22 'duration': 1232,
dc5596ff
PH
23 'title': 'Happy Thanksgiving Miranda',
24 'description': 'Jerry Seinfeld and his special guest Miranda Sings cruise around town in search of coffee, complaining and apologizing along the way.',
dc5596ff
PH
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 41
80f772c2 42 display_id = full_data['activeVideo']['video']
43 video_data = full_data.get('videos', {}).get(display_id) or full_data['singleshots'][display_id]
44 video_id = compat_str(video_data['mediaId'])
dc5596ff
PH
45 thumbnails = [{
46 'url': video_data['images']['thumb'],
47 }, {
48 'url': video_data['images']['poster'],
49 }]
dc5596ff 50
cfe9e5aa
S
51 timestamp = int_or_none(video_data.get('pubDateTime')) or parse_iso8601(
52 video_data.get('pubDate'))
53 duration = int_or_none(video_data.get('durationSeconds')) or parse_duration(
54 video_data.get('duration'))
55
dc5596ff 56 return {
80f772c2 57 '_type': 'url_transparent',
58 'url': 'crackle:%s' % video_id,
dc5596ff
PH
59 'id': video_id,
60 'display_id': display_id,
61 'title': video_data['title'],
62 'description': video_data.get('description'),
cfe9e5aa
S
63 'timestamp': timestamp,
64 'duration': duration,
dc5596ff 65 'thumbnails': thumbnails,
80f772c2 66 'season_number': int_or_none(video_data.get('season')),
67 'episode_number': int_or_none(video_data.get('episode')),
7668a2c5 68 'webpage_url': 'http://comediansincarsgettingcoffee.com/%s' % (video_data.get('urlSlug', video_data.get('slug'))),
dc5596ff 69 }