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:
parent
d9c777df78
commit
352fae640f
@ -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)) {
|
||||
if (channelId != null && channelId.startsWith("UC")) {
|
||||
return YoutubeChannelLinkHandlerFactory.getInstance().getUrl("channel/" + 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");
|
||||
}
|
||||
return YoutubeChannelLinkHandlerFactory.getInstance().getUrl(channelId);
|
||||
|
||||
private String resolveUploaderUrlFromRelativeUrl(final String url) throws ParsingException {
|
||||
return YoutubeChannelLinkHandlerFactory.getInstance().getUrl("c" + url);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
Loading…
x
Reference in New Issue
Block a user