Implement PlaylistInfo.getDescription()
Implement PlaylistExtractor.getDescription() for PeerTube and SoundCloud. Anotate PlaylistExtractor.getDescription() as Nonnull
This commit is contained in:
parent
81f29116ba
commit
b218bf69bd
|
@ -22,6 +22,7 @@ public abstract class PlaylistExtractor extends ListExtractor<StreamInfoItem> {
|
|||
|
||||
public abstract long getStreamCount() throws ParsingException;
|
||||
|
||||
@Nonnull
|
||||
public abstract Description getDescription() throws ParsingException;
|
||||
|
||||
@Nonnull
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.schabi.newpipe.extractor.StreamingService;
|
|||
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;
|
||||
|
||||
|
@ -102,6 +103,11 @@ public final class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
|||
} 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) {
|
||||
|
@ -174,6 +180,7 @@ public final class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
|||
private String subChannelName;
|
||||
private String subChannelAvatarUrl;
|
||||
private long streamCount = 0;
|
||||
private Description description;
|
||||
private PlaylistType playlistType;
|
||||
|
||||
public String getThumbnailUrl() {
|
||||
|
@ -248,6 +255,14 @@ public final class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
|||
this.streamCount = streamCount;
|
||||
}
|
||||
|
||||
public Description getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(final Description description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public PlaylistType getPlaylistType() {
|
||||
return playlistType;
|
||||
}
|
||||
|
|
|
@ -109,6 +109,7 @@ public class BandcampPlaylistExtractor extends PlaylistExtractor {
|
|||
return trackInfo.size();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Description getDescription() throws ParsingException {
|
||||
return Description.EMPTY_DESCRIPTION;
|
||||
|
|
|
@ -66,10 +66,15 @@ public class PeertubePlaylistExtractor extends PlaylistExtractor {
|
|||
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
|
||||
|
|
|
@ -119,10 +119,15 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor {
|
|||
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
|
||||
|
|
|
@ -170,6 +170,7 @@ public class YoutubeMixPlaylistExtractor extends PlaylistExtractor {
|
|||
return ListExtractor.ITEM_COUNT_INFINITE;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Description getDescription() throws ParsingException {
|
||||
return Description.EMPTY_DESCRIPTION;
|
||||
|
|
|
@ -295,6 +295,7 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor {
|
|||
return ITEM_COUNT_UNKNOWN;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Description getDescription() throws ParsingException {
|
||||
final String description = getTextFromObject(
|
||||
|
|
|
@ -60,6 +60,11 @@ public class PeertubePlaylistExtractorTest {
|
|||
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());
|
||||
|
|
Loading…
Reference in New Issue