projects
/
youtube-dl
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
6903555
)
[nrk] Add X-Forwarded-For HTTP header in info dict
author
Sergey M․
<dstftw@gmail.com>
Sun, 13 Nov 2016 15:28:29 +0000
(22:28 +0700)
committer
Sergey M․
<dstftw@gmail.com>
Sun, 13 Nov 2016 15:28:29 +0000
(22:28 +0700)
youtube_dl/extractor/nrk.py
patch
|
blob
|
history
diff --git
a/youtube_dl/extractor/nrk.py
b/youtube_dl/extractor/nrk.py
index aed98141be2365aeca164649a829a0efa72b6b01..1f2204833acceb8fb39e2b3731d156438451dc98 100644
(file)
--- a/
youtube_dl/extractor/nrk.py
+++ b/
youtube_dl/extractor/nrk.py
@@
-17,14
+17,15
@@
from ..utils import (
class NRKBaseIE(InfoExtractor):
_faked_ip = None
class NRKBaseIE(InfoExtractor):
_faked_ip = None
- def _download_webpage(self, *args, **kwargs):
+ def _download_webpage
_handle
(self, *args, **kwargs):
# NRK checks X-Forwarded-For HTTP header in order to figure out the
# origin of the client behind proxy. This allows to bypass geo
# restriction by faking this header's value to some Norway IP.
# We will do so once we encounter any geo restriction error.
if self._faked_ip:
# NRK checks X-Forwarded-For HTTP header in order to figure out the
# origin of the client behind proxy. This allows to bypass geo
# restriction by faking this header's value to some Norway IP.
# We will do so once we encounter any geo restriction error.
if self._faked_ip:
- kwargs.setdefault('headers', {})['X-Forwarded-For'] = self._faked_ip
- return super(NRKBaseIE, self)._download_webpage(*args, **kwargs)
+ # NB: str is intentional
+ kwargs.setdefault(str('headers'), {})['X-Forwarded-For'] = self._faked_ip
+ return super(NRKBaseIE, self)._download_webpage_handle(*args, **kwargs)
def _fake_ip(self):
# Use fake IP from 37.191.128.0/17 in order to workaround geo
def _fake_ip(self):
# Use fake IP from 37.191.128.0/17 in order to workaround geo
@@
-43,6
+44,8
@@
class NRKBaseIE(InfoExtractor):
title = data.get('fullTitle') or data.get('mainTitle') or data['title']
video_id = data.get('id') or video_id
title = data.get('fullTitle') or data.get('mainTitle') or data['title']
video_id = data.get('id') or video_id
+ http_headers = {'X-Forwarded-For': self._faked_ip} if self._faked_ip else {}
+
entries = []
media_assets = data.get('mediaAssets')
entries = []
media_assets = data.get('mediaAssets')
@@
-73,6
+76,7
@@
class NRKBaseIE(InfoExtractor):
'duration': duration,
'subtitles': subtitles,
'formats': formats,
'duration': duration,
'subtitles': subtitles,
'formats': formats,
+ 'http_headers': http_headers,
})
if not entries:
})
if not entries: