From 93ef73e2f2569b820a7950ff9c94655b6cd65888 Mon Sep 17 00:00:00 2001 From: Stypox Date: Tue, 13 Sep 2022 10:24:39 +0200 Subject: [PATCH] [YouTube] Return mqdefault thumbnails in feed The hqdefault thumbnails, which are used by default, have black bars at the top and at the bottom, and are thus not optimal. --- .../youtube/extractors/YoutubeFeedInfoItemExtractor.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeFeedInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeFeedInfoItemExtractor.java index a79586e8..d5a83d3b 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeFeedInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeFeedInfoItemExtractor.java @@ -91,6 +91,10 @@ public class YoutubeFeedInfoItemExtractor implements StreamInfoItemExtractor { @Override public String getThumbnailUrl() { - return entryElement.getElementsByTag("media:thumbnail").first().attr("url"); + // The hqdefault thumbnail has some black bars at the top and at the bottom, while the + // mqdefault doesn't, so return the mqdefault one. It should always exist, according to + // https://stackoverflow.com/a/20542029/9481500. + return entryElement.getElementsByTag("media:thumbnail").first().attr("url") + .replace("hqdefault", "mqdefault"); } }