Bandcamp search query handler factory: inline variable

This commit is contained in:
Fynn Godau 2020-04-20 23:03:46 +02:00
parent 10ae3db118
commit 8c70dab8c5
2 changed files with 3 additions and 9 deletions

View file

@ -17,8 +17,6 @@ import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import static org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampSearchQueryHandlerFactory.CHARSET_UTF_8;
public class BandcampSuggestionExtractor extends SuggestionExtractor {
private static final String AUTOCOMPLETE_URL = "https://bandcamp.com/api/fuzzysearch/1/autocomplete?q=";
@ -32,7 +30,7 @@ public class BandcampSuggestionExtractor extends SuggestionExtractor {
try {
JsonObject fuzzyResults = JsonParser.object().from(
downloader.get(AUTOCOMPLETE_URL + URLEncoder.encode(query, CHARSET_UTF_8)).responseBody()
downloader.get(AUTOCOMPLETE_URL + URLEncoder.encode(query, "UTF-8")).responseBody()
);
JsonArray jsonArray = fuzzyResults.getObject("auto")

View file

@ -11,17 +11,13 @@ import java.util.List;
public class BandcampSearchQueryHandlerFactory extends SearchQueryHandlerFactory {
private static final String SEARCH_URL = "https://bandcamp.com/search?q=";
public static final String CHARSET_UTF_8 = "UTF-8";
@Override
public String getUrl(String query, List<String> contentFilter, String sortFilter) throws ParsingException {
try {
return SEARCH_URL +
URLEncoder.encode(query, CHARSET_UTF_8)
return "https://bandcamp.com/search?q=" +
URLEncoder.encode(query, "UTF-8")
+ "&page=1";
} catch (UnsupportedEncodingException e) {