Add parent channel info to ChannelExtractor: name, url & avatar url
This commit is contained in:
parent
665c69b530
commit
4234740baa
|
@ -37,4 +37,7 @@ 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;
|
||||
public abstract String getParentChannelName() throws ParsingException;
|
||||
public abstract String getParentChannelUrl() throws ParsingException;
|
||||
public abstract String getParentChannelAvatarUrl() throws ParsingException;
|
||||
}
|
||||
|
|
|
@ -94,16 +94,61 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
|||
info.addError(e);
|
||||
}
|
||||
|
||||
try {
|
||||
info.setParentChannelName(extractor.getParentChannelName());
|
||||
} catch (Exception e) {
|
||||
info.addError(e);
|
||||
}
|
||||
|
||||
try {
|
||||
info.setParentChannelUrl(extractor.getParentChannelUrl());
|
||||
} catch (Exception e) {
|
||||
info.addError(e);
|
||||
}
|
||||
|
||||
try {
|
||||
info.setParentChannelAvatarUrl(extractor.getParentChannelAvatarUrl());
|
||||
} catch (Exception e) {
|
||||
info.addError(e);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
private String avatarUrl;
|
||||
private String parentChannelName;
|
||||
private String parentChannelUrl;
|
||||
private String parentChannelAvatarUrl;
|
||||
private String bannerUrl;
|
||||
private String feedUrl;
|
||||
private long subscriberCount = -1;
|
||||
private String description;
|
||||
private String[] donationLinks;
|
||||
|
||||
public String getParentChannelName() {
|
||||
return parentChannelName;
|
||||
}
|
||||
|
||||
public void setParentChannelName(String parentChannelName) {
|
||||
this.parentChannelName = parentChannelName;
|
||||
}
|
||||
|
||||
public String getParentChannelUrl() {
|
||||
return parentChannelUrl;
|
||||
}
|
||||
|
||||
public void setParentChannelUrl(String parentChannelUrl) {
|
||||
this.parentChannelUrl = parentChannelUrl;
|
||||
}
|
||||
|
||||
public String getParentChannelAvatarUrl() {
|
||||
return parentChannelAvatarUrl;
|
||||
}
|
||||
|
||||
public void setParentChannelAvatarUrl(String parentChannelAvatarUrl) {
|
||||
this.parentChannelAvatarUrl = parentChannelAvatarUrl;
|
||||
}
|
||||
|
||||
public String getAvatarUrl() {
|
||||
return avatarUrl;
|
||||
}
|
||||
|
|
|
@ -52,6 +52,21 @@ public class MediaCCCConferenceExtractor extends ChannelExtractor {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentChannelName() throws ParsingException {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentChannelUrl() throws ParsingException {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentChannelAvatarUrl() throws ParsingException {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public InfoItemsPage<StreamInfoItem> getInitialPage() {
|
||||
|
|
|
@ -75,6 +75,27 @@ public class PeertubeChannelExtractor extends ChannelExtractor {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentChannelName() throws ParsingException {
|
||||
return JsonUtils.getString(json, "ownerAccount.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentChannelUrl() throws ParsingException {
|
||||
return JsonUtils.getString(json, "ownerAccount.url");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentChannelAvatarUrl() throws ParsingException {
|
||||
String value;
|
||||
try {
|
||||
value = JsonUtils.getString(json, "ownerAccount.avatar.path");
|
||||
} catch (Exception e) {
|
||||
value = "/client/assets/images/default-avatar.png";
|
||||
}
|
||||
return baseUrl + value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InfoItemsPage<StreamInfoItem> getInitialPage() throws IOException, ExtractionException {
|
||||
super.fetchPage();
|
||||
|
|
|
@ -83,6 +83,21 @@ public class SoundcloudChannelExtractor extends ChannelExtractor {
|
|||
return user.getString("description", EMPTY_STRING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentChannelName() throws ParsingException {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentChannelUrl() throws ParsingException {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentChannelAvatarUrl() throws ParsingException {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public InfoItemsPage<StreamInfoItem> getInitialPage() throws ExtractionException {
|
||||
|
|
|
@ -212,6 +212,21 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentChannelName() throws ParsingException {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentChannelUrl() throws ParsingException {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentChannelAvatarUrl() throws ParsingException {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public InfoItemsPage<StreamInfoItem> getInitialPage() throws ExtractionException {
|
||||
|
|
|
@ -84,6 +84,16 @@ public class PeertubeChannelExtractorTest {
|
|||
assertNotNull(extractor.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParentChannelName() throws ParsingException {
|
||||
assertEquals("libux", extractor.getParentChannelName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParentChannelUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/accounts/libux", extractor.getParentChannelUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAvatarUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getAvatarUrl());
|
||||
|
@ -181,6 +191,16 @@ public class PeertubeChannelExtractorTest {
|
|||
assertNotNull(extractor.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParentChannelName() throws ParsingException {
|
||||
assertEquals("booteille", extractor.getParentChannelName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParentChannelUrl() throws ParsingException {
|
||||
assertEquals("https://peertube.mastodon.host/accounts/booteille", extractor.getParentChannelUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAvatarUrl() throws ParsingException {
|
||||
assertIsSecureUrl(extractor.getAvatarUrl());
|
||||
|
|
Loading…
Reference in New Issue