Apply requested changes

This commit is contained in:
TiA4f8R 2022-03-16 20:14:08 +01:00
parent 35e082248e
commit c7757c0994
No known key found for this signature in database
GPG Key ID: E6D3E7F5949450DD
3 changed files with 13 additions and 8 deletions

View File

@ -127,11 +127,13 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor {
new StreamInfoItemsCollector(getServiceId()); new StreamInfoItemsCollector(getServiceId());
final List<String> ids = new ArrayList<>(); final List<String> ids = new ArrayList<>();
final JsonArray tracks = playlist.getArray("tracks"); playlist.getArray("tracks")
tracks.stream().filter(JsonObject.class::isInstance) .stream()
.filter(JsonObject.class::isInstance)
.map(JsonObject.class::cast) .map(JsonObject.class::cast)
.forEachOrdered(track -> { .forEachOrdered(track -> {
if (track.has("title")) { // i.e. if full info is available // i.e. if full info is available
if (track.has("title")) {
streamInfoItemsCollector.commit( streamInfoItemsCollector.commit(
new SoundcloudStreamInfoItemExtractor(track)); new SoundcloudStreamInfoItemExtractor(track));
} else { } else {

View File

@ -224,8 +224,8 @@ public class YoutubeMixPlaylistExtractor extends PlaylistExtractor {
streams.stream() streams.stream()
.filter(JsonObject.class::isInstance) .filter(JsonObject.class::isInstance)
.map(stream -> ((JsonObject) stream) .map(JsonObject.class::cast)
.getObject("playlistPanelVideoRenderer")) .map(stream -> stream.getObject("playlistPanelVideoRenderer"))
.filter(Objects::nonNull) .filter(Objects::nonNull)
.map(streamInfo -> new YoutubeStreamInfoItemExtractor(streamInfo, timeAgoParser)) .map(streamInfo -> new YoutubeStreamInfoItemExtractor(streamInfo, timeAgoParser))
.forEachOrdered(collector::commit); .forEachOrdered(collector::commit);

View File

@ -236,6 +236,7 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor {
.getArray("contents"); .getArray("contents");
final JsonObject videoPlaylistObject = contents.stream() final JsonObject videoPlaylistObject = contents.stream()
.filter(JsonObject.class::isInstance)
.map(JsonObject.class::cast) .map(JsonObject.class::cast)
.map(content -> content.getObject("itemSectionRenderer") .map(content -> content.getObject("itemSectionRenderer")
.getArray("contents") .getArray("contents")
@ -316,9 +317,11 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor {
final TimeAgoParser timeAgoParser = getTimeAgoParser(); final TimeAgoParser timeAgoParser = getTimeAgoParser();
videos.stream() videos.stream()
.filter(video -> ((JsonObject) video).has(PLAYLIST_VIDEO_RENDERER)) .filter(JsonObject.class::isInstance)
.map(video -> new YoutubeStreamInfoItemExtractor(((JsonObject) video) .map(JsonObject.class::cast)
.getObject(PLAYLIST_VIDEO_RENDERER), timeAgoParser) { .filter(video -> video.has(PLAYLIST_VIDEO_RENDERER))
.map(video -> new YoutubeStreamInfoItemExtractor(
video.getObject(PLAYLIST_VIDEO_RENDERER), timeAgoParser) {
@Override @Override
public long getViewCount() { public long getViewCount() {
return -1; return -1;