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());
final List<String> ids = new ArrayList<>();
final JsonArray tracks = playlist.getArray("tracks");
tracks.stream().filter(JsonObject.class::isInstance)
playlist.getArray("tracks")
.stream()
.filter(JsonObject.class::isInstance)
.map(JsonObject.class::cast)
.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(
new SoundcloudStreamInfoItemExtractor(track));
} else {

View File

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

View File

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