use of de.herrlock.manga.index.entity.HosterListEntry in project Manga by herrlock.
the class MangaFoxChapterList method getAvailabile.
@Override
public Collection<HosterListEntry> getAvailabile(final IndexerConfiguration conf) {
Document doc;
final URL baseUrl;
try {
baseUrl = new URL(getDetails().baseUrl());
URL listUrl = new URL(baseUrl, "/manga/");
doc = Utils.getDocument(listUrl, conf);
} catch (IOException ex) {
throw new MDRuntimeException(ex);
}
Elements elements = doc.select("div#page div.manga_list > ul > li > a");
Collection<HosterListEntry> entries = new TreeSet<>(HosterListEntry.NAME_COMPARATOR);
for (Element element : elements) {
HosterListEntry entry = new HosterListEntry();
entry.setName(element.text());
try {
entry.setUrl(new URL(baseUrl, element.attr("href")).toExternalForm());
} catch (MalformedURLException ex) {
logger.catching(Level.DEBUG, ex);
}
entries.add(entry);
}
return entries;
}
use of de.herrlock.manga.index.entity.HosterListEntry in project Manga by herrlock.
the class HosterImpl method getAvailabile.
public Collection<HosterListEntry> getAvailabile(@SuppressWarnings("unused") final IndexerConfiguration conf) {
HosterListEntry hosterListEntry = new HosterListEntry();
hosterListEntry.setName("<no entries>");
hosterListEntry.setUrl(getDetails().baseUrl());
return Arrays.asList(hosterListEntry);
}
use of de.herrlock.manga.index.entity.HosterListEntry in project Manga by herrlock.
the class MangaPandaChapterList method getAvailabile.
@Override
public Collection<HosterListEntry> getAvailabile(final IndexerConfiguration conf) {
Document doc;
final URL baseUrl;
try {
baseUrl = new URL(getDetails().baseUrl());
URL listUrl = new URL(baseUrl, "/alphabetical");
doc = Utils.getDocument(listUrl, conf);
} catch (IOException ex) {
throw new MDRuntimeException(ex);
}
Elements elements = doc.select("div.series_col ul.series_alpha > li > a");
Collection<HosterListEntry> entries = new TreeSet<>(HosterListEntry.NAME_COMPARATOR);
for (Element element : elements) {
HosterListEntry entry = new HosterListEntry();
entry.setName(element.text());
try {
entry.setUrl(new URL(baseUrl, element.attr("href")).toExternalForm());
} catch (MalformedURLException ex) {
logger.catching(Level.DEBUG, ex);
}
entries.add(entry);
}
return entries;
}
use of de.herrlock.manga.index.entity.HosterListEntry in project Manga by herrlock.
the class Indexer method createJsonIndex.
public static JsonArray createJsonIndex(final IndexerConfiguration conf) {
Index index = createIndex(conf);
JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
for (HosterList hosterList : index.getHosters()) {
for (HosterListEntry hosterListEntry : hosterList.getMangas()) {
arrayBuilder.add(//
Json.createObjectBuilder().add("hosterName", //
hosterList.getHosterName()).add("name", //
hosterListEntry.getName()).add("url", hosterListEntry.getUrl()));
}
}
return arrayBuilder.build();
}
use of de.herrlock.manga.index.entity.HosterListEntry in project Manga by herrlock.
the class Indexer method createIndexFor.
private static HosterList createIndexFor(final Hoster hoster, final IndexerConfiguration conf) {
logger.traceEntry("({})", hoster);
Collection<HosterListEntry> elements = hoster.getAvailabile(conf);
Collection<HosterListEntry> mangas = new TreeSet<>(HosterListEntry.NAME_COMPARATOR);
mangas.addAll(elements);
// select random elements from the list
// final int AMOUNT = 10;
// final java.util.Random random = new java.util.Random(
// Long.parseLong( new java.text.SimpleDateFormat( "yyMMdd" ).format( new java.util.Date() ) ) );
// for ( int i = 0; i < Math.min( elements.size(), AMOUNT ); i++ ) {
// int rnd = random.nextInt( elements.size() );
// HosterListEntry entry = com.google.common.collect.Iterables.get( elements, rnd );
// mangas.add( entry );
// }
HosterList hosterList = new HosterList();
hosterList.setHosterName(hoster.getName());
hosterList.setMangas(mangas);
return hosterList;
}
Aggregations