Skip to content
Open
Changes from all 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 @@ -12,6 +12,7 @@
import org.schabi.newpipe.extractor.playlist.PlaylistInfo;
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItemExtractor;
import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper;
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubePlaylistLinkHandlerFactory;

import javax.annotation.Nonnull;

Expand All @@ -33,16 +34,38 @@ public String getName() throws ParsingException {

@Override
public String getUrl() throws ParsingException {
// Mixes and radio renderers expose a ready-to-share "shareUrl"; use it when present.
final String url = mixInfoItem.getString("shareUrl");
if (isNullOrEmpty(url)) {
throw new ParsingException("Could not get url");
if (!isNullOrEmpty(url)) {
return url;
}
return url;
// Regular channel playlists surfaced in channel tabs (e.g. channel-search results)
// carry no "shareUrl" but have a "playlistId". Rebuild the canonical playlist URL
// from it instead of throwing "Could not get url", which used to abort the whole
// item and surface a spurious error snackbar to the user while the other results
// kept loading fine (#2546).
final String playlistId = mixInfoItem.getString("playlistId");
if (!isNullOrEmpty(playlistId)) {
try {
return YoutubePlaylistLinkHandlerFactory.getInstance().getUrl(playlistId);
} catch (final Exception e) {
throw new ParsingException("Could not get url", e);
}
}
throw new ParsingException("Could not get url");
}

@Override
public String getThumbnailUrl() throws ParsingException {
return getThumbnailUrlFromInfoItem(mixInfoItem);
// A thumbnail is optional: some incomplete playlist/mix items surfaced in channel
// tabs (e.g. channel-search results) carry no usable thumbnail. Return null rather
// than throwing, so the item still shows up (with a placeholder) instead of being
// turned into a user-facing error snackbar (#2546).
try {
return getThumbnailUrlFromInfoItem(mixInfoItem);
} catch (final ParsingException e) {
return null;
}
}

@Override
Expand All @@ -56,7 +79,10 @@ public long getStreamCount() throws ParsingException {
final String countString = YoutubeParsingHelper.getTextFromObject(
mixInfoItem.getObject("videoCountShortText"));
if (countString == null) {
throw new ParsingException("Could not extract item count for playlist/mix info item");
// The item count is optional too: some incomplete playlist/mix items have no
// "videoCountShortText". Report "unknown" rather than throwing, so the item is
// still committed instead of bubbling up a spurious error (#2546).
return ListExtractor.ITEM_COUNT_UNKNOWN;
}

try {
Expand Down