Fix YT artist getSubscriberCount extraction

This commit is contained in:
litetex 2025-02-11 21:35:19 +01:00
parent 25e4a6f3cf
commit 4d7df1486c
No known key found for this signature in database
GPG Key ID: 525B43E6039B3689
2 changed files with 8 additions and 5 deletions

View File

@ -1,5 +1,6 @@
package org.schabi.newpipe.extractor.services.youtube.extractors;
import com.grack.nanojson.JsonArray;
import com.grack.nanojson.JsonObject;
import org.schabi.newpipe.extractor.Image;
import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor;
@ -61,10 +62,14 @@ public class YoutubeMusicArtistInfoItemExtractor implements ChannelInfoItemExtra
@Override
public long getSubscriberCount() throws ParsingException {
final String subscriberCount = getTextFromObject(artistInfoItem.getArray("flexColumns")
.getObject(2)
final JsonArray flexColumns = artistInfoItem.getArray("flexColumns");
final JsonArray runs = flexColumns
.getObject(flexColumns.size() - 1)
.getObject("musicResponsiveListItemFlexColumnRenderer")
.getObject("text"));
.getObject("text")
.getArray("runs");
final String subscriberCount = runs.getObject(runs.size() - 1)
.getString("text");
if (!isNullOrEmpty(subscriberCount)) {
try {
return Utils.mixedNumberWordToLong(subscriberCount);

View File

@ -4,7 +4,6 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube;
import static java.util.Collections.singletonList;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.NewPipe;
@ -107,7 +106,6 @@ public class YoutubeMusicSearchExtractorTest {
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.PLAYLIST; }
}
@Disabled
public static class MusicArtists extends DefaultSearchExtractorTest {
private static SearchExtractor extractor;
private static final String QUERY = "kevin";