1 from __future__ import unicode_literals
5 from .common import InfoExtractor
11 get_element_by_attribute,
13 from ..compat import (
18 class AENetworksBaseIE(InfoExtractor):
19 def theplatform_url_result(self, theplatform_url, video_id, query):
21 '_type': 'url_transparent',
24 update_url_query(theplatform_url, query),
30 'force_smil_url': True
32 'ie_key': 'ThePlatform',
36 class AENetworksIE(AENetworksBaseIE):
37 IE_NAME = 'aenetworks'
38 IE_DESC = 'A+E Networks: A&E, Lifetime, History.com, FYI Network'
39 _VALID_URL = r'https?://(?:www\.)?(?:(?:history|aetv|mylifetime)\.com|fyi\.tv)/(?:shows/(?P<show_path>[^/]+(?:/[^/]+){0,2})|movies/(?P<movie_display_id>[^/]+)/full-movie)'
41 'url': 'http://www.history.com/shows/mountain-men/season-1/episode-1',
42 'md5': '8ff93eb073449f151d6b90c0ae1ef0c7',
46 'title': 'Winter Is Coming',
47 'description': 'md5:641f424b7a19d8e24f26dea22cf59d74',
48 'timestamp': 1338306241,
49 'upload_date': '20120529',
50 'uploader': 'AENE-NEW',
52 'add_ie': ['ThePlatform'],
54 'url': 'http://www.history.com/shows/ancient-aliens/season-1',
58 'playlist_mincount': 5,
60 'url': 'http://www.mylifetime.com/shows/atlanta-plastic',
63 'title': 'Atlanta Plastic',
65 'playlist_mincount': 2,
67 'url': 'http://www.aetv.com/shows/duck-dynasty/season-9/episode-1',
70 'url': 'http://www.fyi.tv/shows/tiny-house-nation/season-1/episode-8',
73 'url': 'http://www.mylifetime.com/shows/project-runway-junior/season-1/episode-6',
76 'url': 'http://www.mylifetime.com/movies/center-stage-on-pointe/full-movie',
80 def _real_extract(self, url):
81 show_path, movie_display_id = re.match(self._VALID_URL, url).groups()
82 display_id = show_path or movie_display_id
83 webpage = self._download_webpage(url, display_id)
85 url_parts = show_path.split('/')
86 url_parts_len = len(url_parts)
87 if url_parts_len == 1:
89 for season_url_path in re.findall(r'(?s)<li[^>]+data-href="(/shows/%s/season-\d+)"' % url_parts[0], webpage):
90 entries.append(self.url_result(
91 compat_urlparse.urljoin(url, season_url_path), 'AENetworks'))
92 return self.playlist_result(
93 entries, self._html_search_meta('aetn:SeriesId', webpage),
94 self._html_search_meta('aetn:SeriesTitle', webpage))
95 elif url_parts_len == 2:
97 for episode_item in re.findall(r'(?s)<div[^>]+class="[^"]*episode-item[^"]*"[^>]*>', webpage):
98 episode_attributes = extract_attributes(episode_item)
99 episode_url = compat_urlparse.urljoin(
100 url, episode_attributes['data-canonical'])
101 entries.append(self.url_result(
102 episode_url, 'AENetworks',
103 episode_attributes['data-videoid']))
104 return self.playlist_result(
105 entries, self._html_search_meta('aetn:SeasonId', webpage))
106 video_id = self._html_search_meta('aetn:VideoID', webpage)
107 media_url = self._search_regex(
108 r"media_url\s*=\s*'([^']+)'", webpage, 'video url')
110 info = self._search_json_ld(webpage, video_id, fatal=False)
111 info.update(self.theplatform_url_result(
112 media_url, video_id, {
114 'assetTypes': 'medium_video_s3'
119 class HistoryTopicIE(AENetworksBaseIE):
120 IE_NAME = 'history:topic'
121 IE_DESC = 'History.com Topic'
122 _VALID_URL = r'https?://(?:www\.)?history\.com/topics/(?:[^/]+/)?(?P<topic_id>[^/]+)/videos(?:/(?P<video_display_id>[^/?#]+))?'
124 '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',
128 'title': "Bet You Didn't Know: Valentine's Day",
129 'description': 'md5:7b57ea4829b391995b405fa60bd7b5f7',
130 'timestamp': 1375819729,
131 'upload_date': '20130806',
132 'uploader': 'AENE-NEW',
136 'skip_download': True,
138 'add_ie': ['ThePlatform'],
140 'url': 'http://www.history.com/topics/world-war-i/world-war-i-history/videos',
143 'id': 'world-war-i-history',
144 'title': 'World War I History',
146 'playlist_mincount': 24,
148 'url': 'http://www.history.com/topics/world-war-i-history/videos',
149 'only_matching': True,
152 def _real_extract(self, url):
153 topic_id, video_display_id = re.match(self._VALID_URL, url).groups()
155 webpage = self._download_webpage(url, video_display_id)
156 release_url, video_id = re.search(r"_videoPlayer.play\('([^']+)'\s*,\s*'[^']+'\s*,\s*'(\d+)'\)", webpage).groups()
157 release_url = unescapeHTML(release_url)
159 return self.theplatform_url_result(
160 release_url, video_id, {
165 webpage = self._download_webpage(url, topic_id)
167 for episode_item in re.findall(r'<a.+?data-release-url="[^"]+"[^>]*>', webpage):
168 video_attributes = extract_attributes(episode_item)
169 entries.append(self.theplatform_url_result(
170 video_attributes['data-release-url'], video_attributes['data-id'], {
174 return self.playlist_result(entries, topic_id, get_element_by_attribute('class', 'show-title', webpage))