switch from string to Description object

This commit is contained in:
chunky programmer 2023-05-11 00:36:57 -04:00
parent e147867d41
commit 81f29116ba
7 changed files with 29 additions and 17 deletions

View File

@ -4,6 +4,7 @@ import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import org.schabi.newpipe.extractor.stream.Description;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import javax.annotation.Nonnull;
@ -21,7 +22,7 @@ public abstract class PlaylistExtractor extends ListExtractor<StreamInfoItem> {
public abstract long getStreamCount() throws ParsingException;
public abstract String getDescription() throws ParsingException;
public abstract Description getDescription() throws ParsingException;
@Nonnull
public String getThumbnailUrl() throws ParsingException {

View File

@ -20,6 +20,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
import org.schabi.newpipe.extractor.services.bandcamp.extractors.streaminfoitem.BandcampPlaylistStreamInfoItemExtractor;
import org.schabi.newpipe.extractor.stream.Description;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
@ -109,8 +110,8 @@ public class BandcampPlaylistExtractor extends PlaylistExtractor {
}
@Override
public String getDescription() throws ParsingException {
return "";
public Description getDescription() throws ParsingException {
return Description.EMPTY_DESCRIPTION;
}
@Nonnull

View File

@ -12,6 +12,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
import org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper;
import org.schabi.newpipe.extractor.stream.Description;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
import org.schabi.newpipe.extractor.utils.Utils;
@ -66,8 +67,8 @@ public class PeertubePlaylistExtractor extends PlaylistExtractor {
}
@Override
public String getDescription() throws ParsingException {
return "";
public Description getDescription() throws ParsingException {
return Description.EMPTY_DESCRIPTION;
}
@Nonnull

View File

@ -13,6 +13,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper;
import org.schabi.newpipe.extractor.stream.Description;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
@ -119,8 +120,8 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor {
}
@Override
public String getDescription() throws ParsingException {
return "";
public Description getDescription() throws ParsingException {
return Description.EMPTY_DESCRIPTION;
}
@Nonnull

View File

@ -31,6 +31,7 @@ import org.schabi.newpipe.extractor.localization.TimeAgoParser;
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
import org.schabi.newpipe.extractor.playlist.PlaylistInfo;
import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper;
import org.schabi.newpipe.extractor.stream.Description;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
import org.schabi.newpipe.extractor.utils.JsonUtils;
@ -170,8 +171,8 @@ public class YoutubeMixPlaylistExtractor extends PlaylistExtractor {
}
@Override
public String getDescription() throws ParsingException {
return "";
public Description getDescription() throws ParsingException {
return Description.EMPTY_DESCRIPTION;
}
@Nonnull

View File

@ -26,6 +26,7 @@ import org.schabi.newpipe.extractor.localization.TimeAgoParser;
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
import org.schabi.newpipe.extractor.playlist.PlaylistInfo;
import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper;
import org.schabi.newpipe.extractor.stream.Description;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
import org.schabi.newpipe.extractor.utils.Utils;
@ -295,8 +296,13 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor {
}
@Override
public String getDescription() throws ParsingException {
return getTextFromObject(getPlaylistInfo().getObject("description"));
public Description getDescription() throws ParsingException {
final String description = getTextFromObject(
getPlaylistInfo().getObject("description"),
true
);
return new Description(description, Description.HTML);
}
@Nonnull

View File

@ -26,6 +26,7 @@ import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
import org.schabi.newpipe.extractor.playlist.PlaylistInfo;
import org.schabi.newpipe.extractor.services.BasePlaylistExtractorTest;
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubePlaylistExtractor;
import org.schabi.newpipe.extractor.stream.Description;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import java.io.IOException;
@ -167,8 +168,8 @@ public class YoutubePlaylistExtractorTest {
@Test
public void testDescription() throws ParsingException {
final String description = extractor.getDescription();
assertContains("pop songs list", description);
final Description description = extractor.getDescription();
assertContains("pop songs list", description.getContent());
}
}
@ -296,8 +297,8 @@ public class YoutubePlaylistExtractorTest {
@Test
public void testDescription() throws ParsingException {
final String description = extractor.getDescription();
assertContains("I Wanna Rock Super Gigantic Playlist", description);
final Description description = extractor.getDescription();
assertContains("I Wanna Rock Super Gigantic Playlist", description.getContent());
}
}
@ -410,8 +411,8 @@ public class YoutubePlaylistExtractorTest {
@Test
public void testDescription() throws ParsingException {
final String description = extractor.getDescription();
assertContains("47 episodes", description);
final Description description = extractor.getDescription();
assertContains("47 episodes", description.getContent());
}
}