[YouTube] Fix frame extraction for livestreams
Use saved playerResponse instead of parsing json every time
This commit is contained in:
parent
7cd410f3fc
commit
072bae321f
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue