use of ar.rulosoft.mimanganu.componentes.Manga in project MiMangaNu by raulhaag.
the class ReadComicOnline method getMangasSource.
private ArrayList<Manga> getMangasSource(String source) {
ArrayList<Manga> mangas = new ArrayList<>();
Pattern p = Pattern.compile("src=\"([^\"]+)\" style=\"float.+?href=\"(.+?)\">(.+?)<", Pattern.DOTALL);
Matcher m = p.matcher(source);
while (m.find()) {
Manga manga = new Manga(getServerID(), m.group(3), m.group(2), false);
manga.setImages(m.group(1));
mangas.add(manga);
}
return mangas;
}
use of ar.rulosoft.mimanganu.componentes.Manga in project MiMangaNu by raulhaag.
the class ReadMangaMe method getMangasFromSource.
private ArrayList<Manga> getMangasFromSource(String source) {
Pattern pattern = Pattern.compile("sm-6 \">[^/]*href=\"([^\"]+)[^/]*=\"([^\"]+)\" title=\"([^\"]+)", Pattern.DOTALL);
Matcher matcher = pattern.matcher(source);
ArrayList<Manga> mangas = new ArrayList<>();
while (matcher.find()) {
Manga manga = new Manga(getServerID(), matcher.group(3), matcher.group(1), false);
manga.setImages(matcher.group(2));
mangas.add(manga);
}
return mangas;
}
use of ar.rulosoft.mimanganu.componentes.Manga in project MiMangaNu by raulhaag.
the class ReadMangaToday method search.
@Override
public ArrayList<Manga> search(String term) throws Exception {
ArrayList<Manga> mangas = new ArrayList<>();
Navigator nav = getNavigatorAndFlushParameters();
nav.addHeader("x-requested-with", "XMLHttpRequest");
String data = getNavigatorAndFlushParameters().get(HOST + "/service/search?q=" + term.toLowerCase());
if (!data.equals("false")) {
JSONArray arr = new JSONArray(data);
for (int i = 0; i < arr.length(); i++) {
JSONObject m = arr.getJSONObject(i);
Manga manga = new Manga(getServerID(), m.getString("title"), m.getString("url"), false);
mangas.add(manga);
}
}
return mangas;
}
use of ar.rulosoft.mimanganu.componentes.Manga in project MiMangaNu by raulhaag.
the class ServerBase method searchForNewChapters.
/**
* Searches for new chapters for a given Manga.
* Loads information from the database and fetches the current state from the server. Afterwards
* the server information is compared to the local information to check if new chapters are
* available.
* <p>
* A fast check can be triggered to reduce load and compare time by checking only the last 20
* chapters for differences.
* <p>
* All detected changes are also stored in the database.
*
* @param id the Manga id to check new chapters for
* @param context the Context object to use for checking
* @param fast <code>true</code> to perform a fast check (first 20 chapters only)
* @return the count of new chapters found
* @throws Exception if an error occurred. The exception is thrown back to UI, so its message
* should be a translatable string.
*/
public int searchForNewChapters(int id, Context context, boolean fast) throws Exception {
int returnValue;
Manga mangaDb = Database.getFullManga(context, id);
Manga manga = new Manga(mangaDb.getServerId(), mangaDb.getTitle(), mangaDb.getPath(), false);
manga.setId(mangaDb.getId());
try {
this.loadMangaInformation(manga, true);
this.loadChapters(manga, false);
} catch (Exception e) {
// to many messages are annoying
// Util.getInstance().toast(context, context.getResources().getString(R.string.update_search_failed, mangaDb.getTitle(), getServerName()));
e.printStackTrace();
return 0;
}
if (fast && manga.getChapters().size() > 21) {
manga.getChapters().subList(0, manga.getChapters().size() - 20).clear();
}
manga.getChapters().removeAll(mangaDb.getChapters());
ArrayList<Chapter> simpleList = manga.getChapters();
for (Chapter chapter : simpleList) {
chapter.setMangaID(mangaDb.getId());
chapter.setReadStatus(Chapter.NEW);
Database.addChapter(context, chapter, mangaDb.getId());
}
if (simpleList.size() > 0) {
Database.updateMangaRead(context, mangaDb.getId());
Database.updateNewMangas(context, mangaDb, simpleList.size());
}
if (!simpleList.isEmpty())
new CreateGroupByMangaNotificationsTask(simpleList, manga, context).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
returnValue = simpleList.size();
boolean changes = false;
if (!mangaDb.getAuthor().equals(manga.getAuthor()) && manga.getAuthor() != null && manga.getAuthor().length() > 2) {
mangaDb.setAuthor(manga.getAuthor());
changes = true;
}
if (mangaDb.getImages() != null && !mangaDb.getImages().equals(manga.getImages()) && manga.getImages() != null && manga.getImages().length() > 2) {
mangaDb.setImages(manga.getImages());
changes = true;
}
if (!mangaDb.getSynopsis().equals(manga.getSynopsis()) && manga.getSynopsis().length() > 3) {
mangaDb.setSynopsis(manga.getSynopsis());
changes = true;
}
if (!mangaDb.getGenre().equals(manga.getGenre()) && manga.getGenre().length() > 2) {
mangaDb.setGenre(manga.getGenre());
changes = true;
}
if (mangaDb.isFinished() != manga.isFinished()) {
mangaDb.setFinished(manga.isFinished());
changes = true;
}
if (!simpleList.isEmpty()) {
DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy", Locale.getDefault());
Date date = new Date();
String lastUpdate = dateFormat.format(date);
if (mangaDb.getLastUpdate() != null && !mangaDb.getLastUpdate().equals(lastUpdate)) {
mangaDb.setLastUpdate(lastUpdate);
changes = true;
}
}
if (changes)
Database.updateManga(context, mangaDb, false);
return returnValue;
}
use of ar.rulosoft.mimanganu.componentes.Manga in project MiMangaNu by raulhaag.
the class SubManga method getMangas.
@Override
public ArrayList<Manga> getMangas() throws Exception {
ArrayList<Manga> mangas = new ArrayList<>();
String source = getNavigatorAndFlushParameters().get(HOST + "/series");
Pattern p = Pattern.compile("<td><a href=\"(http://submanga.com/.+?)\".+?</b>(.+?)<", Pattern.DOTALL);
Matcher m = p.matcher(source);
while (m.find()) {
mangas.add(new Manga(getServerID(), m.group(2), m.group(1), false));
}
return mangas;
}
Aggregations