feat: prettier channel info page
This commit is contained in:
parent
78bbbd405d
commit
9a9fae9a33
|
@ -8,6 +8,7 @@ import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
|||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
|
@ -48,6 +49,11 @@ public abstract class ChannelExtractor extends ListExtractor<StreamInfoItem> {
|
|||
public abstract String getParentChannelAvatarUrl() throws ParsingException;
|
||||
public abstract boolean isVerified() throws ParsingException;
|
||||
@Nonnull
|
||||
public abstract List<ChannelTabHandler> getTabs() throws ParsingException;
|
||||
|
||||
public List<ChannelTabHandler> getTabs() throws ParsingException {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@Nonnull
|
||||
public List<String> getTags() throws ParsingException {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,6 +139,11 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
|||
} catch (final Exception e) {
|
||||
info.addError(e);
|
||||
}
|
||||
try {
|
||||
info.setTags(extractor.getTags());
|
||||
} catch (final Exception e) {
|
||||
info.addError(e);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
@ -156,6 +161,8 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
|||
|
||||
private List<ChannelTabHandler> tabs = Collections.emptyList();
|
||||
|
||||
private List<String> tags = Collections.emptyList();
|
||||
|
||||
public String getParentChannelName() {
|
||||
return parentChannelName;
|
||||
}
|
||||
|
@ -244,4 +251,11 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
|||
public void setTabs(@Nonnull final List<ChannelTabHandler> tabs) {
|
||||
this.tabs = tabs;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public List<String> getTags() { return tags; }
|
||||
|
||||
public void setTags(@Nonnull final List<String> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.ChannelResponseData;
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.DISABLE_PRETTY_PRINT_PARAMETER;
|
||||
|
@ -230,6 +231,15 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
return tabs;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<String> getTags() throws ParsingException {
|
||||
final JsonArray tags = initialData.getObject("microformat")
|
||||
.getObject("microformatDataRenderer").getArray("tags");
|
||||
|
||||
return tags.stream().map(Object::toString).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public InfoItemsPage<StreamInfoItem> getInitialPage() throws IOException, ExtractionException {
|
||||
|
|
Loading…
Reference in New Issue