1 from __future__
import unicode_literals
5 from .theplatform
import ThePlatformIE
11 get_element_by_attribute
,
13 from ..compat
import (
18 class AENetworksBaseIE(ThePlatformIE
):
19 _THEPLATFORM_KEY
= 'crazyjava'
20 _THEPLATFORM_SECRET
= 's3cr3t'
23 class AENetworksIE(AENetworksBaseIE
):
24 IE_NAME
= 'aenetworks'
25 IE_DESC
= 'A+E Networks: A&E, Lifetime, History.com, FYI Network'
30 (?:history|aetv|mylifetime|lifetimemovieclub)\.com|
34 shows/(?P<show_path>[^/]+(?:/[^/]+){0,2})|
35 movies/(?P<movie_display_id>[^/]+)(?:/full-movie)?|
36 specials/(?P<special_display_id>[^/]+)/full-special
40 'url': 'http://www.history.com/shows/mountain-men/season-1/episode-1',
41 'md5': 'a97a65f7e823ae10e9244bc5433d5fe6',
45 'title': 'Winter Is Coming',
46 'description': 'md5:641f424b7a19d8e24f26dea22cf59d74',
47 'timestamp': 1338306241,
48 'upload_date': '20120529',
49 'uploader': 'AENE-NEW',
51 'add_ie': ['ThePlatform'],
53 'url': 'http://www.history.com/shows/ancient-aliens/season-1',
57 'playlist_mincount': 5,
59 'url': 'http://www.mylifetime.com/shows/atlanta-plastic',
62 'title': 'Atlanta Plastic',
64 'playlist_mincount': 2,
66 'url': 'http://www.aetv.com/shows/duck-dynasty/season-9/episode-1',
69 'url': 'http://www.fyi.tv/shows/tiny-house-nation/season-1/episode-8',
72 'url': 'http://www.mylifetime.com/shows/project-runway-junior/season-1/episode-6',
75 'url': 'http://www.mylifetime.com/movies/center-stage-on-pointe/full-movie',
78 'url': 'https://www.lifetimemovieclub.com/movies/a-killer-among-us',
81 'url': 'http://www.history.com/specials/sniper-into-the-kill-zone/full-special',
84 _DOMAIN_TO_REQUESTOR_ID
= {
85 'history.com': 'HISTORY',
87 'mylifetime.com': 'LIFETIME',
88 'lifetimemovieclub.com': 'LIFETIMEMOVIECLUB',
92 def _real_extract(self
, url
):
93 domain
, show_path
, movie_display_id
, special_display_id
= re
.match(self
._VALID
_URL
, url
).groups()
94 display_id
= show_path
or movie_display_id
or special_display_id
95 webpage
= self
._download
_webpage
(url
, display_id
)
97 url_parts
= show_path
.split('/')
98 url_parts_len
= len(url_parts
)
99 if url_parts_len
== 1:
101 for season_url_path
in re
.findall(r
'(?s)<li[^>]+data-href="(/shows/%s/season-\d+)"' % url_parts
[0], webpage
):
102 entries
.append(self
.url_result(
103 compat_urlparse
.urljoin(url
, season_url_path
), 'AENetworks'))
105 return self
.playlist_result(
106 entries
, self
._html
_search
_meta
('aetn:SeriesId', webpage
),
107 self
._html
_search
_meta
('aetn:SeriesTitle', webpage
))
111 if url_parts_len
== 2:
113 for episode_item
in re
.findall(r
'(?s)<[^>]+class="[^"]*(?:episode|program)-item[^"]*"[^>]*>', webpage
):
114 episode_attributes
= extract_attributes(episode_item
)
115 episode_url
= compat_urlparse
.urljoin(
116 url
, episode_attributes
['data-canonical'])
117 entries
.append(self
.url_result(
118 episode_url
, 'AENetworks',
119 episode_attributes
.get('data-videoid') or episode_attributes
.get('data-video-id')))
120 return self
.playlist_result(
121 entries
, self
._html
_search
_meta
('aetn:SeasonId', webpage
))
125 'assetTypes': 'high_video_ak',
126 'switch': 'hls_high_ak',
128 video_id
= self
._html
_search
_meta
('aetn:VideoID', webpage
)
129 media_url
= self
._search
_regex
(
130 [r
"media_url\s*=\s*'(?P<url>[^']+)'",
131 r
'data-media-url=(?P<url>(?:https?:)?//[^\s>]+)',
132 r
'data-media-url=(["\'])(?P
<url
>(?
:(?
!\
1).)+?
)\
1'],
133 webpage, 'video url
', group='url
')
134 theplatform_metadata = self._download_theplatform_metadata(self._search_regex(
135 r'https?
://link\
.theplatform\
.com
/s
/([^?
]+)', media_url, 'theplatform_path
'), video_id)
136 info = self._parse_theplatform_metadata(theplatform_metadata)
137 if theplatform_metadata.get('AETN$isBehindWall
'):
138 requestor_id = self._DOMAIN_TO_REQUESTOR_ID[domain]
139 resource = self._get_mvpd_resource(
140 requestor_id, theplatform_metadata['title
'],
141 theplatform_metadata.get('AETN$PPL_pplProgramId
') or theplatform_metadata.get('AETN$PPL_pplProgramId_OLD
'),
142 theplatform_metadata['ratings
'][0]['rating
'])
143 query['auth
'] = self._extract_mvpd_auth(
144 url, video_id, requestor_id, resource)
145 info.update(self._search_json_ld(webpage, video_id, fatal=False))
146 media_url = update_url_query(media_url, query)
147 media_url = self._sign_url(media_url, self._THEPLATFORM_KEY, self._THEPLATFORM_SECRET)
148 formats, subtitles = self._extract_theplatform_smil(media_url, video_id)
149 self._sort_formats(formats)
153 'subtitles
': subtitles,
158 class HistoryTopicIE(AENetworksBaseIE):
159 IE_NAME = 'history
:topic
'
160 IE_DESC = 'History
.com Topic
'
161 _VALID_URL = r'https?
://(?
:www\
.)?history\
.com
/topics
/(?
:[^
/]+/)?
(?P
<topic_id
>[^
/]+)(?
:/[^
/]+(?
:/(?P
<video_display_id
>[^
/?
#]+))?)?'
163 'url': 'http://www.history.com/topics/valentines-day/history-of-valentines-day/videos/bet-you-didnt-know-valentines-day?m=528e394da93ae&s=undefined&f=1&free=false',
167 'title': "Bet You Didn't Know: Valentine's Day",
168 'description': 'md5:7b57ea4829b391995b405fa60bd7b5f7',
169 'timestamp': 1375819729,
170 'upload_date': '20130806',
171 'uploader': 'AENE-NEW',
175 'skip_download': True,
177 'add_ie': ['ThePlatform'],
179 'url': 'http://www.history.com/topics/world-war-i/world-war-i-history/videos',
182 'id': 'world-war-i-history',
183 'title': 'World War I History',
185 'playlist_mincount': 23,
187 'url': 'http://www.history.com/topics/world-war-i-history/videos',
188 'only_matching': True,
190 'url': 'http://www.history.com/topics/world-war-i/world-war-i-history',
191 'only_matching': True,
193 'url': 'http://www.history.com/topics/world-war-i/world-war-i-history/speeches',
194 'only_matching': True,
197 def theplatform_url_result(self
, theplatform_url
, video_id
, query
):
199 '_type': 'url_transparent',
202 update_url_query(theplatform_url
, query
),
205 'key': self
._THEPLATFORM
_KEY
,
206 'secret': self
._THEPLATFORM
_SECRET
,
208 'force_smil_url': True
210 'ie_key': 'ThePlatform',
213 def _real_extract(self
, url
):
214 topic_id
, video_display_id
= re
.match(self
._VALID
_URL
, url
).groups()
216 webpage
= self
._download
_webpage
(url
, video_display_id
)
217 release_url
, video_id
= re
.search(r
"_videoPlayer.play\('([^']+)'\s*,\s*'[^']+'\s*,\s*'(\d+)'\)", webpage
).groups()
218 release_url
= unescapeHTML(release_url
)
220 return self
.theplatform_url_result(
221 release_url
, video_id
, {
224 'assetTypes': 'high_video_ak',
227 webpage
= self
._download
_webpage
(url
, topic_id
)
229 for episode_item
in re
.findall(r
'<a.+?data-release-url="[^"]+"[^>]*>', webpage
):
230 video_attributes
= extract_attributes(episode_item
)
231 entries
.append(self
.theplatform_url_result(
232 video_attributes
['data-release-url'], video_attributes
['data-id'], {
235 'assetTypes': 'high_video_ak',
237 return self
.playlist_result(entries
, topic_id
, get_element_by_attribute('class', 'show-title', webpage
))