Fix manifest
This commit is contained in:
parent
e95d814709
commit
20b133dbb6
|
@ -7,7 +7,7 @@ import traceback
|
|||
import youtube_dlc
|
||||
import urllib.error
|
||||
from tools.converters import *
|
||||
from tools.extractors import extract_yt_initial_data
|
||||
from tools.extractors import extract_yt_initial_data, extract_yt_initial_player_response
|
||||
from math import floor
|
||||
from cachetools import TTLCache
|
||||
|
||||
|
@ -255,17 +255,19 @@ def get_more_stuff_from_file(id, result):
|
|||
"second__liveNow": is_live(r)
|
||||
} for r in [get_useful_recommendation_data(r) for r in recommendations if get_useful_recommendation_data(r)])
|
||||
|
||||
m_yt_player_config = re.search(r_yt_player_config, content)
|
||||
if m_yt_player_config:
|
||||
yt_player_config = json.loads(m_yt_player_config.group(1))
|
||||
player_response = json.loads(yt_player_config["args"]["player_response"])
|
||||
if "dashManifestUrl" in player_response["streamingData"]:
|
||||
result["second__providedDashUrl"] = player_response["streamingData"]["dashManifestUrl"]
|
||||
result["liveNow"] = player_response["videoDetails"]["isLiveContent"]
|
||||
# m_yt_player_config = re.search(r_yt_player_config, content)
|
||||
# if m_yt_player_config:
|
||||
# yt_player_config = json.loads(m_yt_player_config.group(1))
|
||||
|
||||
player_response = extract_yt_initial_player_response(content)
|
||||
|
||||
# result = player_response
|
||||
# return result
|
||||
|
||||
if "dashManifestUrl" in player_response["streamingData"]:
|
||||
result["second__providedDashUrl"] = player_response["streamingData"]["dashManifestUrl"]
|
||||
result["liveNow"] = player_response["videoDetails"]["isLiveContent"]
|
||||
|
||||
itagDict = {}
|
||||
for f in player_response["streamingData"]["adaptiveFormats"]:
|
||||
if "indexRange" in f:
|
||||
|
|
|
@ -2,6 +2,7 @@ import re
|
|||
import json
|
||||
|
||||
r_yt_initial_data = re.compile(r"""(?:^\s*window\["ytInitialData"\]|var ytInitialData) = (\{.+?\});(?:\s*$|</script>)""", re.S + re.M)
|
||||
r_yt_initial_player_response = re.compile(r"""(?:^\s*window\["ytInitialPlayerResponse"\]|var ytInitialPlayerResponse) = (\{.+?\});(?:\s*$|</script>|var )""", re.S + re.M)
|
||||
|
||||
def extract_yt_initial_data(content):
|
||||
m_yt_initial_data = re.search(r_yt_initial_data, content)
|
||||
|
@ -10,3 +11,11 @@ def extract_yt_initial_data(content):
|
|||
return yt_initial_data
|
||||
else:
|
||||
raise Exception("Could not match ytInitialData in content")
|
||||
|
||||
def extract_yt_initial_player_response(content):
|
||||
m_yt_initial_player_response = re.search(r_yt_initial_player_response, content)
|
||||
if m_yt_initial_player_response:
|
||||
yt_initial_player_response = json.loads(m_yt_initial_player_response.group(1))
|
||||
return yt_initial_player_response
|
||||
else:
|
||||
raise Exception("Could not match ytInitialPlayerResponse in content")
|
||||
|
|
Loading…
Reference in New Issue