From 81f29116bad1655873c4eea8020af56ff5cd6516 Mon Sep 17 00:00:00 2001 From: chunky programmer <78101139+ChunkyProgrammer@users.noreply.github.com> Date: Thu, 11 May 2023 00:36:57 -0400 Subject: [PATCH] switch from string to Description object --- .../extractor/playlist/PlaylistExtractor.java | 3 ++- .../extractors/BandcampPlaylistExtractor.java | 5 +++-- .../extractors/PeertubePlaylistExtractor.java | 5 +++-- .../extractors/SoundcloudPlaylistExtractor.java | 5 +++-- .../extractors/YoutubeMixPlaylistExtractor.java | 5 +++-- .../extractors/YoutubePlaylistExtractor.java | 10 ++++++++-- .../youtube/YoutubePlaylistExtractorTest.java | 13 +++++++------ 7 files changed, 29 insertions(+), 17 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java index 25562673a..c60738c91 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java @@ -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 { public abstract long getStreamCount() throws ParsingException; - public abstract String getDescription() throws ParsingException; + public abstract Description getDescription() throws ParsingException; @Nonnull public String getThumbnailUrl() throws ParsingException { diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampPlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampPlaylistExtractor.java index 462a040e8..a99c9c48d 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampPlaylistExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampPlaylistExtractor.java @@ -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 diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubePlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubePlaylistExtractor.java index 6e848a6a9..e20b396fb 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubePlaylistExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubePlaylistExtractor.java @@ -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 diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudPlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudPlaylistExtractor.java index 5ecb71ec7..34469a7cc 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudPlaylistExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudPlaylistExtractor.java @@ -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 diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMixPlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMixPlaylistExtractor.java index 223fcf6c4..5b6b1eeca 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMixPlaylistExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMixPlaylistExtractor.java @@ -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 diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubePlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubePlaylistExtractor.java index 390e637f7..1523fc923 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubePlaylistExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubePlaylistExtractor.java @@ -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 diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java index e23b2f2e6..3be2f8ce5 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java @@ -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()); } }