mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-14 15:22:35 +00:00
[YoutubeDL] Use a Request object for getting the cookies (fixes #4970)
So that we don't have to implement all the methods used by the cookiejar.
This commit is contained in:
parent
163d966707
commit
662435f728
1 changed files with 2 additions and 23 deletions
|
@ -954,30 +954,9 @@ class YoutubeDL(object):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _calc_cookies(self, info_dict):
|
def _calc_cookies(self, info_dict):
|
||||||
class _PseudoRequest(object):
|
pr = compat_urllib_request.Request(info_dict['url'])
|
||||||
def __init__(self, url):
|
|
||||||
self.url = url
|
|
||||||
self.headers = {}
|
|
||||||
self.unverifiable = False
|
|
||||||
|
|
||||||
def add_unredirected_header(self, k, v):
|
|
||||||
self.headers[k] = v
|
|
||||||
|
|
||||||
def get_full_url(self):
|
|
||||||
return self.url
|
|
||||||
|
|
||||||
def is_unverifiable(self):
|
|
||||||
return self.unverifiable
|
|
||||||
|
|
||||||
def has_header(self, h):
|
|
||||||
return h in self.headers
|
|
||||||
|
|
||||||
def get_header(self, h, default=None):
|
|
||||||
return self.headers.get(h, default)
|
|
||||||
|
|
||||||
pr = _PseudoRequest(info_dict['url'])
|
|
||||||
self.cookiejar.add_cookie_header(pr)
|
self.cookiejar.add_cookie_header(pr)
|
||||||
return pr.headers.get('Cookie')
|
return pr.get_header('Cookie')
|
||||||
|
|
||||||
def process_video_result(self, info_dict, download=True):
|
def process_video_result(self, info_dict, download=True):
|
||||||
assert info_dict.get('_type', 'video') == 'video'
|
assert info_dict.get('_type', 'video') == 'video'
|
||||||
|
|
Loading…
Reference in a new issue