]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/aenetworks.py
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'
26 _VALID_URL
= r
'https?://(?:www\.)?(?P<domain>(?:history|aetv|mylifetime)\.com|fyi\.tv)/(?:shows/(?P<show_path>[^/]+(?:/[^/]+){0,2})|movies/(?P<movie_display_id>[^/]+)/full-movie)'
28 'url': 'http://www.history.com/shows/mountain-men/season-1/episode-1',
29 'md5': '8ff93eb073449f151d6b90c0ae1ef0c7',
33 'title': 'Winter Is Coming',
34 'description': 'md5:641f424b7a19d8e24f26dea22cf59d74',
35 'timestamp': 1338306241,
36 'upload_date': '20120529',
37 'uploader': 'AENE-NEW',
39 'add_ie': ['ThePlatform'],
41 'url': 'http://www.history.com/shows/ancient-aliens/season-1',
45 'playlist_mincount': 5,
47 'url': 'http://www.mylifetime.com/shows/atlanta-plastic',
50 'title': 'Atlanta Plastic',
52 'playlist_mincount': 2,
54 'url': 'http://www.aetv.com/shows/duck-dynasty/season-9/episode-1',
57 'url': 'http://www.fyi.tv/shows/tiny-house-nation/season-1/episode-8',
60 'url': 'http://www.mylifetime.com/shows/project-runway-junior/season-1/episode-6',
63 'url': 'http://www.mylifetime.com/movies/center-stage-on-pointe/full-movie',
66 _DOMAIN_TO_REQUESTOR_ID
= {
67 'history.com': 'HISTORY',
69 'mylifetime.com': 'LIFETIME',
73 def _real_extract(self
, url
):
74 domain
, show_path
, movie_display_id
= re
.match(self
._VALID
_URL
, url
).groups()
75 display_id
= show_path
or movie_display_id
76 webpage
= self
._download
_webpage
(url
, display_id
)
78 url_parts
= show_path
.split('/')
79 url_parts_len
= len(url_parts
)
80 if url_parts_len
== 1:
82 for season_url_path
in re
.findall(r
'(?s)<li[^>]+data-href="(/shows/%s/season-\d+)"' % url_parts
[0], webpage
):
83 entries
.append(self
.url_result(
84 compat_urlparse
.urljoin(url
, season_url_path
), 'AENetworks'))
85 return self
.playlist_result(
86 entries
, self
._html
_search
_meta
('aetn:SeriesId', webpage
),
87 self
._html
_search
_meta
('aetn:SeriesTitle', webpage
))
88 elif url_parts_len
== 2:
90 for episode_item
in re
.findall(r
'(?s)<div[^>]+class="[^"]*episode-item[^"]*"[^>]*>', webpage
):
91 episode_attributes
= extract_attributes(episode_item
)
92 episode_url
= compat_urlparse
.urljoin(
93 url
, episode_attributes
['data-canonical'])
94 entries
.append(self
.url_result(
95 episode_url
, 'AENetworks',
96 episode_attributes
['data-videoid']))
97 return self
.playlist_result(
98 entries
, self
._html
_search
_meta
('aetn:SeasonId', webpage
))
102 'assetTypes': 'medium_video_s3'
104 video_id
= self
._html
_search
_meta
('aetn:VideoID', webpage
)
105 media_url
= self
._search
_regex
(
106 r
"media_url\s*=\s*'([^']+)'", webpage
, 'video url')
107 theplatform_metadata
= self
._download
_theplatform
_metadata
(self
._search
_regex
(
108 r
'https?://link.theplatform.com/s/([^?]+)', media_url
, 'theplatform_path'), video_id
)
109 info
= self
._parse
_theplatform
_metadata
(theplatform_metadata
)
110 if theplatform_metadata
.get('AETN$isBehindWall'):
111 requestor_id
= self
._DOMAIN
_TO
_REQUESTOR
_ID
[domain
]
112 resource
= '<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>%s</title><item><title>%s</title><guid>%s</guid><media:rating scheme="urn:v-chip">%s</media:rating></item></channel></rss>' % (requestor_id
, theplatform_metadata
['title'], theplatform_metadata
['AETN$PPL_pplProgramId'], theplatform_metadata
['ratings'][0]['rating'])
113 query
['auth'] = self
._extract
_mvpd
_auth
(
114 url
, video_id
, requestor_id
, resource
)
115 info
.update(self
._search
_json
_ld
(webpage
, video_id
, fatal
=False))
116 media_url
= update_url_query(media_url
, query
)
117 media_url
= self
._sign
_url
(media_url
, self
._THEPLATFORM
_KEY
, self
._THEPLATFORM
_SECRET
)
118 formats
, subtitles
= self
._extract
_theplatform
_smil
(media_url
, video_id
)
119 self
._sort
_formats
(formats
)
123 'subtitles': subtitles
,
128 class HistoryTopicIE(AENetworksBaseIE
):
129 IE_NAME
= 'history:topic'
130 IE_DESC
= 'History.com Topic'
131 _VALID_URL
= r
'https?://(?:www\.)?history\.com/topics/(?:[^/]+/)?(?P<topic_id>[^/]+)(?:/[^/]+(?:/(?P<video_display_id>[^/?#]+))?)?'
133 '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',
137 'title': "Bet You Didn't Know: Valentine's Day",
138 'description': 'md5:7b57ea4829b391995b405fa60bd7b5f7',
139 'timestamp': 1375819729,
140 'upload_date': '20130806',
141 'uploader': 'AENE-NEW',
145 'skip_download': True,
147 'add_ie': ['ThePlatform'],
149 'url': 'http://www.history.com/topics/world-war-i/world-war-i-history/videos',
152 'id': 'world-war-i-history',
153 'title': 'World War I History',
155 'playlist_mincount': 24,
157 'url': 'http://www.history.com/topics/world-war-i-history/videos',
158 'only_matching': True,
160 'url': 'http://www.history.com/topics/world-war-i/world-war-i-history',
161 'only_matching': True,
163 'url': 'http://www.history.com/topics/world-war-i/world-war-i-history/speeches',
164 'only_matching': True,
167 def theplatform_url_result(self
, theplatform_url
, video_id
, query
):
169 '_type': 'url_transparent',
172 update_url_query(theplatform_url
, query
),
175 'key': self
._THEPLATFORM
_KEY
,
176 'secret': self
._THEPLATFORM
_SECRET
,
178 'force_smil_url': True
180 'ie_key': 'ThePlatform',
183 def _real_extract(self
, url
):
184 topic_id
, video_display_id
= re
.match(self
._VALID
_URL
, url
).groups()
186 webpage
= self
._download
_webpage
(url
, video_display_id
)
187 release_url
, video_id
= re
.search(r
"_videoPlayer.play\('([^']+)'\s*,\s*'[^']+'\s*,\s*'(\d+)'\)", webpage
).groups()
188 release_url
= unescapeHTML(release_url
)
190 return self
.theplatform_url_result(
191 release_url
, video_id
, {
196 webpage
= self
._download
_webpage
(url
, topic_id
)
198 for episode_item
in re
.findall(r
'<a.+?data-release-url="[^"]+"[^>]*>', webpage
):
199 video_attributes
= extract_attributes(episode_item
)
200 entries
.append(self
.theplatform_url_result(
201 video_attributes
['data-release-url'], video_attributes
['data-id'], {
205 return self
.playlist_result(entries
, topic_id
, get_element_by_attribute('class', 'show-title', webpage
))