method obtainErrorMessage for abstract class ChannelExtractor
This commit is contained in:
parent
2b1e4d9142
commit
8aa0f1f174
|
@ -6,6 +6,8 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/*
|
||||
* Created by Christian Schabesberger on 25.07.16.
|
||||
*
|
||||
|
@ -37,4 +39,8 @@ public abstract class ChannelExtractor extends ListExtractor<StreamInfoItem> {
|
|||
public abstract String getFeedUrl() throws ParsingException;
|
||||
public abstract long getSubscriberCount() throws ParsingException;
|
||||
public abstract String getDescription() throws ParsingException;
|
||||
@Nullable
|
||||
public String obtainErrorMessage() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import org.schabi.newpipe.extractor.StreamingService;
|
|||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
|
||||
|
||||
|
@ -67,13 +66,9 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
|||
extractor.getLinkHandler(),
|
||||
"");
|
||||
Throwable nameFailure;
|
||||
if (extractor instanceof YoutubeChannelExtractor) {
|
||||
String errorMessage = ((YoutubeChannelExtractor) extractor).getYoutubeError();
|
||||
if (errorMessage != null) {
|
||||
nameFailure = new ParsingException(errorMessage);
|
||||
} else {
|
||||
nameFailure = e;
|
||||
}
|
||||
String errorMessage = extractor.obtainErrorMessage();
|
||||
if (errorMessage != null) {
|
||||
nameFailure = new ParsingException(errorMessage);
|
||||
} else {
|
||||
nameFailure = e;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.schabi.newpipe.extractor.utils.Utils;
|
|||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/*
|
||||
* Created by Christian Schabesberger on 25.07.16.
|
||||
|
@ -169,12 +168,12 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
* Youtube might show a red warning text for example
|
||||
* "This account has been terminated due to multiple or severe violations of
|
||||
* YouTube's policy prohibiting hate speech."
|
||||
* In that case parsing of the channel informations will fail. This error text should
|
||||
* In that case parsing of the channel information will fail. This error text should
|
||||
* be displayed to the user instead of a cryptic ParsingException.
|
||||
* @return the text as String or null if no warning text could be found
|
||||
*/
|
||||
@Nullable
|
||||
public String getYoutubeError() {
|
||||
@Override
|
||||
public String obtainErrorMessage() {
|
||||
try {
|
||||
return doc.select("div.yt-alert-message").first().text();
|
||||
} catch (Exception e) {
|
||||
|
|
Loading…
Reference in New Issue