|
8 | 8 | import org.schabi.newpipe.extractor.search.filter.FilterGroup; |
9 | 9 | import org.schabi.newpipe.extractor.search.filter.FilterItem; |
10 | 10 | import org.schabi.newpipe.extractor.search.filter.LibraryStringIds; |
| 11 | +import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeSearchQueryHandlerFactory; |
11 | 12 |
|
12 | 13 | import java.time.LocalDateTime; |
13 | 14 | import java.time.format.DateTimeFormatter; |
@@ -224,18 +225,23 @@ protected void init() { |
224 | 225 |
|
225 | 226 |
|
226 | 227 | /* content filters */ |
227 | | - groupsFactory.addFilterItem(new PeertubeFilterItem( |
| 228 | + groupsFactory.addFilterItem(new PeertubeContentFilterItem( |
228 | 229 | ID_CF_MAIN_ALL, |
229 | | - LibraryStringIds.SEARCH_FILTERS_ALL, "")); |
230 | | - groupsFactory.addFilterItem(new PeertubeFilterItem( |
| 230 | + LibraryStringIds.SEARCH_FILTERS_ALL, "", |
| 231 | + // for 'ALL' we default to videos as all (videos/channels/playlist) is not possible |
| 232 | + PeertubeSearchQueryHandlerFactory.SEARCH_ENDPOINT_VIDEOS)); |
| 233 | + groupsFactory.addFilterItem(new PeertubeContentFilterItem( |
231 | 234 | ID_CF_MAIN_VIDEOS, |
232 | | - LibraryStringIds.SEARCH_FILTERS_VIDEOS, "resultType=videos")); |
233 | | - groupsFactory.addFilterItem(new PeertubeFilterItem( |
| 235 | + LibraryStringIds.SEARCH_FILTERS_VIDEOS, "resultType=videos", |
| 236 | + PeertubeSearchQueryHandlerFactory.SEARCH_ENDPOINT_VIDEOS)); |
| 237 | + groupsFactory.addFilterItem(new PeertubeContentFilterItem( |
234 | 238 | ID_CF_MAIN_CHANNELS, |
235 | | - LibraryStringIds.SEARCH_FILTERS_CHANNELS, "resultType=channels")); |
236 | | - groupsFactory.addFilterItem(new PeertubeFilterItem( |
| 239 | + LibraryStringIds.SEARCH_FILTERS_CHANNELS, "resultType=channels", |
| 240 | + PeertubeSearchQueryHandlerFactory.SEARCH_ENDPOINT_CHANNELS)); |
| 241 | + groupsFactory.addFilterItem(new PeertubeContentFilterItem( |
237 | 242 | ID_CF_MAIN_PLAYLISTS, |
238 | | - LibraryStringIds.SEARCH_FILTERS_PLAYLISTS, "resultType=playlists")); |
| 243 | + LibraryStringIds.SEARCH_FILTERS_PLAYLISTS, "resultType=playlists", |
| 244 | + PeertubeSearchQueryHandlerFactory.SEARCH_ENDPOINT_PLAYLISTS)); |
239 | 245 |
|
240 | 246 |
|
241 | 247 | /* content filter groups */ |
@@ -286,6 +292,23 @@ public String getQueryData() { |
286 | 292 | } |
287 | 293 | } |
288 | 294 |
|
| 295 | + public static class PeertubeContentFilterItem extends PeertubeFilterItem { |
| 296 | + |
| 297 | + private final String endpoint; |
| 298 | + |
| 299 | + PeertubeContentFilterItem(final int identifier, |
| 300 | + @Nonnull final LibraryStringIds nameId, |
| 301 | + @Nullable final String query, |
| 302 | + @Nonnull final String endpoint) { |
| 303 | + super(identifier, nameId, query); |
| 304 | + this.endpoint = endpoint; |
| 305 | + } |
| 306 | + |
| 307 | + public String getEndpoint() { |
| 308 | + return endpoint; |
| 309 | + } |
| 310 | + } |
| 311 | + |
289 | 312 | static class PeertubePublishedDateFilterItem extends PeertubeFilterItem { |
290 | 313 | static final int NO_DAYS_SET = -1; |
291 | 314 | private final int days; |
|
0 commit comments