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