From 1414a6f178cf8f2ff1024df80fa00d8f2c85f5f4 Mon Sep 17 00:00:00 2001 From: TiA4f8R <74829229+TiA4f8R@users.noreply.github.com> Date: Wed, 3 Feb 2021 22:07:34 +0100 Subject: [PATCH] Fix extraction of YouTube chapters (#531) YouTube changed the name of the chapters in the JSON from engagement-panel-macro-markers to engagement-panel-macro-markers-description-chapters, so extracting chapters doesn't work. --- .../services/youtube/extractors/YoutubeStreamExtractor.java | 6 ++++-- .../youtube/stream/YoutubeStreamExtractorDefaultTest.java | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java index 291c72d80..0551fc5de 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java @@ -1079,8 +1079,10 @@ public class YoutubeStreamExtractor extends StreamExtractor { // Search for correct panel containing the data for (int i = 0; i < panels.size(); i++) { - if (panels.getObject(i).getObject("engagementPanelSectionListRenderer") - .getString("panelIdentifier").equals("engagement-panel-macro-markers")) { + final String panelIdentifier = panels.getObject(i).getObject("engagementPanelSectionListRenderer") + .getString("panelIdentifier"); + if (panelIdentifier.equals("engagement-panel-macro-markers-description-chapters") + || panelIdentifier.equals("engagement-panel-macro-markers")) { segmentsArray = panels.getObject(i).getObject("engagementPanelSectionListRenderer") .getObject("content").getObject("macroMarkersListRenderer").getArray("contents"); break; diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorDefaultTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorDefaultTest.java index f35f064f2..16bca322b 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorDefaultTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorDefaultTest.java @@ -259,7 +259,6 @@ public class YoutubeStreamExtractorDefaultTest { @Override public int expectedStreamSegmentsCount() { return 7; } @Test - @Ignore("TODO fix") public void testStreamSegment() throws Exception { final StreamSegment segment = extractor.getStreamSegments().get(1); assertEquals(164, segment.getStartTimeSeconds());