Search in sources :

Example 26 with Chapter

use of ar.rulosoft.mimanganu.componentes.Chapter in project MiMangaNu by raulhaag.

the class SubManga method loadChapters.

@Override
public void loadChapters(Manga manga, boolean forceReload) throws Exception {
    if (manga.getChapters().isEmpty() || forceReload) {
        String data = getNavigatorAndFlushParameters().get((manga.getPath() + "/completa"));
        Pattern p = Pattern.compile("<tr[^>]*><td[^>]*><a href=\"http://submanga.com/([^\"|#]+)\">(.+?)</a>", Pattern.DOTALL);
        Matcher m = p.matcher(data);
        while (m.find()) {
            String web = HOST + "/c" + m.group(1).substring(m.group(1).lastIndexOf("/"));
            manga.addChapterFirst(new Chapter(m.group(2), web));
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) Chapter(ar.rulosoft.mimanganu.componentes.Chapter)

Example 27 with Chapter

use of ar.rulosoft.mimanganu.componentes.Chapter in project MiMangaNu by raulhaag.

the class Taadd method loadMangaInformation.

@Override
public void loadMangaInformation(Manga manga, boolean forceReload) throws Exception {
    if (manga.getChapters().isEmpty() || forceReload) {
        String source = getNavigatorAndFlushParameters().get(manga.getPath() + "?waring=1");
        // Cover
        if (manga.getImages() == null || manga.getImages().isEmpty()) {
            String img = getFirstMatchDefault("src=\"(http://pic\\.taadd\\.com/files/img/logo/[^\"]+)\"", source, "");
            manga.setImages(img);
        }
        // Summary
        String summary = getFirstMatchDefault("Summary(.+?)</td>", source, context.getString(R.string.nodisponible));
        manga.setSynopsis(summary);
        // Status
        manga.setFinished(source.contains(">Completed</a>"));
        // Author
        manga.setAuthor(getFirstMatchDefault("author-(.+?).html\">", source, context.getString(R.string.nodisponible)));
        // Genre
        manga.setGenre(getFirstMatchDefault("Categories:(.+?)</a>[^<]*</td>", source, context.getString(R.string.nodisponible)).replaceAll("<img[^>]+>", "").replaceAll("&nbsp;", "").replaceAll("</a>", ","));
        // Chapters
        Pattern p = Pattern.compile("href=\"(/chapter/[^-\"]+?)\">(.+?)</a>", Pattern.DOTALL);
        Matcher matcher = p.matcher(source);
        while (matcher.find()) {
            manga.addChapterFirst(new Chapter(matcher.group(2), HOST + matcher.group(1)));
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) Chapter(ar.rulosoft.mimanganu.componentes.Chapter)

Example 28 with Chapter

use of ar.rulosoft.mimanganu.componentes.Chapter in project MiMangaNu by raulhaag.

the class TuMangaOnline method getChaptersJsonArray.

private ArrayList<Chapter> getChaptersJsonArray(JSONArray jsonArray, String mid) {
    ArrayList<Chapter> result = new ArrayList<>();
    for (int i = 0; i < jsonArray.length(); i++) {
        try {
            JSONObject object = jsonArray.getJSONObject(i);
            Chapter c = new Chapter("CapĂ­tulo " + object.getString("numCapitulo") + " " + (object.getString("nombre").equalsIgnoreCase("null") ? "" : object.getString("nombre")), getServerID() + "_" + mid + "_" + object.getString("numCapitulo"));
            c.setExtra("https://www.tumangaonline.com/api/v1/imagenes?idManga=" + mid + "&idScanlation=" + object.getJSONArray("subidas").getJSONObject(0).getString("idScan") + "&numeroCapitulo=" + object.getString("numCapitulo") + "&visto=false");
            result.add(0, c);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    return result;
}
Also used : JSONObject(org.json.JSONObject) Chapter(ar.rulosoft.mimanganu.componentes.Chapter) ArrayList(java.util.ArrayList) JSONException(org.json.JSONException)

Example 29 with Chapter

use of ar.rulosoft.mimanganu.componentes.Chapter in project MiMangaNu by raulhaag.

the class TuMangaOnline method searchForNewChapters.

@Override
public int searchForNewChapters(int id, Context context, boolean fast) throws Exception {
    // TODO FAST
    int returnValue;
    Manga mangaDb = Database.getFullManga(context, id);
    Manga manga = new Manga(mangaDb.getServerId(), mangaDb.getTitle(), mangaDb.getPath(), false);
    manga.setId(mangaDb.getId());
    this.loadMangaInformation(manga, true);
    loadChapters(manga, false, true);
    manga.getChapters().removeAll(mangaDb.getChapters());
    for (Chapter chapter : manga.getChapters()) {
        chapter.setMangaID(mangaDb.getId());
        chapter.setReadStatus(Chapter.NEW);
        Database.addChapter(context, chapter, mangaDb.getId());
    }
    if (manga.getChapters().size() > 0) {
        Database.updateMangaRead(context, mangaDb.getId());
        Database.updateNewMangas(context, mangaDb, manga.getChapters().size());
    }
    returnValue = manga.getChapters().size();
    if (returnValue > 0)
        new CreateGroupByMangaNotificationsTask(manga.getChapters(), manga, context).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    boolean changes = false;
    if (!mangaDb.getAuthor().equals(manga.getAuthor()) && manga.getAuthor().length() > 2) {
        mangaDb.setAuthor(manga.getAuthor());
        changes = true;
    }
    if (!mangaDb.getImages().equals(manga.getImages()) && manga.getImages().length() > 2) {
        mangaDb.setImages(manga.getImages());
        changes = true;
    }
    if (!mangaDb.getSynopsis().equals(manga.getSynopsis()) && manga.getSynopsis().length() > 2) {
        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 (changes)
        Database.updateManga(context, mangaDb, false);
    return returnValue;
}
Also used : Chapter(ar.rulosoft.mimanganu.componentes.Chapter) Manga(ar.rulosoft.mimanganu.componentes.Manga)

Example 30 with Chapter

use of ar.rulosoft.mimanganu.componentes.Chapter in project MiMangaNu by raulhaag.

the class MangaPanda method loadMangaInformation.

@Override
public void loadMangaInformation(Manga manga, boolean forceReload) throws Exception {
    if (manga.getChapters().isEmpty() || forceReload) {
        String data = getNavigatorAndFlushParameters().get(manga.getPath());
        Pattern p = Pattern.compile(PATTERN_FRAG_CHAPTER, Pattern.DOTALL);
        Matcher m = p.matcher(data);
        if (m.find()) {
            manga.getChapters().clear();
            Pattern p1 = Pattern.compile(PATTERN_CHAPTER, Pattern.DOTALL);
            Matcher m1 = p1.matcher(m.group(1));
            while (m1.find()) {
                String web = m1.group(1);
                if (web.matches(PATTERN_CHAPTER_WEB)) {
                    Pattern p2 = Pattern.compile(PATTERN_CHAPTER_WEB, Pattern.DOTALL);
                    Matcher m2 = p2.matcher(web);
                    if (m2.find())
                        web = m2.group(1) + "/" + m2.group(2);
                }
                String chName = m1.group(2);
                if (!m1.group(3).trim().isEmpty()) {
                    chName += " :" + m1.group(3);
                }
                manga.addChapterLast(new Chapter(chName, HOST + web));
            }
        }
        // Summary
        manga.setSynopsis(getFirstMatchDefault("<p>(.+)</p>", data, context.getString(R.string.nodisponible)));
        // Cover
        manga.setImages(getFirstMatchDefault("mangaimg\"><img src=\"([^\"]+)", data, ""));
        // Status
        manga.setFinished(data.contains("<td>Completed</td>"));
        // Genre
        manga.setGenre(getFirstMatchDefault("Genre:</td>[^<]*<td>(.+?)</td>", data, context.getString(R.string.nodisponible)).replace("a> <a", "a>, <a"));
        assert manga.getGenre() != null;
        if (manga.getGenre().isEmpty()) {
            manga.setGenre(context.getString(R.string.nodisponible));
        }
        // Author
        manga.setAuthor(getFirstMatchDefault("Author:</td>[^<]*<td>([^<]+)", data, context.getString(R.string.nodisponible)));
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) Chapter(ar.rulosoft.mimanganu.componentes.Chapter)

Aggregations

Chapter (ar.rulosoft.mimanganu.componentes.Chapter)37 Matcher (java.util.regex.Matcher)27 Pattern (java.util.regex.Pattern)27 ArrayList (java.util.ArrayList)5 Manga (ar.rulosoft.mimanganu.componentes.Manga)4 DialogInterface (android.content.DialogInterface)3 View (android.view.View)3 AlertDialog (android.app.AlertDialog)2 SharedPreferences (android.content.SharedPreferences)2 TextView (android.widget.TextView)2 ServerBase (ar.rulosoft.mimanganu.servers.ServerBase)2 JSONException (org.json.JSONException)2 JSONObject (org.json.JSONObject)2 SuppressLint (android.annotation.SuppressLint)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 SparseBooleanArray (android.util.SparseBooleanArray)1 ActionMode (android.view.ActionMode)1 LayoutInflater (android.view.LayoutInflater)1 Menu (android.view.Menu)1