From 26bcfcdeaf37e6b7dbdfffd613624e98ea88e2ac Mon Sep 17 00:00:00 2001 From: AudricV <74829229+AudricV@users.noreply.github.com> Date: Wed, 9 Jul 2025 18:05:06 +0200 Subject: [PATCH] [YouTube] Detect members first and members only shorts This fixes view count extraction error for such content, as the view count is replaced by a text describing the availability of the short. Also made YoutubeShortsLockupInfoItemExtractor package private, as it doesn't need to be public. --- .../YoutubeShortsLockupInfoItemExtractor.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeShortsLockupInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeShortsLockupInfoItemExtractor.java index 939d609b6..1293df454 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeShortsLockupInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeShortsLockupInfoItemExtractor.java @@ -33,12 +33,12 @@ import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; * for an extractor for this UI data type. *

*/ -public class YoutubeShortsLockupInfoItemExtractor implements StreamInfoItemExtractor { +class YoutubeShortsLockupInfoItemExtractor implements StreamInfoItemExtractor { @Nonnull private final JsonObject shortsLockupViewModel; - public YoutubeShortsLockupInfoItemExtractor(@Nonnull final JsonObject shortsLockupViewModel) { + YoutubeShortsLockupInfoItemExtractor(@Nonnull final JsonObject shortsLockupViewModel) { this.shortsLockupViewModel = shortsLockupViewModel; } @@ -93,6 +93,12 @@ public class YoutubeShortsLockupInfoItemExtractor implements StreamInfoItemExtra .getObject("secondaryText") .getString("content"); if (!isNullOrEmpty(viewCountText)) { + if (viewCountText.contains("✪")) { + // If secondary text content contains ✪, this short should be a members first or a + // members only one, we can't extract its view count in this case + return -1; + } + // This approach is language dependent if (viewCountText.toLowerCase().contains("no views")) { return 0;