]>
Commit | Line | Data |
---|---|---|
c33c962a | 1 | from .turner import TurnerBaseIE |
241c5d7d RA |
2 | from ..utils import ( |
3 | int_or_none, | |
4 | parse_iso8601, | |
5 | ) | |
c33c962a RA |
6 | |
7 | ||
8 | class TruTVIE(TurnerBaseIE): | |
241c5d7d | 9 | _VALID_URL = r'https?://(?:www\.)?trutv\.com/(?:shows|full-episodes)/(?P<series_slug>[0-9A-Za-z-]+)/(?:videos/(?P<clip_slug>[0-9A-Za-z-]+)|(?P<id>\d+))' |
c33c962a | 10 | _TEST = { |
241c5d7d | 11 | 'url': 'https://www.trutv.com/shows/the-carbonaro-effect/videos/sunlight-activated-flower.html', |
c33c962a | 12 | 'info_dict': { |
241c5d7d | 13 | 'id': 'f16c03beec1e84cd7d1a51f11d8fcc29124cc7f1', |
c33c962a | 14 | 'ext': 'mp4', |
241c5d7d RA |
15 | 'title': 'Sunlight-Activated Flower', |
16 | 'description': "A customer is stunned when he sees Michael's sunlight-activated flower.", | |
17 | }, | |
18 | 'params': { | |
19 | # m3u8 download | |
20 | 'skip_download': True, | |
21 | }, | |
c33c962a RA |
22 | } |
23 | ||
24 | def _real_extract(self, url): | |
5ad28e7f | 25 | series_slug, clip_slug, video_id = self._match_valid_url(url).groups() |
241c5d7d RA |
26 | |
27 | if video_id: | |
28 | path = 'episode' | |
29 | display_id = video_id | |
c33c962a | 30 | else: |
241c5d7d RA |
31 | path = 'series/clip' |
32 | display_id = clip_slug | |
33 | ||
34 | data = self._download_json( | |
35 | 'https://api.trutv.com/v2/web/%s/%s/%s' % (path, series_slug, display_id), | |
36 | display_id) | |
37 | video_data = data['episode'] if video_id else data['info'] | |
38 | media_id = video_data['mediaId'] | |
39 | title = video_data['title'].strip() | |
40 | ||
41 | info = self._extract_ngtv_info( | |
42 | media_id, {}, { | |
c38f0681 RA |
43 | 'url': url, |
44 | 'site_name': 'truTV', | |
241c5d7d | 45 | 'auth_required': video_data.get('isAuthRequired'), |
c33c962a | 46 | }) |
241c5d7d RA |
47 | |
48 | thumbnails = [] | |
49 | for image in video_data.get('images', []): | |
50 | image_url = image.get('srcUrl') | |
51 | if not image_url: | |
52 | continue | |
53 | thumbnails.append({ | |
54 | 'url': image_url, | |
55 | 'width': int_or_none(image.get('width')), | |
56 | 'height': int_or_none(image.get('height')), | |
57 | }) | |
58 | ||
59 | info.update({ | |
60 | 'id': media_id, | |
61 | 'display_id': display_id, | |
62 | 'title': title, | |
63 | 'description': video_data.get('description'), | |
64 | 'thumbnails': thumbnails, | |
65 | 'timestamp': parse_iso8601(video_data.get('publicationDate')), | |
66 | 'series': video_data.get('showTitle'), | |
67 | 'season_number': int_or_none(video_data.get('seasonNum')), | |
68 | 'episode_number': int_or_none(video_data.get('episodeNum')), | |
69 | }) | |
70 | return info |