- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 497
Rework content and sort filter framework #904
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
base: dev
Are you sure you want to change the base?
Changes from all commits
3398a54
              8409215
              3956e22
              b8eb121
              1dc746a
              9e75344
              c7ef8a9
              f484f20
              a043cbd
              17320ef
              d1bf446
              e084338
              debb776
              8568f19
              0a4b889
              ec19719
              af1f1de
              d7b0430
              49c3545
              e06fac6
              c6b335c
              43479ab
              4a8b7f6
              1fc0fc7
              019ef62
              8280fd4
              3e68e17
              5a02063
              1d552c4
              78c8a60
              11d268f
              4210592
              0985afa
              04f03ab
              e81796f
              23fe41d
              659deb0
              dd252d3
              70a2b63
              67366ea
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| package org.schabi.newpipe.extractor.exceptions; | ||
|  | ||
| import org.schabi.newpipe.extractor.search.filter.FilterItem; | ||
|  | ||
| public final class UnsupportedTabException extends UnsupportedOperationException { | ||
| public UnsupportedTabException(final String unsupportedTab) { | ||
| public UnsupportedTabException(final FilterItem unsupportedTab) { | ||
| super("Unsupported tab " + unsupportedTab); | ||
| } | ||
| } | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,24 +1,29 @@ | ||
| package org.schabi.newpipe.extractor.linkhandler; | ||
|  | ||
| import org.schabi.newpipe.extractor.exceptions.ParsingException; | ||
| import org.schabi.newpipe.extractor.search.filter.FilterItem; | ||
| import org.schabi.newpipe.extractor.utils.Utils; | ||
|  | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Objects; | ||
|  | ||
| import javax.annotation.Nonnull; | ||
| import javax.annotation.Nullable; | ||
|  | ||
| public abstract class ListLinkHandlerFactory extends LinkHandlerFactory { | ||
|  | ||
| /////////////////////////////////// | ||
| // To Override | ||
| /////////////////////////////////// | ||
|  | ||
| public abstract String getUrl(String id, List<String> contentFilter, String sortFilter) | ||
| public abstract String getUrl(String id, | ||
| @Nonnull List<FilterItem> contentFilter, | ||
| @Nullable List<FilterItem> sortFilter) | ||
| 
      Comment on lines
    
      +20
     to 
      +21
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we just use one array with  There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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. | ||
| throws ParsingException, UnsupportedOperationException; | ||
|  | ||
| public String getUrl(final String id, | ||
| final List<String> contentFilter, | ||
| final String sortFilter, | ||
| final List<FilterItem> contentFilter, | ||
| final List<FilterItem> sortFilter, | ||
| 
      Comment on lines
    
      +25
     to 
      +26
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some other  | ||
| final String baseUrl) | ||
| throws ParsingException, UnsupportedOperationException { | ||
| return getUrl(id, contentFilter, sortFilter); | ||
|  | @@ -51,16 +56,16 @@ public ListLinkHandler fromId(final String id, final String baseUrl) throws Pars | |
| return new ListLinkHandler(super.fromId(id, baseUrl)); | ||
| } | ||
|  | ||
| public ListLinkHandler fromQuery(final String id, | ||
| final List<String> contentFilters, | ||
| final String sortFilter) throws ParsingException { | ||
| final String url = getUrl(id, contentFilters, sortFilter); | ||
| return new ListLinkHandler(url, url, id, contentFilters, sortFilter); | ||
| public ListLinkHandler fromQuery(final String query, | ||
| final List<FilterItem> contentFilter, | ||
| final List<FilterItem> sortFilter) throws ParsingException { | ||
| final String url = getUrl(query, contentFilter, sortFilter); | ||
| return new ListLinkHandler(url, url, query, contentFilter, sortFilter); | ||
| } | ||
|  | ||
| public ListLinkHandler fromQuery(final String id, | ||
| final List<String> contentFilters, | ||
| final String sortFilter, | ||
| final List<FilterItem> contentFilters, | ||
| final List<FilterItem> sortFilter, | ||
| final String baseUrl) throws ParsingException { | ||
| final String url = getUrl(id, contentFilters, sortFilter, baseUrl); | ||
| return new ListLinkHandler(url, url, id, contentFilters, sortFilter); | ||
|  | @@ -74,31 +79,12 @@ public ListLinkHandler fromQuery(final String id, | |
| * @return the url corresponding to id without any filters applied | ||
| */ | ||
| public String getUrl(final String id) throws ParsingException, UnsupportedOperationException { | ||
| return getUrl(id, new ArrayList<>(0), ""); | ||
| return getUrl(id, List.of(), List.of()); | ||
| } | ||
|  | ||
| @Override | ||
| public String getUrl(final String id, final String baseUrl) throws ParsingException { | ||
| return getUrl(id, new ArrayList<>(0), "", baseUrl); | ||
| } | ||
|  | ||
| /** | ||
| * Will returns content filter the corresponding extractor can handle like "channels", "videos", | ||
| * "music", etc. | ||
| * | ||
| * @return filter that can be applied when building a query for getting a list | ||
| */ | ||
| public String[] getAvailableContentFilter() { | ||
| return new String[0]; | ||
| } | ||
|  | ||
| /** | ||
| * Will returns sort filter the corresponding extractor can handle like "A-Z", "oldest first", | ||
| * "size", etc. | ||
| * | ||
| * @return filter that can be applied when building a query for getting a list | ||
| */ | ||
| public String[] getAvailableSortFilter() { | ||
| return new String[0]; | ||
| public String getUrl(final String id, final String baseUrl) | ||
| throws ParsingException, UnsupportedOperationException { | ||
| return getUrl(id, List.of(), List.of(), baseUrl); | ||
| } | ||
| } | ||
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
@Nonnullcontent filter but@Nullablesort filter?