fix: rebuild formats from yt-dlp data
makes yattee and freetube work
This commit is contained in:
@@ -13,6 +13,11 @@ ytdl_opts = {
|
||||
"default": "%(id)s.%(ext)s",
|
||||
"chapter": "%(id)s.%(ext)s_%(section_number)03d_%(section_title)s.%(ext)s"
|
||||
},
|
||||
"extractor_args": {
|
||||
"youtube": {
|
||||
"formats": ["dashy"]
|
||||
}
|
||||
},
|
||||
"simulate": True
|
||||
}
|
||||
|
||||
@@ -123,7 +128,7 @@ web_context_dict = {
|
||||
}
|
||||
}
|
||||
|
||||
def extract(url: str, getcomments=False, maxcomments=""):
|
||||
def extract(url: str, getcomments=False, maxcomments="", manifest_fix=False):
|
||||
# TODO: check user-agent and cookiefile
|
||||
|
||||
if ythdd_globals.config['extractor']['user-agent']:
|
||||
@@ -137,9 +142,12 @@ def extract(url: str, getcomments=False, maxcomments=""):
|
||||
if getcomments:
|
||||
ytdl_opts['getcomments'] = True
|
||||
if maxcomments:
|
||||
ytdl_opts['extractor_args'] = {'youtube': {'max_comments': [maxcomments, "all", "all", "all"]}}
|
||||
ytdl_opts['extractor_args']['youtube']['max_comments'] = [maxcomments, "all", "all", "all"]
|
||||
if manifest_fix:
|
||||
# https://github.com/yt-dlp/yt-dlp/issues/11952#issuecomment-2565802294
|
||||
ytdl_opts['extractor_args']['youtube']['player_client'] = ['default', 'web_safari']
|
||||
with yt_dlp.YoutubeDL(ytdl_opts) as ytdl:
|
||||
result = ytdl.extract_info(url, download=False)
|
||||
result = ytdl.sanitize_info(ytdl.extract_info(url, download=False))
|
||||
return result
|
||||
|
||||
def WEBrelated(url: str):
|
||||
@@ -183,6 +191,19 @@ def WEBextractSinglePage(uri: str):
|
||||
|
||||
return {'ec1': extracted_json1, 'ec2': extracted_json2, 'took': end_time - start_time}
|
||||
|
||||
def paramsFromUrl(url: str) -> dict:
|
||||
# Returns a dictionary of params from a given URL.
|
||||
split_list = url.split("&")
|
||||
params = {}
|
||||
|
||||
for num, string in enumerate(split_list):
|
||||
if num == 0:
|
||||
string = string[string.find("?") + 1:]
|
||||
key, value = string.split("=")
|
||||
params[key] = value
|
||||
|
||||
return params
|
||||
|
||||
def IOSextract(uri: str):
|
||||
|
||||
start = time.time()
|
||||
|
||||
Reference in New Issue
Block a user