[aenetworks] add support for movie pages

master
Remita Amine 2016-06-29 16:55:17 +01:00
parent c58ed8563d
commit 70157c2c43
1 changed files with 42 additions and 38 deletions

View File

@ -36,7 +36,7 @@ class AENetworksBaseIE(InfoExtractor):
class AENetworksIE(AENetworksBaseIE): class AENetworksIE(AENetworksBaseIE):
IE_NAME = 'aenetworks' IE_NAME = 'aenetworks'
IE_DESC = 'A+E Networks: A&E, Lifetime, History.com, FYI Network' IE_DESC = 'A+E Networks: A&E, Lifetime, History.com, FYI Network'
_VALID_URL = r'https?://(?:www\.)?(?:(?:history|aetv|mylifetime)\.com|fyi\.tv)/shows/(?P<id>[^/]+(?:/[^/]+){0,2})' _VALID_URL = r'https?://(?:www\.)?(?:(?:history|aetv|mylifetime)\.com|fyi\.tv)/(?:shows/(?P<show_path>[^/]+(?:/[^/]+){0,2})|movies/(?P<movie_display_id>[^/]+)/full-movie)'
_TESTS = [{ _TESTS = [{
'url': 'http://www.history.com/shows/mountain-men/season-1/episode-1', 'url': 'http://www.history.com/shows/mountain-men/season-1/episode-1',
'md5': '8ff93eb073449f151d6b90c0ae1ef0c7', 'md5': '8ff93eb073449f151d6b90c0ae1ef0c7',
@ -72,50 +72,54 @@ class AENetworksIE(AENetworksBaseIE):
}, { }, {
'url': 'http://www.mylifetime.com/shows/project-runway-junior/season-1/episode-6', 'url': 'http://www.mylifetime.com/shows/project-runway-junior/season-1/episode-6',
'only_matching': True 'only_matching': True
}, {
'url': 'http://www.mylifetime.com/movies/center-stage-on-pointe/full-movie',
'only_matching': True
}] }]
def _real_extract(self, url): def _real_extract(self, url):
display_id = self._match_id(url) show_path, movie_display_id = re.match(self._VALID_URL, url).groups()
display_id = show_path or movie_display_id
webpage = self._download_webpage(url, display_id) webpage = self._download_webpage(url, display_id)
url_parts = display_id.split('/') if show_path:
url_parts_len = len(url_parts) url_parts = show_path.split('/')
if url_parts_len == 1: url_parts_len = len(url_parts)
entries = [] if url_parts_len == 1:
for season_url_path in re.findall(r'(?s)<li[^>]+data-href="(/shows/%s/season-\d+)"' % url_parts[0], webpage): entries = []
entries.append(self.url_result( for season_url_path in re.findall(r'(?s)<li[^>]+data-href="(/shows/%s/season-\d+)"' % url_parts[0], webpage):
compat_urlparse.urljoin(url, season_url_path), 'AENetworks')) entries.append(self.url_result(
return self.playlist_result( compat_urlparse.urljoin(url, season_url_path), 'AENetworks'))
entries, self._html_search_meta('aetn:SeriesId', webpage), return self.playlist_result(
self._html_search_meta('aetn:SeriesTitle', webpage)) entries, self._html_search_meta('aetn:SeriesId', webpage),
elif url_parts_len == 2: self._html_search_meta('aetn:SeriesTitle', webpage))
entries = [] elif url_parts_len == 2:
for episode_item in re.findall(r'(?s)<div[^>]+class="[^"]*episode-item[^"]*"[^>]*>', webpage): entries = []
episode_attributes = extract_attributes(episode_item) for episode_item in re.findall(r'(?s)<div[^>]+class="[^"]*episode-item[^"]*"[^>]*>', webpage):
episode_url = compat_urlparse.urljoin( episode_attributes = extract_attributes(episode_item)
url, episode_attributes['data-canonical']) episode_url = compat_urlparse.urljoin(
entries.append(self.url_result( url, episode_attributes['data-canonical'])
episode_url, 'AENetworks', entries.append(self.url_result(
episode_attributes['data-videoid'])) episode_url, 'AENetworks',
return self.playlist_result( episode_attributes['data-videoid']))
entries, self._html_search_meta('aetn:SeasonId', webpage)) return self.playlist_result(
else: entries, self._html_search_meta('aetn:SeasonId', webpage))
video_id = self._html_search_meta('aetn:VideoID', webpage) video_id = self._html_search_meta('aetn:VideoID', webpage)
media_url = self._search_regex( media_url = self._search_regex(
r"media_url\s*=\s*'([^']+)'", webpage, 'video url') r"media_url\s*=\s*'([^']+)'", webpage, 'video url')
info = self._search_json_ld(webpage, video_id, fatal=False) info = self._search_json_ld(webpage, video_id, fatal=False)
info.update(self.theplatform_url_result( info.update(self.theplatform_url_result(
media_url, video_id, { media_url, video_id, {
'mbr': 'true', 'mbr': 'true',
'assetTypes': 'medium_video_s3' 'assetTypes': 'medium_video_s3'
})) }))
return info return info
class HistoryTopicIE(AENetworksBaseIE): class HistoryTopicIE(AENetworksBaseIE):
IE_NAME = 'history:topic' IE_NAME = 'history:topic'
IE_DESC = 'History.com Topic' IE_DESC = 'History.com Topic'
_VALID_URL = r'https?://(?:www\.)?history\.com/topics/(?:[^/]+/)?(?P<topic_id>[^/]+)/videos(?:/(?P<display_id>[^/?#]+))?' _VALID_URL = r'https?://(?:www\.)?history\.com/topics/(?:[^/]+/)?(?P<topic_id>[^/]+)/videos(?:/(?P<video_display_id>[^/?#]+))?'
_TESTS = [{ _TESTS = [{
'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', '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',
'info_dict': { 'info_dict': {
@ -146,9 +150,9 @@ class HistoryTopicIE(AENetworksBaseIE):
}] }]
def _real_extract(self, url): def _real_extract(self, url):
topic_id, display_id = re.match(self._VALID_URL, url).groups() topic_id, video_display_id = re.match(self._VALID_URL, url).groups()
if display_id: if video_display_id:
webpage = self._download_webpage(url, display_id) webpage = self._download_webpage(url, video_display_id)
release_url, video_id = re.search(r"_videoPlayer.play\('([^']+)'\s*,\s*'[^']+'\s*,\s*'(\d+)'\)", webpage).groups() release_url, video_id = re.search(r"_videoPlayer.play\('([^']+)'\s*,\s*'[^']+'\s*,\s*'(\d+)'\)", webpage).groups()
release_url = unescapeHTML(release_url) release_url = unescapeHTML(release_url)