add extraction for support info and rename getLanguageInfo function
This commit is contained in:
parent
1a15c0e750
commit
74439f692a
|
@ -248,7 +248,7 @@ public class MediaCCCStreamExtractor extends StreamExtractor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getStreamInfoLanguage() throws ParsingException {
|
||||
public String getLanguageInfo() throws ParsingException {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -257,4 +257,10 @@ public class MediaCCCStreamExtractor extends StreamExtractor {
|
|||
public List<String> getTags() throws ParsingException {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getSupportInfo() throws ParsingException {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ import com.grack.nanojson.JsonObject;
|
|||
import com.grack.nanojson.JsonParser;
|
||||
import com.grack.nanojson.JsonParserException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class PeertubeStreamExtractor extends StreamExtractor {
|
||||
|
||||
|
||||
|
@ -251,6 +253,12 @@ public class PeertubeStreamExtractor extends StreamExtractor {
|
|||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getSupportInfo() throws ParsingException {
|
||||
return JsonUtils.getString(json, "support");
|
||||
}
|
||||
|
||||
private String getRelatedStreamsUrl(List<String> tags) throws UnsupportedEncodingException {
|
||||
String url = baseUrl + PeertubeSearchQueryHandlerFactory.SEARCH_ENDPOINT;
|
||||
StringBuilder params = new StringBuilder();
|
||||
|
@ -378,7 +386,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getStreamInfoLanguage() throws ParsingException {
|
||||
public String getLanguageInfo() throws ParsingException {
|
||||
return JsonUtils.getString(json, "language.label");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -276,7 +276,7 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getStreamInfoLanguage() throws ParsingException {
|
||||
public String getLanguageInfo() throws ParsingException {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -285,4 +285,10 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
|
|||
public List<String> getTags() throws ParsingException {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getSupportInfo() throws ParsingException {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1156,7 +1156,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getStreamInfoLanguage() throws ParsingException {
|
||||
public String getLanguageInfo() throws ParsingException {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -1165,4 +1165,10 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
public List<String> getTags() throws ParsingException {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getSupportInfo() throws ParsingException {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -396,7 +396,7 @@ public abstract class StreamExtractor extends Extractor {
|
|||
* @throws ParsingException
|
||||
*/
|
||||
@Nonnull
|
||||
public abstract String getStreamInfoLanguage() throws ParsingException;
|
||||
public abstract String getLanguageInfo() throws ParsingException;
|
||||
|
||||
/**
|
||||
* The list of tags of the stream.
|
||||
|
@ -406,4 +406,16 @@ public abstract class StreamExtractor extends Extractor {
|
|||
*/
|
||||
@Nonnull
|
||||
public abstract List<String> getTags() throws ParsingException;
|
||||
|
||||
/**
|
||||
* The support information of the stream.
|
||||
* see: https://framatube.org/videos/watch/ee408ec8-07cd-4e35-b884-fb681a4b9d37
|
||||
* (support button).
|
||||
* If the support information are not available,
|
||||
* you can simply return an empty String.
|
||||
* @return the support information of the stream or an empty String.
|
||||
* @throws ParsingException
|
||||
*/
|
||||
@Nonnull
|
||||
public abstract String getSupportInfo() throws ParsingException;
|
||||
}
|
||||
|
|
|
@ -292,7 +292,7 @@ public class StreamInfo extends Info {
|
|||
streamInfo.addError(e);
|
||||
}
|
||||
try {
|
||||
streamInfo.setLanguage(extractor.getStreamInfoLanguage());
|
||||
streamInfo.setLanguageInfo(extractor.getLanguageInfo());
|
||||
} catch (Exception e) {
|
||||
streamInfo.addError(e);
|
||||
}
|
||||
|
@ -301,6 +301,11 @@ public class StreamInfo extends Info {
|
|||
} catch (Exception e) {
|
||||
streamInfo.addError(e);
|
||||
}
|
||||
try {
|
||||
streamInfo.setSupportInfo(extractor.getSupportInfo());
|
||||
} catch (Exception e) {
|
||||
streamInfo.addError(e);
|
||||
}
|
||||
|
||||
streamInfo.setRelatedStreams(ExtractorHelper.getRelatedVideosOrLogError(streamInfo, extractor));
|
||||
|
||||
|
@ -345,6 +350,7 @@ public class StreamInfo extends Info {
|
|||
private String category = "";
|
||||
private String licence = "";
|
||||
private String language = "";
|
||||
private String support = "";
|
||||
private List<String> tags = new ArrayList<>();
|
||||
|
||||
/**
|
||||
|
@ -604,11 +610,11 @@ public class StreamInfo extends Info {
|
|||
this.licence = str;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
public String getLanguageInfo() {
|
||||
return this.language;
|
||||
}
|
||||
|
||||
public void setLanguage(String lang) {
|
||||
public void setLanguageInfo(String lang) {
|
||||
this.language = lang;
|
||||
}
|
||||
|
||||
|
@ -620,5 +626,11 @@ public class StreamInfo extends Info {
|
|||
this.tags = tags;
|
||||
}
|
||||
|
||||
public void setSupportInfo(String support) {
|
||||
this.support = support;
|
||||
}
|
||||
|
||||
public String getSupportInfo() {
|
||||
return this.support;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,4 +147,11 @@ public class PeertubeStreamExtractorDefaultTest {
|
|||
ageLimit.fetchPage();
|
||||
assertEquals(18, ageLimit.getAgeLimit());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSupportInformation() throws ExtractionException, IOException {
|
||||
PeertubeStreamExtractor supportInfoExtractor = (PeertubeStreamExtractor) PeerTube.getStreamExtractor("https://framatube.org/videos/watch/ee408ec8-07cd-4e35-b884-fb681a4b9d37");
|
||||
supportInfoExtractor.fetchPage();
|
||||
assertEquals("https://utip.io/chatsceptique", supportInfoExtractor.getSupportInfo());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue