]>
Commit | Line | Data |
---|---|---|
27a95f51 | 1 | from .common import InfoExtractor |
2 | from ..utils import ( | |
b99b0bcf | 3 | ExtractorError, |
27a95f51 | 4 | int_or_none, |
0a74b451 | 5 | parse_age_limit, |
27a95f51 | 6 | parse_iso8601, |
0a74b451 RA |
7 | smuggle_url, |
8 | str_or_none, | |
27a95f51 | 9 | ) |
10 | ||
11 | ||
12 | class CWTVIE(InfoExtractor): | |
e03d3e64 | 13 | _VALID_URL = r'https?://(?:www\.)?cw(?:tv(?:pr)?|seed)\.com/(?:shows/)?(?:[^/]+/)+[^?]*\?.*\b(?:play|watch)=(?P<id>[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12})' |
27a95f51 | 14 | _TESTS = [{ |
15 | 'url': 'http://cwtv.com/shows/arrow/legends-of-yesterday/?play=6b15e985-9345-4f60-baf8-56e96be57c63', | |
16 | 'info_dict': { | |
17 | 'id': '6b15e985-9345-4f60-baf8-56e96be57c63', | |
18 | 'ext': 'mp4', | |
19 | 'title': 'Legends of Yesterday', | |
20 | 'description': 'Oliver and Barry Allen take Kendra Saunders and Carter Hall to a remote location to keep them hidden from Vandal Savage while they figure out how to defeat him.', | |
21 | 'duration': 2665, | |
22 | 'series': 'Arrow', | |
23 | 'season_number': 4, | |
24 | 'season': '4', | |
25 | 'episode_number': 8, | |
26 | 'upload_date': '20151203', | |
27 | 'timestamp': 1449122100, | |
28 | }, | |
29 | 'params': { | |
30 | # m3u8 download | |
31 | 'skip_download': True, | |
6bb801cf RA |
32 | }, |
33 | 'skip': 'redirect to http://cwtv.com/shows/arrow/', | |
27a95f51 | 34 | }, { |
35 | 'url': 'http://www.cwseed.com/shows/whose-line-is-it-anyway/jeff-davis-4/?play=24282b12-ead2-42f2-95ad-26770c2c6088', | |
36 | 'info_dict': { | |
37 | 'id': '24282b12-ead2-42f2-95ad-26770c2c6088', | |
38 | 'ext': 'mp4', | |
39 | 'title': 'Jeff Davis 4', | |
40 | 'description': 'Jeff Davis is back to make you laugh.', | |
41 | 'duration': 1263, | |
42 | 'series': 'Whose Line Is It Anyway?', | |
43 | 'season_number': 11, | |
27a95f51 | 44 | 'episode_number': 20, |
45 | 'upload_date': '20151006', | |
46 | 'timestamp': 1444107300, | |
0a74b451 RA |
47 | 'age_limit': 14, |
48 | 'uploader': 'CWTV', | |
7e09c147 | 49 | 'thumbnail': r're:^https?://.*\.jpe?g$', |
50 | 'chapters': 'count:4', | |
51 | 'episode': 'Episode 20', | |
52 | 'season': 'Season 11', | |
0a74b451 RA |
53 | }, |
54 | 'params': { | |
55 | # m3u8 download | |
56 | 'skip_download': True, | |
27a95f51 | 57 | }, |
52af8f22 S |
58 | }, { |
59 | 'url': 'http://cwtv.com/thecw/chroniclesofcisco/?play=8adebe35-f447-465f-ab52-e863506ff6d6', | |
60 | 'only_matching': True, | |
e03d3e64 S |
61 | }, { |
62 | 'url': 'http://cwtvpr.com/the-cw/video?watch=9eee3f60-ef4e-440b-b3b2-49428ac9c54e', | |
63 | 'only_matching': True, | |
64 | }, { | |
65 | 'url': 'http://cwtv.com/shows/arrow/legends-of-yesterday/?watch=6b15e985-9345-4f60-baf8-56e96be57c63', | |
66 | 'only_matching': True, | |
27a95f51 | 67 | }] |
68 | ||
69 | def _real_extract(self, url): | |
70 | video_id = self._match_id(url) | |
b99b0bcf | 71 | data = self._download_json( |
0a74b451 | 72 | 'http://images.cwtv.com/feed/mobileapp/video-meta/apiversion_8/guid_' + video_id, |
b99b0bcf RA |
73 | video_id) |
74 | if data.get('result') != 'ok': | |
75 | raise ExtractorError(data['msg'], expected=True) | |
76 | video_data = data['video'] | |
0a74b451 RA |
77 | title = video_data['title'] |
78 | mpx_url = video_data.get('mpx_url') or 'http://link.theplatform.com/s/cwtv/media/guid/2703454149/%s?formats=M3U' % video_id | |
27a95f51 | 79 | |
0a74b451 RA |
80 | season = str_or_none(video_data.get('season')) |
81 | episode = str_or_none(video_data.get('episode')) | |
82 | if episode and season: | |
de74ef83 | 83 | episode = episode[len(season):] |
27a95f51 | 84 | |
85 | return { | |
0a74b451 | 86 | '_type': 'url_transparent', |
27a95f51 | 87 | 'id': video_id, |
0a74b451 RA |
88 | 'title': title, |
89 | 'url': smuggle_url(mpx_url, {'force_smil_url': True}), | |
90 | 'description': video_data.get('description_long'), | |
91 | 'duration': int_or_none(video_data.get('duration_secs')), | |
92 | 'series': video_data.get('series_name'), | |
93 | 'season_number': int_or_none(season), | |
94 | 'episode_number': int_or_none(episode), | |
95 | 'timestamp': parse_iso8601(video_data.get('start_time')), | |
96 | 'age_limit': parse_age_limit(video_data.get('rating')), | |
97 | 'ie_key': 'ThePlatform', | |
8d214c48 | 98 | 'thumbnail': video_data.get('large_thumbnail') |
27a95f51 | 99 | } |