2
0
mirror of https://github.com/TeamNewPipe/NewPipeExtractor synced 2025-08-22 09:57:38 +00:00

[YouTube] Correctly set uploaderUrl for lockup content type items

Fixes an issue, where the uploader URL for related items would be incorrect,
due to the `YoutubeChannelLinkHandlerFactory.getUrl` expecting the id with a
`channel/` prefix. However, the `browseId` used to extract the channel id is
missing this prefix.

Ref: https://github.com/TeamNewPipe/NewPipeExtractor/pull/1320

Fix getUploaderUrl not resolving correct url
This commit is contained in:
FineFindus 2025-07-26 10:43:47 +02:00 committed by litetex
parent d9c777df78
commit 352fae640f
No known key found for this signature in database
GPG Key ID: 525B43E6039B3689

View File

@ -179,19 +179,38 @@ public class YoutubeStreamInfoItemLockupExtractor implements StreamInfoItemExtra
@Override
public String getUploaderUrl() throws ParsingException {
final String channelId = channelImageViewModel()
final JsonObject innerTubeCommand = channelImageViewModel()
.forUploaderUrlExtraction()
.getObject("rendererContext")
.getObject("commandContext")
.getObject("onTap")
.getObject("innertubeCommand")
.getObject("browseEndpoint")
.getObject("innertubeCommand");
final JsonObject browseEndpoint = innerTubeCommand
.getObject("browseEndpoint");
final String channelId = browseEndpoint
.getString("browseId");
if (isNullOrEmpty(channelId)) {
throw new ParsingException("Could not get uploader url");
if (channelId != null && channelId.startsWith("UC")) {
return YoutubeChannelLinkHandlerFactory.getInstance().getUrl("channel/" + channelId);
}
return YoutubeChannelLinkHandlerFactory.getInstance().getUrl(channelId);
final String canonicalBaseUrl = browseEndpoint.getString("canonicalBaseUrl");
if (!isNullOrEmpty(canonicalBaseUrl)) {
return resolveUploaderUrlFromRelativeUrl(canonicalBaseUrl);
}
final String webCommandMetadataUrl = innerTubeCommand.getObject("commandMetadata")
.getObject("webCommandMetadata")
.getString("url");
if (!isNullOrEmpty(webCommandMetadataUrl)) {
return resolveUploaderUrlFromRelativeUrl(webCommandMetadataUrl);
}
throw new ParsingException("Could not get uploader url");
}
private String resolveUploaderUrlFromRelativeUrl(final String url) throws ParsingException {
return YoutubeChannelLinkHandlerFactory.getInstance().getUrl("c" + url);
}
@Nonnull