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;
|
public abstract long getStreamCount() throws ParsingException;
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public abstract Description getDescription() throws ParsingException;
|
public abstract Description getDescription() throws ParsingException;
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
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.stream.StreamInfoItem;
|
||||||
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
|
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
|
||||||
|
|
||||||
|
@ -102,6 +103,11 @@ public final class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
info.addError(e);
|
info.addError(e);
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
info.setDescription(extractor.getDescription());
|
||||||
|
} catch (final Exception e) {
|
||||||
|
info.addError(e);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
info.setThumbnailUrl(extractor.getThumbnailUrl());
|
info.setThumbnailUrl(extractor.getThumbnailUrl());
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
|
@ -174,6 +180,7 @@ public final class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
||||||
private String subChannelName;
|
private String subChannelName;
|
||||||
private String subChannelAvatarUrl;
|
private String subChannelAvatarUrl;
|
||||||
private long streamCount = 0;
|
private long streamCount = 0;
|
||||||
|
private Description description;
|
||||||
private PlaylistType playlistType;
|
private PlaylistType playlistType;
|
||||||
|
|
||||||
public String getThumbnailUrl() {
|
public String getThumbnailUrl() {
|
||||||
|
@ -248,6 +255,14 @@ public final class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
||||||
this.streamCount = streamCount;
|
this.streamCount = streamCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Description getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(final Description description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
public PlaylistType getPlaylistType() {
|
public PlaylistType getPlaylistType() {
|
||||||
return playlistType;
|
return playlistType;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,7 @@ public class BandcampPlaylistExtractor extends PlaylistExtractor {
|
||||||
return trackInfo.size();
|
return trackInfo.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Description getDescription() throws ParsingException {
|
public Description getDescription() throws ParsingException {
|
||||||
return Description.EMPTY_DESCRIPTION;
|
return Description.EMPTY_DESCRIPTION;
|
||||||
|
|
|
@ -66,10 +66,15 @@ public class PeertubePlaylistExtractor extends PlaylistExtractor {
|
||||||
return playlistInfo.getLong("videosLength");
|
return playlistInfo.getLong("videosLength");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Description getDescription() throws ParsingException {
|
public Description getDescription() throws ParsingException {
|
||||||
|
final String description = playlistInfo.getString("description");
|
||||||
|
if (isNullOrEmpty(description)) {
|
||||||
return Description.EMPTY_DESCRIPTION;
|
return Description.EMPTY_DESCRIPTION;
|
||||||
}
|
}
|
||||||
|
return new Description(description, Description.PLAIN_TEXT);
|
||||||
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -119,10 +119,15 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor {
|
||||||
return playlist.getLong("track_count");
|
return playlist.getLong("track_count");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Description getDescription() throws ParsingException {
|
public Description getDescription() throws ParsingException {
|
||||||
|
final String description = playlist.getString("description");
|
||||||
|
if (isNullOrEmpty(description)) {
|
||||||
return Description.EMPTY_DESCRIPTION;
|
return Description.EMPTY_DESCRIPTION;
|
||||||
}
|
}
|
||||||
|
return new Description(description, Description.PLAIN_TEXT);
|
||||||
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -170,6 +170,7 @@ public class YoutubeMixPlaylistExtractor extends PlaylistExtractor {
|
||||||
return ListExtractor.ITEM_COUNT_INFINITE;
|
return ListExtractor.ITEM_COUNT_INFINITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Description getDescription() throws ParsingException {
|
public Description getDescription() throws ParsingException {
|
||||||
return Description.EMPTY_DESCRIPTION;
|
return Description.EMPTY_DESCRIPTION;
|
||||||
|
|
|
@ -295,6 +295,7 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor {
|
||||||
return ITEM_COUNT_UNKNOWN;
|
return ITEM_COUNT_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Description getDescription() throws ParsingException {
|
public Description getDescription() throws ParsingException {
|
||||||
final String description = getTextFromObject(
|
final String description = getTextFromObject(
|
||||||
|
|
|
@ -60,6 +60,11 @@ public class PeertubePlaylistExtractorTest {
|
||||||
ExtractorAsserts.assertGreaterOrEqual(39, extractor.getStreamCount());
|
ExtractorAsserts.assertGreaterOrEqual(39, extractor.getStreamCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testGetDescription() throws ParsingException {
|
||||||
|
ExtractorAsserts.assertContains("épisodes de Shocking", extractor.getDescription().getContent());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGetSubChannelUrl() {
|
void testGetSubChannelUrl() {
|
||||||
assertEquals("https://skeptikon.fr/video-channels/metadechoc_channel", extractor.getSubChannelUrl());
|
assertEquals("https://skeptikon.fr/video-channels/metadechoc_channel", extractor.getSubChannelUrl());
|
||||||
|
|
Loading…
Reference in New Issue