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