fix peertube trending, added most-liked kiosk
This commit is contained in:
parent
6a7680ce17
commit
5115541268
|
@ -145,6 +145,7 @@ public class PeertubeService extends StreamingService {
|
|||
final PeertubeTrendingLinkHandlerFactory h = new PeertubeTrendingLinkHandlerFactory();
|
||||
try {
|
||||
list.addKioskEntry(kioskFactory, h, PeertubeTrendingLinkHandlerFactory.KIOSK_TRENDING);
|
||||
list.addKioskEntry(kioskFactory, h, PeertubeTrendingLinkHandlerFactory.KIOSK_MOST_LIKED);
|
||||
list.addKioskEntry(kioskFactory, h, PeertubeTrendingLinkHandlerFactory.KIOSK_RECENT);
|
||||
list.addKioskEntry(kioskFactory, h, PeertubeTrendingLinkHandlerFactory.KIOSK_LOCAL);
|
||||
list.setDefaultKiosk(PeertubeTrendingLinkHandlerFactory.KIOSK_TRENDING);
|
||||
|
|
|
@ -20,7 +20,7 @@ import com.grack.nanojson.JsonArray;
|
|||
import com.grack.nanojson.JsonObject;
|
||||
import com.grack.nanojson.JsonParser;
|
||||
|
||||
public class PeertubeTrendingExtractor extends KioskExtractor {
|
||||
public class PeertubeTrendingExtractor extends KioskExtractor<StreamInfoItem> {
|
||||
|
||||
private static final String START_KEY = "start";
|
||||
private static final String COUNT_KEY = "count";
|
||||
|
|
|
@ -17,14 +17,16 @@ public class PeertubeTrendingLinkHandlerFactory extends ListLinkHandlerFactory {
|
|||
public static final Map<String, String> KIOSK_MAP;
|
||||
public static final Map<String, String> REVERSE_KIOSK_MAP;
|
||||
public static final String KIOSK_TRENDING = "Trending";
|
||||
public static final String KIOSK_MOST_LIKED = "Most liked";
|
||||
public static final String KIOSK_RECENT = "Recently added";
|
||||
public static final String KIOSK_LOCAL = "Local";
|
||||
|
||||
static {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put(KIOSK_TRENDING, "%s/api/v1/videos?sort=-views");
|
||||
map.put(KIOSK_TRENDING, "%s/api/v1/videos?sort=-trending");
|
||||
map.put(KIOSK_MOST_LIKED, "%s/api/v1/videos?sort=-likes");
|
||||
map.put(KIOSK_RECENT, "%s/api/v1/videos?sort=-publishedAt");
|
||||
map.put(KIOSK_LOCAL, "%s/api/v1/videos?filter=local");
|
||||
map.put(KIOSK_LOCAL, "%s/api/v1/videos?sort=-publishedAt&filter=local");
|
||||
KIOSK_MAP = Collections.unmodifiableMap(map);
|
||||
|
||||
Map<String, String> reverseMap = new HashMap<>();
|
||||
|
@ -55,6 +57,8 @@ public class PeertubeTrendingLinkHandlerFactory extends ListLinkHandlerFactory {
|
|||
url = url.replace(baseUrl, "%s");
|
||||
if (url.contains("/videos/trending")) {
|
||||
return KIOSK_TRENDING;
|
||||
} else if (url.contains("/videos/most-liked")) {
|
||||
return KIOSK_MOST_LIKED;
|
||||
} else if (url.contains("/videos/recently-added")) {
|
||||
return KIOSK_RECENT;
|
||||
} else if (url.contains("/videos/local")) {
|
||||
|
@ -68,6 +72,6 @@ public class PeertubeTrendingLinkHandlerFactory extends ListLinkHandlerFactory {
|
|||
|
||||
@Override
|
||||
public boolean onAcceptUrl(final String url) {
|
||||
return url.contains("/videos?") || url.contains("/videos/trending") || url.contains("/videos/recently-added") || url.contains("/videos/local");
|
||||
return url.contains("/videos?") || url.contains("/videos/trending") || url.contains("/videos/most-liked") || url.contains("/videos/recently-added") || url.contains("/videos/local");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,6 +92,6 @@ public class PeertubeTrendingExtractorTest {
|
|||
|
||||
@Test
|
||||
public void testGetCleanUrl() throws Exception {
|
||||
assertEquals(extractor.getUrl(), "https://peertube.mastodon.host/api/v1/videos?sort=-views");
|
||||
assertEquals(extractor.getUrl(), "https://peertube.mastodon.host/api/v1/videos?sort=-trending");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,15 +29,17 @@ public class PeertubeTrendingLinkHandlerFactoryTest {
|
|||
@Test
|
||||
public void getUrl()
|
||||
throws Exception {
|
||||
assertEquals(LinkHandlerFactory.fromId("Trending").getUrl(), "https://peertube.mastodon.host/api/v1/videos?sort=-views");
|
||||
assertEquals(LinkHandlerFactory.fromId("Trending").getUrl(), "https://peertube.mastodon.host/api/v1/videos?sort=-trending");
|
||||
assertEquals(LinkHandlerFactory.fromId("Most liked").getUrl(), "https://peertube.mastodon.host/api/v1/videos?sort=-likes");
|
||||
assertEquals(LinkHandlerFactory.fromId("Recently added").getUrl(), "https://peertube.mastodon.host/api/v1/videos?sort=-publishedAt");
|
||||
assertEquals(LinkHandlerFactory.fromId("Local").getUrl(), "https://peertube.mastodon.host/api/v1/videos?filter=local");
|
||||
assertEquals(LinkHandlerFactory.fromId("Local").getUrl(), "https://peertube.mastodon.host/api/v1/videos?sort=-publishedAt&filter=local");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getId()
|
||||
throws Exception {
|
||||
assertEquals(LinkHandlerFactory.fromUrl("https://peertube.mastodon.host/videos/trending").getId(), "Trending");
|
||||
assertEquals(LinkHandlerFactory.fromUrl("https://peertube.mastodon.host/videos/most-liked").getId(), "Most liked");
|
||||
assertEquals(LinkHandlerFactory.fromUrl("https://peertube.mastodon.host/videos/recently-added").getId(), "Recently added");
|
||||
assertEquals(LinkHandlerFactory.fromUrl("https://peertube.mastodon.host/videos/local").getId(), "Local");
|
||||
}
|
||||
|
@ -47,6 +49,9 @@ public class PeertubeTrendingLinkHandlerFactoryTest {
|
|||
assertTrue(LinkHandlerFactory.acceptUrl("https://peertube.mastodon.host/videos/trending"));
|
||||
assertTrue(LinkHandlerFactory.acceptUrl("https://peertube.mastodon.host/videos/trending?adsf=fjaj#fhe"));
|
||||
|
||||
assertTrue(LinkHandlerFactory.acceptUrl("https://peertube.mastodon.host/videos/most-liked"));
|
||||
assertTrue(LinkHandlerFactory.acceptUrl("https://peertube.mastodon.host/videos/most-liked?adsf=fjaj#fhe"));
|
||||
|
||||
assertTrue(LinkHandlerFactory.acceptUrl("https://peertube.mastodon.host/videos/recently-added"));
|
||||
assertTrue(LinkHandlerFactory.acceptUrl("https://peertube.mastodon.host/videos/recently-added?adsf=fjaj#fhe"));
|
||||
|
||||
|
|
Loading…
Reference in New Issue