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

Fix missing paranthesis in condition and improve null-safety

This commit is contained in:
TobiGr 2025-07-31 11:01:18 +02:00
parent aa70b5a04b
commit 6397b2ec3f

View File

@ -96,7 +96,7 @@ public final class YoutubeChannelHelper {
webPageType = endpoint.getObject("commandMetadata") webPageType = endpoint.getObject("commandMetadata")
.getObject("webCommandMetadata") .getObject("webCommandMetadata")
.getString("webPageType", ""); .getString("webPageType");
urlToResolve = "WEB_PAGE_TYPE_UNKNOWN".equals(webPageType) urlToResolve = "WEB_PAGE_TYPE_UNKNOWN".equals(webPageType)
? endpoint.getObject("urlEndpoint").getString("url") ? endpoint.getObject("urlEndpoint").getString("url")
@ -106,8 +106,8 @@ public final class YoutubeChannelHelper {
final String browseId = endpoint.getObject(BROWSE_ENDPOINT) final String browseId = endpoint.getObject(BROWSE_ENDPOINT)
.getString(BROWSE_ID, ""); .getString(BROWSE_ID, "");
if (webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_BROWSE") if (("WEB_PAGE_TYPE_BROWSE".equalsIgnoreCase(webPageType)
|| webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_CHANNEL") || "WEB_PAGE_TYPE_CHANNEL".equalsIgnoreCase(webPageType))
&& !browseId.isEmpty()) { && !browseId.isEmpty()) {
if (!browseId.startsWith("UC")) { if (!browseId.startsWith("UC")) {
throw new ExtractionException("Redirected id is not pointing to a channel"); throw new ExtractionException("Redirected id is not pointing to a channel");
@ -116,7 +116,7 @@ public final class YoutubeChannelHelper {
return browseId; return browseId;
} }
// Otherwise the code after that will run into an IndexOutOfBoundsException // Otherwise, the code after that will run into an IndexOutOfBoundsException
if (channelId.length < 2) { if (channelId.length < 2) {
throw new ExtractionException("Failed to resolve channelId for " + idOrPath); throw new ExtractionException("Failed to resolve channelId for " + idOrPath);
} }
@ -201,13 +201,13 @@ public final class YoutubeChannelHelper {
final String webPageType = endpoint.getObject("commandMetadata") final String webPageType = endpoint.getObject("commandMetadata")
.getObject("webCommandMetadata") .getObject("webCommandMetadata")
.getString("webPageType", ""); .getString("webPageType");
final String browseId = endpoint.getObject(BROWSE_ENDPOINT) final String browseId = endpoint.getObject(BROWSE_ENDPOINT)
.getString(BROWSE_ID, ""); .getString(BROWSE_ID, "");
if (webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_BROWSE") if (("WEB_PAGE_TYPE_BROWSE".equalsIgnoreCase(webPageType)
|| webPageType.equalsIgnoreCase("WEB_PAGE_TYPE_CHANNEL") || "WEB_PAGE_TYPE_CHANNEL".equalsIgnoreCase(webPageType))
&& !browseId.isEmpty()) { && !browseId.isEmpty()) {
if (!browseId.startsWith("UC")) { if (!browseId.startsWith("UC")) {
throw new ExtractionException("Redirected id is not pointing to a channel"); throw new ExtractionException("Redirected id is not pointing to a channel");