]>
Commit | Line | Data |
---|---|---|
48fbb100 AMW |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | import re | |
5 | ||
29825140 | 6 | from .turner import TurnerBaseIE |
3fb2a230 | 7 | from ..utils import ( |
3fb2a230 | 8 | int_or_none, |
3b859145 | 9 | strip_or_none, |
3052a30d | 10 | url_or_none, |
3fb2a230 | 11 | ) |
48fbb100 | 12 | |
5f6a1245 | 13 | |
29825140 | 14 | class AdultSwimIE(TurnerBaseIE): |
3b859145 | 15 | _VALID_URL = r'https?://(?:www\.)?adultswim\.com/videos/(?P<show_path>[^/?#]+)(?:/(?P<episode_path>[^/?#]+))?' |
71155991 | 16 | |
17 | _TESTS = [{ | |
18 | 'url': 'http://adultswim.com/videos/rick-and-morty/pilot', | |
71155991 | 19 | 'info_dict': { |
11e611a7 | 20 | 'id': 'rQxZvXQ4ROaSOqq-or2Mow', |
3b859145 | 21 | 'ext': 'mp4', |
71155991 | 22 | 'title': 'Rick and Morty - Pilot', |
3b859145 RA |
23 | 'description': 'Rick moves in with his daughter\'s family and establishes himself as a bad influence on his grandson, Morty.', |
24 | 'timestamp': 1493267400, | |
25 | 'upload_date': '20170427', | |
58cd7e17 | 26 | }, |
3b859145 RA |
27 | 'params': { |
28 | # m3u8 download | |
29 | 'skip_download': True, | |
71155991 | 30 | }, |
3b859145 | 31 | 'expected_warnings': ['Unable to download f4m manifest'], |
cc08b11d NJ |
32 | }, { |
33 | 'url': 'http://www.adultswim.com/videos/tim-and-eric-awesome-show-great-job/dr-steve-brule-for-your-wine/', | |
cc08b11d NJ |
34 | 'info_dict': { |
35 | 'id': 'sY3cMUR_TbuE4YmdjzbIcQ', | |
3b859145 | 36 | 'ext': 'mp4', |
cc08b11d | 37 | 'title': 'Tim and Eric Awesome Show Great Job! - Dr. Steve Brule, For Your Wine', |
3b859145 RA |
38 | 'description': 'Dr. Brule reports live from Wine Country with a special report on wines. \nWatch Tim and Eric Awesome Show Great Job! episode #20, "Embarrassed" on Adult Swim.', |
39 | 'upload_date': '20080124', | |
40 | 'timestamp': 1201150800, | |
cc08b11d | 41 | }, |
0f15ad7b | 42 | 'params': { |
43 | # m3u8 download | |
44 | 'skip_download': True, | |
3b859145 | 45 | }, |
038a5e1a | 46 | }, { |
038a5e1a | 47 | 'url': 'http://www.adultswim.com/videos/decker/inside-decker-a-new-hero/', |
038a5e1a S |
48 | 'info_dict': { |
49 | 'id': 'I0LQFQkaSUaFp8PnAWHhoQ', | |
50 | 'ext': 'mp4', | |
51 | 'title': 'Decker - Inside Decker: A New Hero', | |
3b859145 RA |
52 | 'description': 'The guys recap the conclusion of the season. They announce a new hero, take a peek into the Victorville Film Archive and welcome back the talented James Dean.', |
53 | 'timestamp': 1469480460, | |
54 | 'upload_date': '20160725', | |
038a5e1a S |
55 | }, |
56 | 'params': { | |
57 | # m3u8 download | |
58 | 'skip_download': True, | |
29825140 RA |
59 | }, |
60 | 'expected_warnings': ['Unable to download f4m manifest'], | |
a5a8877f | 61 | }, { |
3b859145 RA |
62 | 'url': 'http://www.adultswim.com/videos/attack-on-titan', |
63 | 'info_dict': { | |
64 | 'id': 'b7A69dzfRzuaXIECdxW8XQ', | |
65 | 'title': 'Attack on Titan', | |
66 | 'description': 'md5:6c8e003ea0777b47013e894767f5e114', | |
67 | }, | |
68 | 'playlist_mincount': 12, | |
69 | }, { | |
70 | 'url': 'http://www.adultswim.com/videos/streams/williams-stream', | |
a5a8877f | 71 | 'info_dict': { |
3b859145 RA |
72 | 'id': 'd8DEBj7QRfetLsRgFnGEyg', |
73 | 'ext': 'mp4', | |
74 | 'title': r're:^Williams Stream \d{4}-\d{2}-\d{2} \d{2}:\d{2}$', | |
75 | 'description': 'original programming', | |
a5a8877f | 76 | }, |
a5a8877f YCH |
77 | 'params': { |
78 | # m3u8 download | |
79 | 'skip_download': True, | |
80 | }, | |
71155991 | 81 | }] |
82 | ||
48fbb100 | 83 | def _real_extract(self, url): |
3b859145 RA |
84 | show_path, episode_path = re.match(self._VALID_URL, url).groups() |
85 | display_id = episode_path or show_path | |
86 | webpage = self._download_webpage(url, display_id) | |
87 | initial_data = self._parse_json(self._search_regex( | |
88 | r'AS_INITIAL_DATA(?:__)?\s*=\s*({.+?});', | |
89 | webpage, 'initial data'), display_id) | |
90 | ||
91 | is_stream = show_path == 'streams' | |
92 | if is_stream: | |
93 | if not episode_path: | |
94 | episode_path = 'live-stream' | |
95 | ||
96 | video_data = next(stream for stream_path, stream in initial_data['streams'].items() if stream_path == episode_path) | |
97 | video_id = video_data.get('stream') | |
98 | ||
99 | if not video_id: | |
100 | entries = [] | |
101 | for episode in video_data.get('archiveEpisodes', []): | |
3052a30d | 102 | episode_url = url_or_none(episode.get('url')) |
3b859145 RA |
103 | if not episode_url: |
104 | continue | |
105 | entries.append(self.url_result( | |
106 | episode_url, 'AdultSwim', episode.get('id'))) | |
107 | return self.playlist_result( | |
108 | entries, video_data.get('id'), video_data.get('title'), | |
109 | strip_or_none(video_data.get('description'))) | |
71155991 | 110 | else: |
3b859145 RA |
111 | show_data = initial_data['show'] |
112 | ||
113 | if not episode_path: | |
114 | entries = [] | |
115 | for video in show_data.get('videos', []): | |
116 | slug = video.get('slug') | |
117 | if not slug: | |
118 | continue | |
119 | entries.append(self.url_result( | |
120 | 'http://adultswim.com/videos/%s/%s' % (show_path, slug), | |
121 | 'AdultSwim', video.get('id'))) | |
122 | return self.playlist_result( | |
123 | entries, show_data.get('id'), show_data.get('title'), | |
124 | strip_or_none(show_data.get('metadata', {}).get('description'))) | |
125 | ||
126 | video_data = show_data['sluggedVideo'] | |
127 | video_id = video_data['id'] | |
128 | ||
129 | info = self._extract_cvp_info( | |
39ee2638 | 130 | 'http://www.adultswim.com/videos/api/v0/assets?platform=desktop&id=' + video_id, |
3b859145 RA |
131 | video_id, { |
132 | 'secure': { | |
133 | 'media_src': 'http://androidhls-secure.cdn.turner.com/adultswim/big', | |
134 | 'tokenizer_src': 'http://www.adultswim.com/astv/mvpd/processors/services/token_ipadAdobe.do', | |
135 | }, | |
136 | }, { | |
137 | 'url': url, | |
138 | 'site_name': 'AdultSwim', | |
139 | 'auth_required': video_data.get('auth'), | |
140 | }) | |
48fbb100 | 141 | |
3b859145 RA |
142 | info.update({ |
143 | 'id': video_id, | |
144 | 'display_id': display_id, | |
145 | 'description': info.get('description') or strip_or_none(video_data.get('description')), | |
146 | }) | |
147 | if not is_stream: | |
148 | info.update({ | |
149 | 'duration': info.get('duration') or int_or_none(video_data.get('duration')), | |
150 | 'timestamp': info.get('timestamp') or int_or_none(video_data.get('launch_date')), | |
151 | 'season_number': info.get('season_number') or int_or_none(video_data.get('season_number')), | |
152 | 'episode': info['title'], | |
153 | 'episode_number': info.get('episode_number') or int_or_none(video_data.get('episode_number')), | |
48fbb100 AMW |
154 | }) |
155 | ||
3b859145 RA |
156 | info['series'] = video_data.get('collection_title') or info.get('series') |
157 | if info['series'] and info['series'] != info['title']: | |
158 | info['title'] = '%s - %s' % (info['series'], info['title']) | |
159 | ||
160 | return info |