Search in sources :

Example 36 with Manga

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;
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList) Manga(ar.rulosoft.mimanganu.componentes.Manga)

Example 37 with Manga

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;
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList) Manga(ar.rulosoft.mimanganu.componentes.Manga)

Example 38 with Manga

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;
}
Also used : JSONObject(org.json.JSONObject) Navigator(ar.rulosoft.navegadores.Navigator) ArrayList(java.util.ArrayList) JSONArray(org.json.JSONArray) Manga(ar.rulosoft.mimanganu.componentes.Manga)

Example 39 with Manga

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;
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) Chapter(ar.rulosoft.mimanganu.componentes.Chapter) SimpleDateFormat(java.text.SimpleDateFormat) Manga(ar.rulosoft.mimanganu.componentes.Manga) Date(java.util.Date)

Example 40 with Manga

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;
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList) Manga(ar.rulosoft.mimanganu.componentes.Manga)

Aggregations

Manga (ar.rulosoft.mimanganu.componentes.Manga)61 ArrayList (java.util.ArrayList)48 Matcher (java.util.regex.Matcher)40 Pattern (java.util.regex.Pattern)40 JSONObject (org.json.JSONObject)6 View (android.view.View)5 Navigator (ar.rulosoft.navegadores.Navigator)5 Chapter (ar.rulosoft.mimanganu.componentes.Chapter)4 AsyncAddManga (ar.rulosoft.mimanganu.utils.AsyncAddManga)4 JSONArray (org.json.JSONArray)4 MenuInflater (android.view.MenuInflater)3 ServerBase (ar.rulosoft.mimanganu.servers.ServerBase)3 List (java.util.List)3 Bundle (android.os.Bundle)2 RecyclerView (android.support.v7.widget.RecyclerView)2 OnClickListener (android.view.View.OnClickListener)2 AdapterView (android.widget.AdapterView)2 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)2 ListView (android.widget.ListView)2 MangasRecAdapter (ar.rulosoft.mimanganu.adapters.MangasRecAdapter)2