[brightcove] Use the original url (usually the player) as the default referer (fixes #1929)
This commit is contained in:
parent
4ff50ef846
commit
77526143e7
|
@ -55,6 +55,18 @@ class BrightcoveIE(InfoExtractor):
|
||||||
u'uploader': u'Mashable',
|
u'uploader': u'Mashable',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
# test that the default referer works
|
||||||
|
# from http://national.ballet.ca/interact/video/Lost_in_Motion_II/
|
||||||
|
u'url': u'http://link.brightcove.com/services/player/bcpid756015033001?bckey=AQ~~,AAAApYJi_Ck~,GxhXCegT1Dp39ilhXuxMJxasUhVNZiil&bctid=2878862109001',
|
||||||
|
u'info_dict': {
|
||||||
|
u'id': u'2878862109001',
|
||||||
|
u'ext': u'mp4',
|
||||||
|
u'title': u'Lost in Motion II',
|
||||||
|
u'description': u'md5:363109c02998fee92ec02211bd8000df',
|
||||||
|
u'uploader': u'National Ballet of Canada',
|
||||||
|
},
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -118,17 +130,21 @@ class BrightcoveIE(InfoExtractor):
|
||||||
|
|
||||||
videoPlayer = query.get('@videoPlayer')
|
videoPlayer = query.get('@videoPlayer')
|
||||||
if videoPlayer:
|
if videoPlayer:
|
||||||
return self._get_video_info(videoPlayer[0], query_str, query)
|
return self._get_video_info(videoPlayer[0], query_str, query,
|
||||||
|
# We set the original url as the default 'Referer' header
|
||||||
|
referer=url)
|
||||||
else:
|
else:
|
||||||
player_key = query['playerKey']
|
player_key = query['playerKey']
|
||||||
return self._get_playlist_info(player_key[0])
|
return self._get_playlist_info(player_key[0])
|
||||||
|
|
||||||
def _get_video_info(self, video_id, query_str, query):
|
def _get_video_info(self, video_id, query_str, query, referer=None):
|
||||||
request_url = self._FEDERATED_URL_TEMPLATE % query_str
|
request_url = self._FEDERATED_URL_TEMPLATE % query_str
|
||||||
req = compat_urllib_request.Request(request_url)
|
req = compat_urllib_request.Request(request_url)
|
||||||
linkBase = query.get('linkBaseURL')
|
linkBase = query.get('linkBaseURL')
|
||||||
if linkBase is not None:
|
if linkBase is not None:
|
||||||
req.add_header('Referer', linkBase[0])
|
referer = linkBase[0]
|
||||||
|
if referer is not None:
|
||||||
|
req.add_header('Referer', referer)
|
||||||
webpage = self._download_webpage(req, video_id)
|
webpage = self._download_webpage(req, video_id)
|
||||||
|
|
||||||
self.report_extraction(video_id)
|
self.report_extraction(video_id)
|
||||||
|
|
Loading…
Reference in New Issue