diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeDescriptionHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeDescriptionHelper.java index 49b94f6e9..33148d7eb 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeDescriptionHelper.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeDescriptionHelper.java @@ -24,13 +24,13 @@ public final class YoutubeDescriptionHelper { private YoutubeDescriptionHelper() { } - public static final String LINK_CLOSE = ""; - public static final String STRIKETHROUGH_OPEN = ""; - public static final String STRIKETHROUGH_CLOSE = ""; - public static final String BOLD_OPEN = ""; - public static final String BOLD_CLOSE = ""; - public static final String ITALIC_OPEN = ""; - public static final String ITALIC_CLOSE = ""; + private static final String LINK_CLOSE = ""; + private static final String STRIKETHROUGH_OPEN = ""; + private static final String STRIKETHROUGH_CLOSE = ""; + private static final String BOLD_OPEN = ""; + private static final String BOLD_CLOSE = ""; + private static final String ITALIC_OPEN = ""; + private static final String ITALIC_CLOSE = ""; // special link chips (e.g. for YT videos, YT channels or social media accounts): // (u00a0) u00a0 u00a0 [/•] u00a0 u00a0 u00a0 @@ -44,30 +44,26 @@ public final class YoutubeDescriptionHelper { @Nonnull final String open; @Nonnull final String close; final int pos; - final boolean isClose; @Nullable final Function transformContent; int openPosInOutput = -1; Run( @Nonnull final String open, @Nonnull final String close, - final int pos, - final boolean isClose + final int pos ) { - this(open, close, pos, isClose, null); + this(open, close, pos, null); } Run( @Nonnull final String open, @Nonnull final String close, final int pos, - final boolean isClose, @Nullable final Function transformContent ) { this.open = open; this.close = close; this.pos = pos; - this.isClose = isClose; this.transformContent = transformContent; } @@ -87,6 +83,7 @@ public final class YoutubeDescriptionHelper { * @param attributedDescription the JSON object of the attributed description * @return the parsed description, in HTML format, as a string */ + @Nullable public static String attributedDescriptionToHtml( @Nullable final JsonObject attributedDescription ) { @@ -243,10 +240,8 @@ public final class YoutubeDescriptionHelper { final String open = ""; final Function transformContent = getTransformContentFun(run); - openers.add(new Run(open, LINK_CLOSE, startIndex, false, - transformContent)); - closers.add(new Run(open, LINK_CLOSE, startIndex + length, true, - transformContent)); + openers.add(new Run(open, LINK_CLOSE, startIndex, transformContent)); + closers.add(new Run(open, LINK_CLOSE, startIndex + length, transformContent)); }); } @@ -297,19 +292,19 @@ public final class YoutubeDescriptionHelper { final int end = start + length; if (run.has("strikethrough")) { - openers.add(new Run(STRIKETHROUGH_OPEN, STRIKETHROUGH_CLOSE, start, false)); - closers.add(new Run(STRIKETHROUGH_OPEN, STRIKETHROUGH_CLOSE, end, true)); + openers.add(new Run(STRIKETHROUGH_OPEN, STRIKETHROUGH_CLOSE, start)); + closers.add(new Run(STRIKETHROUGH_OPEN, STRIKETHROUGH_CLOSE, end)); } if (run.getBoolean("italic", false)) { - openers.add(new Run(ITALIC_OPEN, ITALIC_CLOSE, start, false)); - closers.add(new Run(ITALIC_OPEN, ITALIC_CLOSE, end, true)); + openers.add(new Run(ITALIC_OPEN, ITALIC_CLOSE, start)); + closers.add(new Run(ITALIC_OPEN, ITALIC_CLOSE, end)); } if (run.has("weightLabel") && !"FONT_WEIGHT_NORMAL".equals(run.getString("weightLabel"))) { - openers.add(new Run(BOLD_OPEN, BOLD_CLOSE, start, false)); - closers.add(new Run(BOLD_OPEN, BOLD_CLOSE, end, true)); + openers.add(new Run(BOLD_OPEN, BOLD_CLOSE, start)); + closers.add(new Run(BOLD_OPEN, BOLD_CLOSE, end)); } }); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Description.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Description.java index d55237b25..2641815b1 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Description.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Description.java @@ -3,6 +3,8 @@ package org.schabi.newpipe.extractor.stream; import java.io.Serializable; import java.util.Objects; +import javax.annotation.Nullable; + public class Description implements Serializable { public static final int HTML = 1; @@ -13,7 +15,7 @@ public class Description implements Serializable { private final String content; private final int type; - public Description(final String content, final int type) { + public Description(@Nullable final String content, final int type) { this.type = type; if (content == null) { this.content = "";