From bf1c7716620e1dbc2b01d29b2f5af601596ac621 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Fri, 4 May 2018 16:11:25 +0200 Subject: [PATCH] fix could not parese metadata despide available error --- .../services/youtube/YoutubeStreamInfoItemExtractor.java | 4 ++++ .../services/youtube/YoutubeTrendingExtractorTest.java | 1 + 2 files changed, 5 insertions(+) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamInfoItemExtractor.java index 7e792c1af..e4146313d 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamInfoItemExtractor.java @@ -135,7 +135,11 @@ public class YoutubeStreamInfoItemExtractor implements StreamInfoItemExtractor { Element meta = item.select("div[class=\"yt-lockup-meta\"]").first(); if (meta == null) return -1; + // This case can happen if google releases a special video + if(meta.select("li").size() < 2) return -1; + input = meta.select("li").get(1).text(); + } catch (IndexOutOfBoundsException e) { throw new ParsingException("Could not parse yt-lockup-meta although available: " + getUrl(), e); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java index ea8312a12..d4599e983 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java @@ -48,6 +48,7 @@ public class YoutubeTrendingExtractorTest { .getKioskList() .getExtractorById("Trending", null); extractor.fetchPage(); + extractor.setContentCountry("de"); } @Test