Skip to content
Open
Show file tree
Hide file tree
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 @@ -174,4 +174,27 @@ public List<Image> getThumbnails() throws ParsingException {
throw new ParsingException("Could not get thumbnails", e);
}
}

@Override
public String getPlaylistUrl() throws ParsingException {
if (searchType.equals(MUSIC_SONGS)) {
for (final Object item : descriptionElements) {
final JsonObject browseEndpoint = ((JsonObject) item)
.getObject("navigationEndpoint")
.getObject("browseEndpoint");

final String type = browseEndpoint
.getObject("browseEndpointContextSupportedConfigs")
.getObject("browseEndpointContextMusicConfig")
.getString("pageType");

if (type != null && type.equals("MUSIC_PAGE_TYPE_ALBUM")) {
return "https://music.youtube.com/browse/"
+ browseEndpoint.getString("browseId");
}
}
}
// handles singles, video, and others which may not belong in playlist
return "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class StreamInfoItem extends InfoItem {
private String uploaderName;
private String shortDescription;
private String textualUploadDate;
private String playlistUrl;
@Nullable
private DateWrapper uploadDate;
private long viewCount = -1;
Expand Down Expand Up @@ -120,6 +121,14 @@ public void setTextualUploadDate(final String textualUploadDate) {
this.textualUploadDate = textualUploadDate;
}

public String getPlaylistUrl() {
return playlistUrl;
}

public void setPlaylistUrl(final String playlistUrl) {
this.playlistUrl = playlistUrl;
}

@Nullable
public DateWrapper getUploadDate() {
return uploadDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,14 @@ default boolean isShortFormContent() throws ParsingException {
default ContentAvailability getContentAvailability() throws ParsingException {
return ContentAvailability.UNKNOWN;
}

/**
* Gets the playlist url of the stream item.
*
* @return the playlist url of the stream item.
* @throws ParsingException if there is an error in the extraction
*/
default String getPlaylistUrl() throws ParsingException {
return "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ public StreamInfoItem extract(final StreamInfoItemExtractor extractor) throws Pa
} catch (final Exception e) {
addError(e);
}
try {
resultItem.setPlaylistUrl(extractor.getPlaylistUrl());
} catch (final Exception e) {
addError(e);
}

return resultItem;
}
Expand Down