Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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;
Expand All @@ -21,6 +22,9 @@ public PlaylistExtractor(final StreamingService service, final ListLinkHandler l

public abstract long getStreamCount() throws ParsingException;

@Nonnull
public abstract Description getDescription() throws ParsingException;
Comment thread
ChunkyProgrammer marked this conversation as resolved.

@Nonnull
public String getThumbnailUrl() throws ParsingException {
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
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 org.schabi.newpipe.extractor.utils.ExtractorHelper;

Expand Down Expand Up @@ -102,6 +103,11 @@ public static PlaylistInfo getInfo(final PlaylistExtractor extractor)
} catch (final Exception e) {
info.addError(e);
}
try {
info.setDescription(extractor.getDescription());
} catch (final Exception e) {
info.addError(e);
}
try {
info.setThumbnailUrl(extractor.getThumbnailUrl());
} catch (final Exception e) {
Expand Down Expand Up @@ -174,6 +180,7 @@ public static PlaylistInfo getInfo(final PlaylistExtractor extractor)
private String subChannelName;
private String subChannelAvatarUrl;
private long streamCount = 0;
private Description description;
private PlaylistType playlistType;

public String getThumbnailUrl() {
Expand Down Expand Up @@ -248,6 +255,14 @@ public void setStreamCount(final long streamCount) {
this.streamCount = streamCount;
}

public Description getDescription() {
return description;
}

public void setDescription(final Description description) {
this.description = description;
}

public PlaylistType getPlaylistType() {
return playlistType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
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;

Expand Down Expand Up @@ -108,6 +109,12 @@ public long getStreamCount() {
return trackInfo.size();
}

@Nonnull
@Override
public Description getDescription() throws ParsingException {
return Description.EMPTY_DESCRIPTION;
}

@Nonnull
@Override
public InfoItemsPage<StreamInfoItem> getInitialPage() throws ExtractionException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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;
Expand Down Expand Up @@ -65,6 +66,16 @@ public long getStreamCount() {
return playlistInfo.getLong("videosLength");
}

@Nonnull
@Override
public Description getDescription() throws ParsingException {
final String description = playlistInfo.getString("description");
if (isNullOrEmpty(description)) {
return Description.EMPTY_DESCRIPTION;
}
return new Description(description, Description.PLAIN_TEXT);
}

@Nonnull
@Override
public String getSubChannelName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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;

Expand Down Expand Up @@ -118,6 +119,16 @@ public long getStreamCount() {
return playlist.getLong("track_count");
}

@Nonnull
@Override
public Description getDescription() throws ParsingException {
final String description = playlist.getString("description");
if (isNullOrEmpty(description)) {
return Description.EMPTY_DESCRIPTION;
}
return new Description(description, Description.PLAIN_TEXT);
}

@Nonnull
@Override
public InfoItemsPage<StreamInfoItem> getInitialPage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
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;
Expand Down Expand Up @@ -169,6 +170,12 @@ public long getStreamCount() {
return ListExtractor.ITEM_COUNT_INFINITE;
}

@Nonnull
@Override
public Description getDescription() throws ParsingException {
return Description.EMPTY_DESCRIPTION;
}

@Nonnull
@Override
public InfoItemsPage<StreamInfoItem> getInitialPage()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
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;
Expand Down Expand Up @@ -294,6 +295,17 @@ public long getStreamCount() throws ParsingException {
return ITEM_COUNT_UNKNOWN;
}

@Nonnull
@Override
public Description getDescription() throws ParsingException {
final String description = getTextFromObject(
getPlaylistInfo().getObject("description"),
true
);

return new Description(description, Description.HTML);
}

@Nonnull
@Override
public InfoItemsPage<StreamInfoItem> getInitialPage() throws IOException, ExtractionException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ void testGetStreamCount() {
ExtractorAsserts.assertGreaterOrEqual(39, extractor.getStreamCount());
}

@Test
void testGetDescription() throws ParsingException {
ExtractorAsserts.assertContains("épisodes de Shocking", extractor.getDescription().getContent());
}

@Test
void testGetSubChannelUrl() {
assertEquals("https://skeptikon.fr/video-channels/metadechoc_channel", extractor.getSubChannelUrl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertContains;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
import static org.schabi.newpipe.extractor.services.DefaultTests.assertNoMoreItems;
Expand All @@ -25,6 +26,7 @@
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;
Expand Down Expand Up @@ -163,6 +165,12 @@ public void testUploaderVerified() throws Exception {
void getPlaylistType() throws ParsingException {
assertEquals(PlaylistInfo.PlaylistType.NORMAL, extractor.getPlaylistType());
}

@Test
public void testDescription() throws ParsingException {
final Description description = extractor.getDescription();
assertContains("pop songs list", description.getContent());
}
}

public static class HugePlaylist implements BasePlaylistExtractorTest {
Expand Down Expand Up @@ -286,6 +294,12 @@ public void testUploaderVerified() throws Exception {
void getPlaylistType() throws ParsingException {
assertEquals(PlaylistInfo.PlaylistType.NORMAL, extractor.getPlaylistType());
}

@Test
public void testDescription() throws ParsingException {
final Description description = extractor.getDescription();
assertContains("I Wanna Rock Super Gigantic Playlist", description.getContent());
}
}

public static class LearningPlaylist implements BasePlaylistExtractorTest {
Expand Down Expand Up @@ -394,6 +408,12 @@ public void testUploaderVerified() throws Exception {
void getPlaylistType() throws ParsingException {
assertEquals(PlaylistInfo.PlaylistType.NORMAL, extractor.getPlaylistType());
}

@Test
public void testDescription() throws ParsingException {
final Description description = extractor.getDescription();
assertContains("47 episodes", description.getContent());
}
}

public static class ContinuationsTests {
Expand Down