//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package kinosearch.webapp.servlets;

import java.io.IOException;
import java.util.Map;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import kinosearch.core.warez.KinoWarez;
import kinosearch.core.warez.Onlinelife;
import kinosearch.webapp.WebApp;
import kinosearch.webapp.template.TemplateProcessor;

public class PlayerServlet extends HttpServlet {
    private TemplateProcessor template;

    public void init(ServletConfig config) throws ServletException {
        super.init(config);
        this.template = WebApp.getTemplateProcessor();
    }

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        if (req.getPathInfo() != null) {
            Map<String, Object> model = WebApp.getDefaultModel(this.getServletContext());
            model.put("raw_data", String.format("req.getPathInfo() = %s\nreq.getServletPath() = %s", req.getPathInfo(), req.getServletPath()));
            KinoWarez kinoWarez = new Onlinelife();
            String json = kinoWarez.player(req.getPathInfo());
            model.put("json", json);
            resp.setCharacterEncoding("UTF-8");
            resp.setContentType("text/html;charset=UTF-8");

            try {
                this.template.process("player.html", model, resp.getWriter());
            } catch (IOException e) {
                this.log("Error process template", e);
                resp.sendError(500);
            }

        }
    }
}
