mirror of
https://git.sr.ht/~cadence/NewLeaf
synced 2024-11-22 07:37:29 +00:00
Fix manifest
This commit is contained in:
parent
e95d814709
commit
20b133dbb6
@ -7,7 +7,7 @@ import traceback
|
|||||||
import youtube_dlc
|
import youtube_dlc
|
||||||
import urllib.error
|
import urllib.error
|
||||||
from tools.converters import *
|
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 math import floor
|
||||||
from cachetools import TTLCache
|
from cachetools import TTLCache
|
||||||
|
|
||||||
@ -255,17 +255,19 @@ def get_more_stuff_from_file(id, result):
|
|||||||
"second__liveNow": is_live(r)
|
"second__liveNow": is_live(r)
|
||||||
} for r in [get_useful_recommendation_data(r) for r in recommendations if get_useful_recommendation_data(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)
|
# m_yt_player_config = re.search(r_yt_player_config, content)
|
||||||
if m_yt_player_config:
|
# if m_yt_player_config:
|
||||||
yt_player_config = json.loads(m_yt_player_config.group(1))
|
# 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"]:
|
player_response = extract_yt_initial_player_response(content)
|
||||||
result["second__providedDashUrl"] = player_response["streamingData"]["dashManifestUrl"]
|
|
||||||
result["liveNow"] = player_response["videoDetails"]["isLiveContent"]
|
|
||||||
|
|
||||||
# result = player_response
|
# result = player_response
|
||||||
# return result
|
# return result
|
||||||
|
|
||||||
|
if "dashManifestUrl" in player_response["streamingData"]:
|
||||||
|
result["second__providedDashUrl"] = player_response["streamingData"]["dashManifestUrl"]
|
||||||
|
result["liveNow"] = player_response["videoDetails"]["isLiveContent"]
|
||||||
|
|
||||||
itagDict = {}
|
itagDict = {}
|
||||||
for f in player_response["streamingData"]["adaptiveFormats"]:
|
for f in player_response["streamingData"]["adaptiveFormats"]:
|
||||||
if "indexRange" in f:
|
if "indexRange" in f:
|
||||||
|
@ -2,6 +2,7 @@ import re
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
r_yt_initial_data = re.compile(r"""(?:^\s*window\["ytInitialData"\]|var ytInitialData) = (\{.+?\});(?:\s*$|</script>)""", re.S + re.M)
|
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):
|
def extract_yt_initial_data(content):
|
||||||
m_yt_initial_data = re.search(r_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
|
return yt_initial_data
|
||||||
else:
|
else:
|
||||||
raise Exception("Could not match ytInitialData in content")
|
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
Block a user