Merge branch 'master' into invidious-support
This commit is contained in:
commit
c255fdcdf7
|
@ -308,11 +308,11 @@ public abstract class StreamingService {
|
||||||
LinkHandlerFactory cH = getChannelLHFactory();
|
LinkHandlerFactory cH = getChannelLHFactory();
|
||||||
LinkHandlerFactory pH = getPlaylistLHFactory();
|
LinkHandlerFactory pH = getPlaylistLHFactory();
|
||||||
|
|
||||||
if (sH.acceptUrl(url)) {
|
if (sH != null && sH.acceptUrl(url)) {
|
||||||
return LinkType.STREAM;
|
return LinkType.STREAM;
|
||||||
} else if (cH.acceptUrl(url)) {
|
} else if (cH != null && cH.acceptUrl(url)) {
|
||||||
return LinkType.CHANNEL;
|
return LinkType.CHANNEL;
|
||||||
} else if (pH.acceptUrl(url)) {
|
} else if (pH != null && pH.acceptUrl(url)) {
|
||||||
return LinkType.PLAYLIST;
|
return LinkType.PLAYLIST;
|
||||||
} else {
|
} else {
|
||||||
return LinkType.NONE;
|
return LinkType.NONE;
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.schabi.newpipe.extractor.services.youtube.extractors;
|
||||||
import org.schabi.newpipe.extractor.comments.CommentsInfoItemExtractor;
|
import org.schabi.newpipe.extractor.comments.CommentsInfoItemExtractor;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.utils.JsonUtils;
|
import org.schabi.newpipe.extractor.utils.JsonUtils;
|
||||||
|
import org.schabi.newpipe.extractor.utils.Utils;
|
||||||
|
|
||||||
import com.grack.nanojson.JsonArray;
|
import com.grack.nanojson.JsonArray;
|
||||||
import com.grack.nanojson.JsonObject;
|
import com.grack.nanojson.JsonObject;
|
||||||
|
@ -62,7 +63,9 @@ public class YoutubeCommentsInfoItemExtractor implements CommentsInfoItemExtract
|
||||||
@Override
|
@Override
|
||||||
public String getCommentText() throws ParsingException {
|
public String getCommentText() throws ParsingException {
|
||||||
try {
|
try {
|
||||||
return YoutubeCommentsExtractor.getYoutubeText(JsonUtils.getObject(json, "contentText"));
|
String commentText = YoutubeCommentsExtractor.getYoutubeText(JsonUtils.getObject(json, "contentText"));
|
||||||
|
// youtube adds U+FEFF in some comments. eg. https://www.youtube.com/watch?v=Nj4F63E59io<feff>
|
||||||
|
return Utils.removeUTF8BOM(commentText);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ParsingException("Could not get comment text", e);
|
throw new ParsingException("Could not get comment text", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package org.schabi.newpipe.extractor.utils;
|
package org.schabi.newpipe.extractor.utils;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
private Utils() {
|
private Utils() {
|
||||||
|
@ -133,4 +133,14 @@ public class Utils {
|
||||||
|
|
||||||
return setsNoPort || usesDefaultPort;
|
return setsNoPort || usesDefaultPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String removeUTF8BOM(String s) {
|
||||||
|
if (s.startsWith("\uFEFF")) {
|
||||||
|
s = s.substring(1);
|
||||||
|
}
|
||||||
|
if (s.endsWith("\uFEFF")) {
|
||||||
|
s = s.substring(0, s.length()-1);
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue