Description: rm constructor by serviceId
This commit is contained in:
parent
26c65b2948
commit
70a40e7388
|
@ -49,7 +49,7 @@ public class MediaCCCStreamExtractor extends StreamExtractor {
|
|||
@Nonnull
|
||||
@Override
|
||||
public Description getDescription() throws ParsingException {
|
||||
return new Description(getServiceId(), data.getString("description"));
|
||||
return new Description(data.getString("description"), Description.PLAIN_TEXT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -83,7 +83,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return new Description(getServiceId(), text);
|
||||
return new Description(text, Description.MARKDOWN);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -76,7 +76,7 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
|
|||
|
||||
@Override
|
||||
public Description getDescription() {
|
||||
return new Description(getServiceId(), track.getString("description"));
|
||||
return new Description(track.getString("description"), Description.PLAIN_TEXT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -184,7 +184,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
assertPageFetched();
|
||||
try {
|
||||
// first try to get html-formatted description
|
||||
return new Description(getServiceId(), parseHtmlAndGetFullLinks(doc.select("p[id=\"eow-description\"]").first().html()));
|
||||
return new Description(parseHtmlAndGetFullLinks(doc.select("p[id=\"eow-description\"]").first().html()), Description.HTML);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
// fallback to raw non-html description
|
||||
|
|
|
@ -1,29 +1,17 @@
|
|||
package org.schabi.newpipe.extractor.stream;
|
||||
|
||||
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
public class Description {
|
||||
private String content;
|
||||
private int type;
|
||||
|
||||
public static final int HTML = 1;
|
||||
public static final int MARKDOWN = 2;
|
||||
public static final int PLAIN_TEXT = 3;
|
||||
public static final Description emptyDescription = new Description(PLAIN_TEXT, "");
|
||||
public static final Description emptyDescription = new Description("", PLAIN_TEXT);
|
||||
|
||||
public Description(int serviceID, String content) {
|
||||
if (serviceID == PeerTube.getServiceId()) {
|
||||
this.type = MARKDOWN;
|
||||
} else if (serviceID == YouTube.getServiceId()) {
|
||||
this.type = HTML;
|
||||
} else {
|
||||
this.type = PLAIN_TEXT;
|
||||
}
|
||||
setContent(content);
|
||||
}
|
||||
private String content;
|
||||
private int type;
|
||||
|
||||
private void setContent(String content) {
|
||||
public Description(String content, int type) {
|
||||
this.type = type;
|
||||
if (content == null) {
|
||||
this.content = "";
|
||||
} else {
|
||||
|
@ -31,11 +19,6 @@ public class Description {
|
|||
}
|
||||
}
|
||||
|
||||
public Description(String content, int type) {
|
||||
this.type = type;
|
||||
setContent(content);
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue