0

В базу заносится название и описание кино/сериала

This commit is contained in:
2017-04-07 15:30:37 +03:00
parent b732be993a
commit 8e4122afe0
7 changed files with 28 additions and 13 deletions

View File

@@ -59,7 +59,11 @@ public class OnlinelifeScanner implements ScannerCinema {
File saveTo = new File(this.saveToDir, url.substring(url.lastIndexOf("/")+1, url.lastIndexOf("."))+".jpg");
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);
}

View File

@@ -55,7 +55,12 @@ public class SeasonvarScanner implements ScannerCinema {
File saveTo = new File(this.saveTo, url.substring(url.indexOf("/")+1, url.lastIndexOf("."))+".jpg");
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);
}
}

View File

@@ -13,17 +13,18 @@ import org.springframework.data.mongodb.core.mapping.Document;
@Document(collection = "cinema")
@NoArgsConstructor
public class CinemaDocument {
@Id
@Id @Getter
private String id;
@Getter @Setter
private String title;
@Getter @Setter
private String description;
@Getter @Setter
private String fileName;
@Getter @Setter
private String typeWarez;
public CinemaDocument(String fileName, String typeWarez) {
this.fileName = fileName;
this.typeWarez = typeWarez;
}
}