Skip to content

Commit 26bcfcd

Browse files
committed
[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.
1 parent 22f7cd4 commit 26bcfcd

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeShortsLockupInfoItemExtractor.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
* for an extractor for this UI data type.
3434
* </p>
3535
*/
36-
public class YoutubeShortsLockupInfoItemExtractor implements StreamInfoItemExtractor {
36+
class YoutubeShortsLockupInfoItemExtractor implements StreamInfoItemExtractor {
3737

3838
@Nonnull
3939
private final JsonObject shortsLockupViewModel;
4040

41-
public YoutubeShortsLockupInfoItemExtractor(@Nonnull final JsonObject shortsLockupViewModel) {
41+
YoutubeShortsLockupInfoItemExtractor(@Nonnull final JsonObject shortsLockupViewModel) {
4242
this.shortsLockupViewModel = shortsLockupViewModel;
4343
}
4444

@@ -93,6 +93,12 @@ public long getViewCount() throws ParsingException {
9393
.getObject("secondaryText")
9494
.getString("content");
9595
if (!isNullOrEmpty(viewCountText)) {
96+
if (viewCountText.contains("✪")) {
97+
// If secondary text content contains ✪, this short should be a members first or a
98+
// members only one, we can't extract its view count in this case
99+
return -1;
100+
}
101+
96102
// This approach is language dependent
97103
if (viewCountText.toLowerCase().contains("no views")) {
98104
return 0;

0 commit comments

Comments
 (0)