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