[YouTube] Fix frame extraction for livestreams

Use saved playerResponse instead of parsing json every time
This commit is contained in:
Stypox 2020-04-09 15:52:42 +02:00
parent 7cd410f3fc
commit 072bae321f
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
1 changed files with 10 additions and 4 deletions

View File

@ -1006,12 +1006,18 @@ public class YoutubeStreamExtractor extends StreamExtractor {
@Override @Override
public List<Frameset> getFrames() throws ExtractionException { public List<Frameset> getFrames() throws ExtractionException {
try { try {
JsonObject jo = initialAjaxJson.getObject(2).getObject("player"); final JsonObject storyboards = playerResponse.getObject("storyboards");
final String resp = jo.getObject("args").getString("player_response"); final JsonObject storyboardsRenderer;
jo = JsonParser.object().from(resp); if (storyboards.has("playerLiveStoryboardSpecRenderer")) {
final String[] spec = jo.getObject("storyboards").getObject("playerStoryboardSpecRenderer").getString("spec").split("\\|"); storyboardsRenderer = storyboards.getObject("playerLiveStoryboardSpecRenderer");
} else {
storyboardsRenderer = storyboards.getObject("playerStoryboardSpecRenderer");
}
final String[] spec = storyboardsRenderer.getString("spec").split("\\|");
final String url = spec[0]; final String url = spec[0];
final ArrayList<Frameset> result = new ArrayList<>(spec.length - 1); final ArrayList<Frameset> result = new ArrayList<>(spec.length - 1);
for (int i = 1; i < spec.length; ++i) { for (int i = 1; i < spec.length; ++i) {
final String[] parts = spec[i].split("#"); final String[] parts = spec[i].split("#");
if (parts.length != 8) { if (parts.length != 8) {