-
Notifications
You must be signed in to change notification settings - Fork 417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework content and sort filter framework #904
base: dev
Are you sure you want to change the base?
Rework content and sort filter framework #904
Conversation
Holy shit it's happening |
I like the approach of using proto files with wire! Any reason why these classes are in git and not auto-generated, perhaps with a gradle plugin? See: https://github.com/square/wire/blob/master/wire-library/docs/wire_compiler.md |
They are not in git. They will be auto-generated by the wire gradle plugin. Why do you think they are? |
I'm having a look at the |
Am 26. August 2022 06:32:22 MESZ schrieb Kavin ***@***.***>:
I'm having a look at the `Filter`, `FilterGroup`, `FilterItem`,
`SearchFiltersBase`, etc classes. They look auto-generated to me, are
they not?
Nope as only YouTube uses proto buffer for their parameter. The classes you mentioned are for describing the sort and content filters within each service. They abstract the differences. I'll convert Filter* to interfaces as they are.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good for the most part, I just had a look at the general changes and YouTube-specific changes.
The code currently fails checkstyle, which is why tests cannot currently be run. Two tests appear to be commented out, but that's a minor issue and can be fixed easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for implementing this long awaited feature.
I briefly skimmed over the most important code changes.
I noticed that there are no tests for the newly added classes and methods yet.
I've added singletons for some *QueryHandlerFactory as we rely now on the same object sets during a search. Was there a good reason to always recreate those objects?
IIRC some of the link handlers were not stateless in the beginning. But I think they are stateless now. So converting those into singletons should be fine.
extractor/src/main/java/org/schabi/newpipe/extractor/search/filter/SearchFiltersBase.java
Outdated
Show resolved
Hide resolved
...est/java/org/schabi/newpipe/extractor/services/soundcloud/search/SoundcloudSearchQHTest.java
Outdated
Show resolved
Hide resolved
.../src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchQHTest.java
Outdated
Show resolved
Hide resolved
extractor/src/main/java/org/schabi/newpipe/extractor/search/filter/Filter.java
Outdated
Show resolved
Hide resolved
4a7a7bb
to
4c420fb
Compare
4c420fb
to
b09eda4
Compare
b09eda4
to
bb97de7
Compare
extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/ListLinkHandler.java
Outdated
Show resolved
Hide resolved
extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/SearchQueryHandlerFactory.java
Outdated
Show resolved
Hide resolved
extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/ListLinkHandlerFactory.java
Outdated
Show resolved
Hide resolved
extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeHelpers.java
Outdated
Show resolved
Hide resolved
...a/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudSearchExtractor.java
Outdated
Show resolved
Hide resolved
...chabi/newpipe/extractor/services/peertube/linkHandler/PeertubeSearchQueryHandlerFactory.java
Outdated
Show resolved
Hide resolved
...i/newpipe/extractor/services/soundcloud/linkHandler/SoundcloudSearchQueryHandlerFactory.java
Outdated
Show resolved
Hide resolved
...pipe/extractor/services/youtube/search/filter/YoutubeProtoBufferSearchParameterAccessor.java
Outdated
Show resolved
Hide resolved
...pipe/extractor/services/youtube/search/filter/YoutubeProtoBufferSearchParameterAccessor.java
Outdated
Show resolved
Hide resolved
extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/ListLinkHandlerFactory.java
Outdated
Show resolved
Hide resolved
@evermind-zz I went through your changes a bit, and they look good to me overall. I've suggested a few changes; for some of these (the Utils encode and decode methods), a rebase will be needed. |
… within the searchfilters The class LibraryStringIds is a enum. This enum's identify a message. The name of the enum constants reflect the actual message. This message has to be transformed by the library user into a meaningful string.
…nnull Annotate methods in classes that got some signatures changed due to the searchfilters integration
DividerItem was inserted in the content filter framework in the NewPipeExtractor to have a section title for YoutubeMusic. But as UI releated stuff seems a bit out of place in the Extractor I came up with injecting the DividerItem aka section title in the frontend without having to change too much in the frontend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you are. I finished rebasing, but left some fixup commits for clearness. Those will need to either be squashed or get a better commit description. I also kind of reviewed the code, but I will need to review it more.
Now there are only a couple of tests to fix. I pushed a commit to update mocks just so that tests don't fail for that reason. The first two failures in the image are caused by the emergency info filter not being used for YouTube search, while the last one is for PeerTube endpoints not being used anymore.
private static final String MUSIC_SEARCH_URL = "https://music.youtube.com/search?q="; | ||
private YoutubeSearchQueryHandlerFactory() { | ||
super(new YoutubeFilters()); | ||
} | ||
|
||
@Nonnull | ||
public static YoutubeSearchQueryHandlerFactory getInstance() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw that the creation of link handler factory instances was being done with a lazy getInstance
, before the rebase. Since in the meantime we also added getInstance
in the current extractor, I kept the current version to reduce changes, and thus discarded the lazy initialization. However we might want to check if it's better to lazily initialize all link handler factories to reduce static initialization time (but this can be done in a separate PR).
final List<FilterItem> contentFilter, | ||
final List<FilterItem> sortFilter, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some other @Nonnull
and @Nullable
annotations are missing in this file (and all derivate classes)
@Nonnull List<FilterItem> contentFilter, | ||
@Nullable List<FilterItem> sortFilter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why @Nonnull
content filter but @Nullable
sort filter?
@Nonnull List<FilterItem> contentFilter, | ||
@Nullable List<FilterItem> sortFilter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we just use one array with FilterItem
and stop making the distinction between content and sort filters? What is the advantage of having two separate arrays?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a content filter might have a different set of sort filters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But there can already be content filters from various available filter groups, so why can't sort filters be just another filter group? Maybe I'm missing something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have to review my code again. I think I thought about that.
public static final String SEARCH_ENDPOINT_PLAYLISTS = "/api/v1/search/video-playlists"; | ||
public static final String SEARCH_ENDPOINT_VIDEOS = "/api/v1/search/videos"; | ||
public static final String SEARCH_ENDPOINT_CHANNELS = "/api/v1/search/video-channels"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this broke PeerTube filters. In theory using resultType=videos/playlists/channels
should work, however it doesn't seem to, see query with resultType
and query with different endpoints. PeerTube on the web uses the endpoints, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed with 70a2b63
case MUSIC_ARTISTS: | ||
return ""; | ||
default: | ||
return "8AEB"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to update the protobuf file in order to include the "allow emergency requests" field, and then always set that field to true
. I didn't do this while rebasing because I have no idea how the protobuf file is obtained.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you point me more information about the emergency requests? Where is it handled in eg. the browser youtube client.
b938a3c
to
e81796f
Compare
'ALL' option not possible as Peertube uses different endpoints for video/channels/playlist search
…ontent filter search
…able encountered IOException The following Exception crashes NewPipe. Adding Serializable to FilterItem solves it: java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = org.schabi.newpipe.extractor.linkhandler.ListLinkHandler) ... Caused by: java.io.NotSerializableException: org.schabi.newpipe.extractor.search.filter.FilterItem
|
|
||
public FilterContainer(@Nonnull final FilterGroup[] filterGroups) { | ||
this.filterGroups = | ||
Arrays.stream(filterGroups).collect(Collectors.toCollection(ArrayList::new)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arrays.stream(filterGroups).collect(Collectors.toCollection(ArrayList::new)); | |
Arrays.asList(filterGroups); |
extractor/src/main/java/org/schabi/newpipe/extractor/search/filter/FilterGroup.java
Show resolved
Hide resolved
At the moment I have not enough time to look into it. But I will do it whenever I have some time for it. |
@evermind-zz As I can't anwser you as a comment as I have a pending review of your PR (in which I also explained you where to implement this property), see #1127. I will try to finish the review soon, but I can't promise you anything. |
Sort filters reworked
Closes:
Superseeds
Questions
A: Rework content and sort filter framework #904 (review)