fix: изменение алгоритмов поиска в Seasonvar
This commit is contained in:
@@ -13,10 +13,6 @@ import kinosearch.core.KinoItem;
|
||||
import kinosearch.core.KinoPlay;
|
||||
import kinosearch.core.Tools;
|
||||
import kinosearch.core.browser.Browser;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -42,30 +38,31 @@ public class Seasonvar implements KinoWarez {
|
||||
|
||||
@Override
|
||||
public List<Kino> search(String nameKino, boolean strong) {
|
||||
String html = browser.get(DOMAIN + "/search?q=" + Tools.SafeUrlEncode(nameKino, "UTF-8"));
|
||||
if (html.isEmpty()) return Collections.emptyList();
|
||||
browser.setHeader("X-Requested-With", "XMLHttpRequest");
|
||||
String json = browser.get(String.format(
|
||||
"%s/autocomplete.php?query=%s",
|
||||
DOMAIN,
|
||||
Tools.SafeUrlEncode(nameKino, "UTF-8")));
|
||||
|
||||
Pattern pattern = null;
|
||||
if (strong) {
|
||||
pattern = Tools.getStrongPattern(nameKino.toLowerCase());
|
||||
if (json.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Document document = Jsoup.parse(html);
|
||||
Elements elements = document.getElementsByClass("searchName");
|
||||
JsonObject jsonObject = gson.fromJson(json, JsonObject.class);
|
||||
JsonArray data = jsonObject.get("data").getAsJsonArray();
|
||||
if (data.size() == 0 || data.get(0).getAsString().isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
JsonArray suggestions = jsonObject.get("suggestions").getAsJsonArray();
|
||||
|
||||
List<Kino> outList = new ArrayList<>();
|
||||
for (Element element : elements) {
|
||||
Element childElement = element.child(0);
|
||||
String name = childElement.text();
|
||||
String url = childElement.attr("href");
|
||||
|
||||
if (strong) {
|
||||
Matcher matcher = pattern.matcher(name.toLowerCase());
|
||||
if (!matcher.find()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Kino kino = new Kino(name, DOMAIN + url, this);
|
||||
for (int i = 0; i < suggestions.size(); i++) {
|
||||
Kino kino = new Kino(
|
||||
suggestions.get(i).getAsString(),
|
||||
DOMAIN + "/" + data.get(i).getAsString(),
|
||||
this
|
||||
);
|
||||
kino.setPlayer(true);
|
||||
outList.add(kino);
|
||||
}
|
||||
@@ -100,6 +97,7 @@ public class Seasonvar implements KinoWarez {
|
||||
serials.add(new KinoItem(
|
||||
jsonObject.get("comment").getAsString().replace("<br>", ""),
|
||||
jsonObject.get("file").getAsString().replace("http://", "/proxy/seasonvar/")
|
||||
.replace("/fi3lm/", "/fi2lm/").replace("//", "/")
|
||||
));
|
||||
}
|
||||
kinoPlay.setSerials(serials);
|
||||
|
||||
Reference in New Issue
Block a user