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 @@ -37,10 +37,37 @@

@Override
public String getUrl() throws ParsingException {
// Primary: playlistItemData.videoId (legacy, may be absent)
final String id = songOrVideoInfoItem.getObject("playlistItemData").getString("videoId");
if (!isNullOrEmpty(id)) {
return "https://music.youtube.com/watch?v=" + id;
}

// Fallback: overlay play button watchEndpoint
final String overlayId = songOrVideoInfoItem.getObject("overlay")
.getObject("musicItemThumbnailOverlayRenderer")
.getObject("content")
.getObject("musicPlayButtonRenderer")
.getObject("playNavigationEndpoint")
.getObject("watchEndpoint")
.getString("videoId");
if (!isNullOrEmpty(overlayId)) {
return "https://music.youtube.com/watch?v=" + overlayId;
}

// Fallback: song title navigationEndpoint
final String flexUrl = getUrlFromNavigationEndpoint(
songOrVideoInfoItem.getArray("flexColumns")

Check failure on line 60 in extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMusicSongOrVideoInfoItemExtractor.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "flexColumns" 3 times.

See more on https://sonarcloud.io/project/issues?id=TeamNewPipe_NewPipeExtractor&issues=AZ6KCHH0cmj5yaW4fpnJ&open=AZ6KCHH0cmj5yaW4fpnJ&pullRequest=1506
.getObject(0)
.getObject("musicResponsiveListItemFlexColumnRenderer")

Check failure on line 62 in extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMusicSongOrVideoInfoItemExtractor.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "musicResponsiveListItemFlexColumnRenderer" 3 times.

See more on https://sonarcloud.io/project/issues?id=TeamNewPipe_NewPipeExtractor&issues=AZ6KCHH0cmj5yaW4fpnH&open=AZ6KCHH0cmj5yaW4fpnH&pullRequest=1506
.getObject("text")
.getArray("runs")
.getObject(0)
.getObject("navigationEndpoint"));

Check failure on line 66 in extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeMusicSongOrVideoInfoItemExtractor.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "navigationEndpoint" 4 times.

See more on https://sonarcloud.io/project/issues?id=TeamNewPipe_NewPipeExtractor&issues=AZ6KCHH0cmj5yaW4fpnI&open=AZ6KCHH0cmj5yaW4fpnI&pullRequest=1506
if (!isNullOrEmpty(flexUrl)) {
return flexUrl;
}

throw new ParsingException("Could not get URL");
}

Expand Down
Loading