Search in sources :

Example 11 with Chapter

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

the class MangaKawaii method loadMangaInformation.

@Override
public void loadMangaInformation(Manga manga, boolean forceReload) throws Exception {
    if (manga.getChapters().isEmpty() || forceReload) {
        String source = getNavigatorAndFlushParameters().get(manga.getPath());
        // Cover
        if (manga.getImages() == null || manga.getImages().isEmpty()) {
            String img = getFirstMatchDefault("src='(https://www.mangakawaii.com/uploads/manga/[^\"]+?)'", source, "");
            manga.setImages(img);
        }
        // Summary
        manga.setSynopsis(getFirstMatchDefault("id=\"synopsis\">[\\s]*<p>(.+?)</p>", source, context.getString(R.string.nodisponible)));
        // Status
        manga.setFinished(!getFirstMatchDefault("Statut(.+?)</span>", source, "").contains("En Cours"));
        // Author
        manga.setAuthor(getFirstMatchDefault("author/.+?\">(.+?)</a>", source, context.getString(R.string.nodisponible)));
        // Genre
        manga.setGenre(getFirstMatchDefault("Genres</span>(.+?)</span>", source, context.getString(R.string.nodisponible)));
        // Chapters
        Pattern p = Pattern.compile("href=\"(https://www\\.mangakawaii\\.com/manga/[^\"]+?)\">([^\"]+?)</a>", Pattern.DOTALL);
        Matcher matcher = p.matcher(source);
        ArrayList<String> tmpChapterList = new ArrayList<>();
        while (matcher.find()) {
            if (!tmpChapterList.contains(matcher.group(1))) {
                manga.addChapterFirst(new Chapter(matcher.group(2), matcher.group(1)));
                tmpChapterList.add(matcher.group(1));
            }
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList) Chapter(ar.rulosoft.mimanganu.componentes.Chapter)

Example 12 with Chapter

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

the class MangaStream method loadMangaInformation.

@Override
public void loadMangaInformation(Manga manga, boolean forceReload) throws Exception {
    if (manga.getChapters().isEmpty() || forceReload) {
        String source = getNavigatorAndFlushParameters().get(manga.getPath());
        // no Summary
        manga.setSynopsis(context.getString(R.string.nodisponible));
        // no Status
        manga.setFinished(true);
        // no Authors
        manga.setAuthor(context.getString(R.string.nodisponible));
        // no Genres
        manga.setGenre(context.getString(R.string.nodisponible));
        // Chapters
        Pattern p = Pattern.compile(PATTERN_CHAPTER, Pattern.DOTALL);
        Matcher matcher = p.matcher(source);
        while (matcher.find()) {
            manga.addChapterFirst(new Chapter(matcher.group(2), HOST + matcher.group(1)));
        }
        // Cover - use first image of latest chapter (if present)
        ArrayList<Chapter> chapters = manga.getChapters();
        manga.setImages("");
        if (!chapters.isEmpty()) {
            source = getNavigatorAndFlushParameters().get(chapters.get(chapters.size() - 1).getPath());
            String image = getFirstMatchDefault(PATTERN_IMAGE, source, "");
            if (!image.isEmpty()) {
                manga.setImages("http:" + image);
            }
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) Chapter(ar.rulosoft.mimanganu.componentes.Chapter)

Example 13 with Chapter

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

the class MangaTown method loadChapters.

@Override
public void loadChapters(Manga manga, boolean forceReload) throws Exception {
    if (manga.getChapters().isEmpty() || forceReload) {
        String data = getNavigatorAndFlushParameters().get(manga.getPath());
        // cover image
        manga.setImages(getFirstMatchDefault(PATTERN_COVER, data, ""));
        // summary
        manga.setSynopsis(getFirstMatchDefault(PATTERN_SUMMARY, data, context.getString(R.string.nodisponible)));
        // ongoing or completed
        manga.setFinished(data.contains(PATTERN_COMPLETED));
        // author
        manga.setAuthor(getFirstMatchDefault(PATTERN_AUTHOR, data, context.getString(R.string.nodisponible)));
        // genre
        manga.setGenre(getFirstMatchDefault(PATTERN_GENRE, data, context.getString(R.string.nodisponible)));
        // chapter
        Pattern p = Pattern.compile(PATTERN_CHAPTER, Pattern.DOTALL);
        Matcher m = p.matcher(data);
        while (m.find()) {
            manga.addChapterFirst(new Chapter(m.group(2), "http:" + m.group(1)));
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) Chapter(ar.rulosoft.mimanganu.componentes.Chapter)

Example 14 with Chapter

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

the class MyMangaIo method loadChapters.

@Override
public void loadChapters(Manga manga, boolean forceReload) throws Exception {
    if (manga.getChapters().isEmpty() || forceReload) {
        String data = getNavigatorWithNeededHeader().get(manga.getPath());
        // Cover
        manga.setImages(HOST + getFirstMatchDefault("<img src=\"(images/mangas_thumb/.+?)\"", data, ""));
        // Summary
        manga.setSynopsis(getFirstMatchDefault("Synopsis</h1>\\s+<p><[^>]+>(.+?)</p>", data, context.getString(R.string.nodisponible)));
        // Status
        manga.setFinished(!data.contains("en cours</a>"));
        // Author
        manga.setAuthor(getFirstMatchDefault("Auteur\\s*:\\s*(.+?)</tr>", data, context.getString(R.string.nodisponible)));
        // Genre
        manga.setGenre(getFirstMatchDefault("Sous-Genres\\s*:\\s*(.+?)</tr>", data, context.getString(R.string.nodisponible)));
        // Chapter
        Pattern p = Pattern.compile("href=\"([^\"]+)\"[^>]+title=\"Li.+?<span class=\"chapter\">(.+?)<", Pattern.DOTALL);
        Matcher m = p.matcher(data);
        while (m.find()) {
            manga.addChapterFirst(new Chapter(m.group(2).trim(), m.group(1)));
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) Chapter(ar.rulosoft.mimanganu.componentes.Chapter)

Example 15 with Chapter

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

the class FromFolder method loadChapters.

@Override
public void loadChapters(Manga manga, boolean forceReload) throws Exception {
    manga.setImages(manga.getPath() + "cover.jpg");
    ArrayList<String> folders = Util.getInstance().dirList(manga.getPath());
    ArrayList<Chapter> chapters = new ArrayList<>();
    // remove "."
    folders.remove(0);
    for (String folder : folders) {
        Chapter chapter = new Chapter(folder, manga.getPath() + folder + "/");
        chapter.setDownloaded(true);
        chapters.add(chapter);
    }
    Chapter.Comparators.setManga_title(manga.getTitle());
    Collections.sort(chapters, Chapter.Comparators.NUMBERS_ASC);
    manga.setChapters(chapters);
    manga.setAuthor(context.getString(R.string.nodisponible));
    manga.setGenre(context.getString(R.string.nodisponible));
    manga.setSynopsis(context.getString(R.string.nodisponible));
    manga.setFinished(true);
}
Also used : Chapter(ar.rulosoft.mimanganu.componentes.Chapter) ArrayList(java.util.ArrayList)

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