Первые попытки воспроизведения фильмов со сторонних ресурсов
This commit is contained in:
@@ -50,7 +50,8 @@ public class Hdrezka implements KinoWarez {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void player(String page) {
|
||||
public String player(String page) {
|
||||
//TODO ignore
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,5 +6,5 @@ import java.util.List;
|
||||
|
||||
public interface KinoWarez {
|
||||
void search(String nameKino, List<Kino> outList, boolean strong);
|
||||
void player(String page);
|
||||
String player(String page);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package kinosearch.core.warez;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import kinosearch.core.browser.Browser;
|
||||
import kinosearch.core.Kino;
|
||||
import kinosearch.core.Tools;
|
||||
@@ -54,7 +56,23 @@ public class Onlinelife implements KinoWarez {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void player(String page) {
|
||||
//TODO some code...
|
||||
public String player(String page) {
|
||||
String movie_id = page.substring(1,page.indexOf("-"));
|
||||
|
||||
Browser browser = Tools.createBrowser();
|
||||
browser.setEncoding("windows-1251");
|
||||
browser.setHeader("Referer", "http://dterod.com/player.php?newsid=" + movie_id);
|
||||
String html = browser.get("http://dterod.com/js.php?id=" + movie_id);
|
||||
html = html.substring(0, html.indexOf('\n')).trim();
|
||||
String json = html.substring(html.indexOf('{'), html.indexOf("};")+1);
|
||||
JsonObject jsonObj = new Gson().fromJson(json, JsonObject.class);
|
||||
|
||||
if (jsonObj.has("file")) {
|
||||
return jsonObj.get("file").getAsString();
|
||||
} else if (jsonObj.has("pl")) {
|
||||
return jsonObj.get("pl").getAsString();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
53
src/main/java/kinosearch/webapp/servlets/PlayerServlet.java
Normal file
53
src/main/java/kinosearch/webapp/servlets/PlayerServlet.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package kinosearch.webapp.servlets;
|
||||
|
||||
import kinosearch.core.warez.KinoWarez;
|
||||
import kinosearch.core.warez.Onlinelife;
|
||||
import kinosearch.webapp.WebApp;
|
||||
import kinosearch.webapp.template.TemplateProcessor;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by DmitriyMX <mail@dmitriymx.ru>
|
||||
* 2016
|
||||
*/
|
||||
public class PlayerServlet extends HttpServlet {
|
||||
private TemplateProcessor template;
|
||||
|
||||
@Override
|
||||
public void init(ServletConfig config) throws ServletException {
|
||||
super.init(config);
|
||||
template = WebApp.getTemplateProcessor();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
if (req.getPathInfo() == null) return;
|
||||
|
||||
Map<String, Object> model = WebApp.getDefaultModel(getServletContext());
|
||||
|
||||
model.put("raw_data", String.format(
|
||||
"req.getPathInfo() = %s\n" +
|
||||
"req.getServletPath() = %s",
|
||||
req.getPathInfo(), req.getServletPath()));
|
||||
|
||||
KinoWarez kinoWarez = new Onlinelife();
|
||||
String movie_url = kinoWarez.player(req.getPathInfo());
|
||||
model.put("movie_url", movie_url);
|
||||
|
||||
resp.setCharacterEncoding("UTF-8");
|
||||
resp.setContentType("text/html;charset=UTF-8");
|
||||
try {
|
||||
template.process("player.html", model, resp.getWriter());
|
||||
} catch (IOException e) {
|
||||
log("Error process template", e);
|
||||
resp.sendError(500);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user