0

Удачный парсинг фильмов и сериалов с OnlineLife

This commit is contained in:
2016-03-24 13:43:30 +03:00
parent 66aa27859d
commit d23f84bc80
3 changed files with 71 additions and 7 deletions

View File

@@ -41,7 +41,7 @@ public class Onlinelife implements KinoWarez {
for (Element element : elements) {
Element childElement = element.child(0);
String name = childElement.text();
String url = childElement.attr("href");
String url = "onlinelife/" + (childElement.attr("href").substring(DOMAIN.length()+1));
if (strong) {
Matcher matcher = pattern.matcher(name.toLowerCase());
@@ -68,11 +68,12 @@ public class Onlinelife implements KinoWarez {
JsonObject jsonObj = new Gson().fromJson(json, JsonObject.class);
if (jsonObj.has("file")) {
return jsonObj.get("file").getAsString();
return "{\"file\":\"" + jsonObj.get("file").getAsString() + "\"}";
} else if (jsonObj.has("pl")) {
return jsonObj.get("pl").getAsString();
browser.setEncoding("utf-8");
return browser.get(jsonObj.get("pl").getAsString());
} else {
return "";
return "{}";
}
}
}

View File

@@ -38,8 +38,8 @@ public class PlayerServlet extends HttpServlet {
req.getPathInfo(), req.getServletPath()));
KinoWarez kinoWarez = new Onlinelife();
String movie_url = kinoWarez.player(req.getPathInfo());
model.put("movie_url", movie_url);
String json = kinoWarez.player(req.getPathInfo());
model.put("json", json);
resp.setCharacterEncoding("UTF-8");
resp.setContentType("text/html;charset=UTF-8");