Отображение постеров к фильмам
This commit is contained in:
@@ -62,13 +62,13 @@ public class OnlinelifeScanner implements ScannerCinema {
|
|||||||
Document document = Jsoup.parse(browser.get(url));
|
Document document = Jsoup.parse(browser.get(url));
|
||||||
Element element = document.getElementsByClass("full-poster").get(0);
|
Element element = document.getElementsByClass("full-poster").get(0);
|
||||||
|
|
||||||
File saveTo = new File(this.saveToDir, url.substring(url.lastIndexOf("/")+1, url.lastIndexOf("."))+".jpg");
|
String pathFile = "onlinelife/"+url.substring(url.lastIndexOf("/")+1, url.lastIndexOf("."))+".jpg";
|
||||||
this.fileDownloader.addFile(element.attr("src"), saveTo);
|
this.fileDownloader.addFile(element.attr("src"), new File(this.saveToDir, pathFile));
|
||||||
|
|
||||||
CinemaDocument cinemaDocument = new CinemaDocument();
|
CinemaDocument cinemaDocument = new CinemaDocument();
|
||||||
cinemaDocument.setTitle(document.getElementsByClass("film_info").get(0).child(0).child(0).text().trim());
|
cinemaDocument.setTitle(document.getElementsByClass("film_info").get(0).child(0).child(0).text().trim());
|
||||||
cinemaDocument.setDescription(document.getElementsByClass("film-description").get(0).text());
|
cinemaDocument.setDescription(document.getElementsByClass("film-description").get(0).text());
|
||||||
cinemaDocument.setFileName(saveTo.getAbsolutePath());
|
cinemaDocument.setFileName(pathFile);
|
||||||
cinemaDocument.setTypeWarez(this.getName());
|
cinemaDocument.setTypeWarez(this.getName());
|
||||||
cinemaDocument.setUrl(url);
|
cinemaDocument.setUrl(url);
|
||||||
repository.save(cinemaDocument);
|
repository.save(cinemaDocument);
|
||||||
|
|||||||
@@ -58,14 +58,14 @@ public class SeasonvarScanner implements ScannerCinema {
|
|||||||
Document document = Jsoup.parse(browser.get(url));
|
Document document = Jsoup.parse(browser.get(url));
|
||||||
Element element = document.getElementsByAttributeValue("itemprop", "thumbnailUrl").get(0);
|
Element element = document.getElementsByAttributeValue("itemprop", "thumbnailUrl").get(0);
|
||||||
|
|
||||||
File saveTo = new File(this.saveTo, url.substring(url.lastIndexOf("/")+1, url.lastIndexOf("."))+".jpg");
|
String pathFile = "seasonvar/"+url.substring(url.lastIndexOf("/")+1, url.lastIndexOf("."))+".jpg";
|
||||||
this.fileDownloader.addFile(element.attr("src"), saveTo);
|
this.fileDownloader.addFile(element.attr("src"), new File(this.saveTo, pathFile));
|
||||||
|
|
||||||
CinemaDocument cinemaDocument = new CinemaDocument();
|
CinemaDocument cinemaDocument = new CinemaDocument();
|
||||||
String title = document.getElementsByClass("pgs-sinfo-title").get(0).text();
|
String title = document.getElementsByClass("pgs-sinfo-title").get(0).text();
|
||||||
cinemaDocument.setTitle(title.replaceAll("^Сериал ", "").replaceAll(" онлайн$", ""));
|
cinemaDocument.setTitle(title.replaceAll("^Сериал ", "").replaceAll(" онлайн$", ""));
|
||||||
cinemaDocument.setDescription(document.getElementsByAttributeValue("itemprop", "description").get(0).text());
|
cinemaDocument.setDescription(document.getElementsByAttributeValue("itemprop", "description").get(0).text());
|
||||||
cinemaDocument.setFileName(saveTo.getAbsolutePath());
|
cinemaDocument.setFileName(pathFile);
|
||||||
cinemaDocument.setTypeWarez(this.getName());
|
cinemaDocument.setTypeWarez(this.getName());
|
||||||
cinemaDocument.setUrl(url);
|
cinemaDocument.setUrl(url);
|
||||||
this.repository.save(cinemaDocument);
|
this.repository.save(cinemaDocument);
|
||||||
|
|||||||
@@ -6,27 +6,34 @@ package kinosearch.kinosearch3.webpp;
|
|||||||
|
|
||||||
import kinosearch.kinosearch3.base.BaseRepository;
|
import kinosearch.kinosearch3.base.BaseRepository;
|
||||||
import kinosearch.kinosearch3.base.CinemaDocument;
|
import kinosearch.kinosearch3.base.CinemaDocument;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@PropertySource("classpath:/application.properties")
|
||||||
public class WebAppController {
|
public class WebAppController {
|
||||||
private final Logger logger = LoggerFactory.getLogger(WebAppController.class);
|
private final Logger logger = LoggerFactory.getLogger(WebAppController.class);
|
||||||
private final BaseRepository baseRepository;
|
private final BaseRepository baseRepository;
|
||||||
|
private final String saveDir;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public WebAppController(BaseRepository baseRepository) {
|
public WebAppController(BaseRepository baseRepository, @Value("${saveRootDir}") String saveDir) {
|
||||||
this.baseRepository = baseRepository;
|
this.baseRepository = baseRepository;
|
||||||
|
this.saveDir = saveDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/", method = RequestMethod.GET)
|
@RequestMapping(value = "/", method = RequestMethod.GET)
|
||||||
@@ -45,6 +52,19 @@ public class WebAppController {
|
|||||||
return "searchResult";
|
return "searchResult";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/poster/**", method = RequestMethod.GET)
|
||||||
|
@ResponseBody
|
||||||
|
public void poster(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||||
|
File posterFile = new File(this.saveDir, request.getPathInfo().substring("/poster/".length()));
|
||||||
|
logger.debug("poster file: {}", posterFile);
|
||||||
|
if (posterFile.exists()) {
|
||||||
|
response.setStatus(200);
|
||||||
|
IOUtils.copy(new FileInputStream(posterFile), response.getOutputStream());
|
||||||
|
} else {
|
||||||
|
response.setStatus(404);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/blog.html", method = RequestMethod.GET)
|
@RequestMapping(value = "/blog.html", method = RequestMethod.GET)
|
||||||
public String blog() {
|
public String blog() {
|
||||||
return "blog";
|
return "blog";
|
||||||
|
|||||||
@@ -43,14 +43,14 @@
|
|||||||
<property name="encoding" value="windows-1251"/>
|
<property name="encoding" value="windows-1251"/>
|
||||||
</bean>
|
</bean>
|
||||||
</constructor-arg>
|
</constructor-arg>
|
||||||
<constructor-arg name="saveToDir" value="file:${saveRootDir}/onlinelife"/>
|
<constructor-arg name="saveToDir" value="file:${saveRootDir}"/>
|
||||||
<constructor-arg name="repository" ref="repository"/>
|
<constructor-arg name="repository" ref="repository"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="seasonvarScanner" class="kinosearch.kinosearch3.cinema.SeasonvarScanner">
|
<bean id="seasonvarScanner" class="kinosearch.kinosearch3.cinema.SeasonvarScanner">
|
||||||
<constructor-arg name="fileDownloader" ref="fileDownloader"/>
|
<constructor-arg name="fileDownloader" ref="fileDownloader"/>
|
||||||
<constructor-arg name="browser" ref="browser"/>
|
<constructor-arg name="browser" ref="browser"/>
|
||||||
<constructor-arg name="saveTo" value="file:${saveRootDir}/seasonvar"/>
|
<constructor-arg name="saveTo" value="file:${saveRootDir}"/>
|
||||||
<constructor-arg name="repository" ref="repository"/>
|
<constructor-arg name="repository" ref="repository"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,10 @@
|
|||||||
[#if cindocs?has_content]
|
[#if cindocs?has_content]
|
||||||
<ol>
|
<ol>
|
||||||
[#list cindocs as cinema]
|
[#list cindocs as cinema]
|
||||||
<li><a href="${cinema.url}" target="_blank">[${cinema.typeWarez}] ${cinema.title}</a></li>
|
<li>
|
||||||
|
<img src="/poster/${cinema.fileName}">
|
||||||
|
<a href="${cinema.url}" target="_blank">[${cinema.typeWarez}] ${cinema.title}</a>
|
||||||
|
</li>
|
||||||
[/#list]
|
[/#list]
|
||||||
</ol>
|
</ol>
|
||||||
[#else]
|
[#else]
|
||||||
|
|||||||
Reference in New Issue
Block a user