В базу заносится название и описание кино/сериала
This commit is contained in:
@@ -59,7 +59,11 @@ public class OnlinelifeScanner implements ScannerCinema {
|
|||||||
File saveTo = new File(this.saveToDir, url.substring(url.lastIndexOf("/")+1, url.lastIndexOf("."))+".jpg");
|
File saveTo = new File(this.saveToDir, url.substring(url.lastIndexOf("/")+1, url.lastIndexOf("."))+".jpg");
|
||||||
this.fileDownloader.addFile(element.attr("src"), saveTo);
|
this.fileDownloader.addFile(element.attr("src"), saveTo);
|
||||||
|
|
||||||
CinemaDocument cinemaDocument = new CinemaDocument(saveTo.getAbsolutePath(), this.getName());
|
CinemaDocument cinemaDocument = new CinemaDocument();
|
||||||
|
cinemaDocument.setTitle(document.getElementsByClass("film_info").get(0).child(0).child(0).text().trim());
|
||||||
|
cinemaDocument.setDescription(document.getElementsByClass("film-description").get(0).text());
|
||||||
|
cinemaDocument.setFileName(saveTo.getAbsolutePath());
|
||||||
|
cinemaDocument.setTypeWarez(this.getName());
|
||||||
repository.save(cinemaDocument);
|
repository.save(cinemaDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,12 @@ public class SeasonvarScanner implements ScannerCinema {
|
|||||||
File saveTo = new File(this.saveTo, url.substring(url.indexOf("/")+1, url.lastIndexOf("."))+".jpg");
|
File saveTo = new File(this.saveTo, url.substring(url.indexOf("/")+1, url.lastIndexOf("."))+".jpg");
|
||||||
this.fileDownloader.addFile(element.attr("src"), saveTo);
|
this.fileDownloader.addFile(element.attr("src"), saveTo);
|
||||||
|
|
||||||
CinemaDocument cinemaDocument = new CinemaDocument(saveTo.getAbsolutePath(), this.getName());
|
CinemaDocument cinemaDocument = new CinemaDocument();
|
||||||
|
String title = document.getElementsByClass("pgs-sinfo-title").get(0).text();
|
||||||
|
cinemaDocument.setTitle(title.replaceAll("^Сериал ", "").replaceAll(" онлайн$", ""));
|
||||||
|
cinemaDocument.setDescription(document.getElementsByAttributeValue("itemprop", "description").get(0).text());
|
||||||
|
cinemaDocument.setFileName(saveTo.getAbsolutePath());
|
||||||
|
cinemaDocument.setTypeWarez(this.getName());
|
||||||
this.repository.save(cinemaDocument);
|
this.repository.save(cinemaDocument);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,17 +13,18 @@ import org.springframework.data.mongodb.core.mapping.Document;
|
|||||||
@Document(collection = "cinema")
|
@Document(collection = "cinema")
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class CinemaDocument {
|
public class CinemaDocument {
|
||||||
@Id
|
@Id @Getter
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
@Getter @Setter
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@Getter @Setter
|
||||||
|
private String description;
|
||||||
|
|
||||||
@Getter @Setter
|
@Getter @Setter
|
||||||
private String fileName;
|
private String fileName;
|
||||||
|
|
||||||
@Getter @Setter
|
@Getter @Setter
|
||||||
private String typeWarez;
|
private String typeWarez;
|
||||||
|
|
||||||
public CinemaDocument(String fileName, String typeWarez) {
|
|
||||||
this.fileName = fileName;
|
|
||||||
this.typeWarez = typeWarez;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ public class AbstractScannerTest {
|
|||||||
private static MongodProcess mongodProcess;
|
private static MongodProcess mongodProcess;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public static void initBase() throws IOException {
|
public static void initBase() throws IOException {
|
||||||
|
sleep();
|
||||||
IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
|
IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
|
||||||
.defaultsWithLogger(Command.MongoD, LoggerFactory.getLogger("Mongod"))
|
.defaultsWithLogger(Command.MongoD, LoggerFactory.getLogger("Mongod"))
|
||||||
.build();
|
.build();
|
||||||
@@ -41,6 +43,9 @@ public class AbstractScannerTest {
|
|||||||
@AfterClass
|
@AfterClass
|
||||||
public static void shutdownBase() {
|
public static void shutdownBase() {
|
||||||
mongodProcess.stop();
|
mongodProcess.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sleep() {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(5000L);
|
Thread.sleep(5000L);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
*/
|
*/
|
||||||
package kinosearch.kinosearch3.cinema;
|
package kinosearch.kinosearch3.cinema;
|
||||||
|
|
||||||
import kinosearch.kinosearch3.cinema.AbstractScannerTest;
|
|
||||||
import kinosearch.kinosearch3.cinema.OnlinelifeScanner;
|
|
||||||
import kinosearch.kinosearch3.spider.CinemaDocument;
|
import kinosearch.kinosearch3.spider.CinemaDocument;
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
*/
|
*/
|
||||||
package kinosearch.kinosearch3.cinema;
|
package kinosearch.kinosearch3.cinema;
|
||||||
|
|
||||||
import kinosearch.kinosearch3.cinema.AbstractScannerTest;
|
|
||||||
import kinosearch.kinosearch3.cinema.SeasonvarScanner;
|
|
||||||
import kinosearch.kinosearch3.spider.CinemaDocument;
|
import kinosearch.kinosearch3.spider.CinemaDocument;
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|||||||
@@ -26,7 +26,11 @@
|
|||||||
|
|
||||||
<bean id="onlinelifeScanner" class="kinosearch.kinosearch3.cinema.OnlinelifeScanner">
|
<bean id="onlinelifeScanner" class="kinosearch.kinosearch3.cinema.OnlinelifeScanner">
|
||||||
<constructor-arg name="fileDownloader" ref="fileDownloader"/>
|
<constructor-arg name="fileDownloader" ref="fileDownloader"/>
|
||||||
<constructor-arg name="browser" ref="browser"/>
|
<constructor-arg name="browser">
|
||||||
|
<bean parent="browser">
|
||||||
|
<property name="encoding" value="windows-1251"/>
|
||||||
|
</bean>
|
||||||
|
</constructor-arg>
|
||||||
<constructor-arg name="saveToDir" value="file:R:/onlinelife"/>
|
<constructor-arg name="saveToDir" value="file:R:/onlinelife"/>
|
||||||
<constructor-arg name="repository" ref="repository"/>
|
<constructor-arg name="repository" ref="repository"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|||||||
Reference in New Issue
Block a user