File tree Expand file tree Collapse file tree
extractor/src/main/java/org/schabi/newpipe/extractor
services/youtube/extractors Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -308,11 +308,11 @@ public final LinkType getLinkTypeByUrl(String url) throws ParsingException {
308308 LinkHandlerFactory cH = getChannelLHFactory ();
309309 LinkHandlerFactory pH = getPlaylistLHFactory ();
310310
311- if (sH .acceptUrl (url )) {
311+ if (sH != null && sH .acceptUrl (url )) {
312312 return LinkType .STREAM ;
313- } else if (cH .acceptUrl (url )) {
313+ } else if (cH != null && cH .acceptUrl (url )) {
314314 return LinkType .CHANNEL ;
315- } else if (pH .acceptUrl (url )) {
315+ } else if (pH != null && pH .acceptUrl (url )) {
316316 return LinkType .PLAYLIST ;
317317 } else {
318318 return LinkType .NONE ;
Original file line number Diff line number Diff line change 33import org .schabi .newpipe .extractor .comments .CommentsInfoItemExtractor ;
44import org .schabi .newpipe .extractor .exceptions .ParsingException ;
55import org .schabi .newpipe .extractor .utils .JsonUtils ;
6+ import org .schabi .newpipe .extractor .utils .Utils ;
67
78import com .grack .nanojson .JsonArray ;
89import com .grack .nanojson .JsonObject ;
@@ -62,7 +63,9 @@ public Integer getLikeCount() throws ParsingException {
6263 @ Override
6364 public String getCommentText () throws ParsingException {
6465 try {
65- return YoutubeCommentsExtractor .getYoutubeText (JsonUtils .getObject (json , "contentText" ));
66+ String commentText = YoutubeCommentsExtractor .getYoutubeText (JsonUtils .getObject (json , "contentText" ));
67+ // youtube adds U+FEFF in some comments. eg. https://www.youtube.com/watch?v=Nj4F63E59io<feff>
68+ return Utils .removeUTF8BOM (commentText );
6669 } catch (Exception e ) {
6770 throw new ParsingException ("Could not get comment text" , e );
6871 }
Original file line number Diff line number Diff line change 11package org .schabi .newpipe .extractor .utils ;
22
3- import org .schabi .newpipe .extractor .exceptions .ParsingException ;
4-
53import java .io .UnsupportedEncodingException ;
64import java .net .MalformedURLException ;
75import java .net .URL ;
86import java .net .URLDecoder ;
97import java .util .List ;
108
9+ import org .schabi .newpipe .extractor .exceptions .ParsingException ;
10+
1111public class Utils {
1212
1313 private Utils () {
@@ -133,4 +133,14 @@ public static boolean isHTTP(URL url) {
133133
134134 return setsNoPort || usesDefaultPort ;
135135 }
136+
137+ public static String removeUTF8BOM (String s ) {
138+ if (s .startsWith ("\uFEFF " )) {
139+ s = s .substring (1 );
140+ }
141+ if (s .endsWith ("\uFEFF " )) {
142+ s = s .substring (0 , s .length ()-1 );
143+ }
144+ return s ;
145+ }
136146}
You can’t perform that action at this time.
0 commit comments