download, thumbnail, sub API에 headers 키 추가

This commit is contained in:
joyfuI
2022-07-24 21:56:46 +09:00
parent 26e4f96d49
commit 3410ddd73c
4 changed files with 32 additions and 6 deletions

View File

@@ -118,7 +118,10 @@ class MyYoutubeDL:
self.status = Status.START
# 동영상 정보 가져오기
info_dict = MyYoutubeDL.get_info_dict(
self.url, self.opts.get("proxy"), self.opts.get("cookiefile")
self.url,
self.opts.get("proxy"),
self.opts.get("cookiefile"),
self.opts.get("http_headers"),
)
if info_dict is None:
self.status = Status.ERROR
@@ -174,7 +177,7 @@ class MyYoutubeDL:
return __version__
@staticmethod
def get_info_dict(url, proxy=None, cookiefile=None):
def get_info_dict(url, proxy=None, cookiefile=None, http_headers=None):
# import youtube_dl
youtube_dl = __import__(youtube_dl_package)
@@ -184,6 +187,8 @@ class MyYoutubeDL:
ydl_opts["proxy"] = proxy
if cookiefile:
ydl_opts["cookiefile"] = cookiefile
if http_headers:
ydl_opts["http_headers"] = http_headers
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
info = ydl.extract_info(url, download=False)
except Exception as error: