Search in sources :

Example 31 with Chapter

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

the class MangaRawOnline method loadMangaInformation.

@Override
public void loadMangaInformation(Manga manga, boolean forceReload) throws Exception {
    if (manga.getChapters().isEmpty() || forceReload) {
        String data = getNavigatorAndFlushParameters().get(HOST + manga.getPath());
        manga.setSynopsis(getFirstMatchDefault("<h5><strong>Summary</strong></h5>\\s*<p>(.+?)</p>", data, context.getString(R.string.nodisponible)));
        manga.setAuthor(getFirstMatchDefault("<dt>Author\\(s\\)</dt>\\s+<dd>([\\s\\S]+?)</dd>", data, context.getString(R.string.nodisponible)).replaceAll(" <a href=\".+?\">(.+?)</a>", "$1,"));
        if (data.contains("<span class=\"label label-success\">Ongoing</span>")) {
            manga.setFinished(false);
        } else {
            manga.setFinished(true);
        }
        manga.setGenre(getFirstMatchDefault("<dt>Categories</dt>\\s+<dd>([\\s\\S]+?)</dd>", data, context.getString(R.string.nodisponible)).replaceAll(" <a href=\".+?\">(.+?)</a>", "$1"));
        manga.setImages(getFirstMatchDefault("class=\"img-responsive\" src='(.+?)'", data, ""));
        // chapter
        Pattern p = Pattern.compile("<h5 class=\"chapter-title-rtl\">\\s*<a href=\"https?://mangaraw.online(.+?)\">(.+?)<", Pattern.DOTALL);
        Matcher m = p.matcher(data);
        while (m.find()) {
            manga.addChapterFirst(new Chapter(m.group(2), m.group(1)));
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) Chapter(ar.rulosoft.mimanganu.componentes.Chapter)

Example 32 with Chapter

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

the class Mangapedia method loadMangaInformation.

@Override
public void loadMangaInformation(Manga manga, boolean forceReload) throws Exception {
    if (manga.getChapters().isEmpty() || forceReload) {
        String data = getNavigatorAndFlushParameters().get(manga.getPath());
        // Cover
        if (manga.getImages() == null) {
            manga.setImages(getFirstMatchDefault("<div id=\"mangaImage\">\\s*<img src=\"([^\"]+)\"", data, "") + "|" + HOST + "/mangas/");
        }
        // Author
        manga.setAuthor(getFirstMatchDefault("Auteur : (.+?)</div>", data, context.getString(R.string.nodisponible)));
        // Genre
        manga.setGenre(getFirstMatchDefault("Sous-genres : (.+?)<\\/div>", data, context.getString(R.string.nodisponible)));
        // Summary
        manga.setSynopsis(getFirstMatchDefault("Synopsis : (.+?)<\\/div>", data, context.getString(R.string.nodisponible)));
        // Status
        manga.setFinished(!getFirstMatchDefault("Statut : (.+?)<\\/div>", data, "en cours").contains("en cours"));
        // Chapters
        Pattern pattern = Pattern.compile("<a href=\"(http[s]*://mangapedia.fr/lel[^\"]+).+?\"nameChapter\">(.+?)<", Pattern.DOTALL);
        Matcher matcher = pattern.matcher(data);
        while (matcher.find()) {
            manga.addChapterFirst(new Chapter(matcher.group(2), matcher.group(1)));
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) Chapter(ar.rulosoft.mimanganu.componentes.Chapter)

Example 33 with Chapter

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

the class BatoTo method loadMangaInformation.

@Override
public void loadMangaInformation(Manga manga, boolean forceReload) throws Exception {
    try {
        if (manga.getChapters().size() == 0 || forceReload) {
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
            String user = prefs.getString("username_" + getServerName(), "");
            String password = prefs.getString("dwp_" + getServerName(), "");
            String data = getNavigatorAndFlushParameters().get(manga.getPath(), new BatotoLoginInterceptor(user, password));
            String synopsis = getFirstMatchDefault("Description:</td>\\s+<td>(.*?)</td>", data, context.getString(R.string.nodisponible));
            manga.setSynopsis(Util.getInstance().fromHtml(synopsis).toString());
            manga.setImages(HOST + getFirstMatchDefault("(\\/forums\\/upload.+?)\"", data, ""));
            if (manga.getImages().equals(HOST))
                manga.setImages("");
            manga.setAuthor(getFirstMatchDefault("search\\?artist_name=.+?>([^<]+)", data, "n/a"));
            manga.setGenre(getFirstMatchDefault("Genres:</td>\\s+<td>([\\s\\S]+?)<img[^>]+?alt=.edit", data, "").replaceAll("<.*?>", "").replaceAll(",[\\s]*", ",").trim());
            manga.setFinished(!getFirstMatchDefault("Status:<\\/td>\\s+<td>([^<]+)", data, "").contains("Ongoing"));
            ArrayList<Chapter> chapters = new ArrayList<>();
            Pattern pattern = Pattern.compile("<a href=\"([^\"]+)\" title=\"[^\"]+\">.+?>([^<]+).+?title=\"(.+?)\".+?<a[^>]+>([^<]+)", Pattern.DOTALL);
            data = getFirstMatchDefault("ipb_table chapters_list\"([\\s\\S]+?)</table", data, "");
            Matcher matcher = pattern.matcher(data);
            String lang_selection, lang = "";
            lang_selection = prefs.getString("batoto_lang_selection", "Automatic");
            if (lang_selection.equals("Automatic"))
                lang = Locale.getDefault().getDisplayLanguage(new Locale("eng"));
            else if (lang_selection.equals("Custom"))
                lang = prefs.getString("batoto_custom_lang", "");
            else
                lang = lang_selection;
            while (matcher.find()) {
                if (!lang_selection.equals("All") && !lang.isEmpty()) {
                    if (matcher.group(3).contains(lang))
                        chapters.add(0, new Chapter("(" + matcher.group(3) + ") " + matcher.group(2) + " [" + matcher.group(4) + "]", matcher.group(1)));
                } else if (lang_selection.equals("All"))
                    chapters.add(0, new Chapter("(" + matcher.group(3) + ") " + matcher.group(2) + " [" + matcher.group(4) + "]", matcher.group(1)));
            }
            manga.setChapters(chapters);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Locale(java.util.Locale) Pattern(java.util.regex.Pattern) SharedPreferences(android.content.SharedPreferences) Matcher(java.util.regex.Matcher) Chapter(ar.rulosoft.mimanganu.componentes.Chapter) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 34 with Chapter

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

the class BatoToEs method loadMangaInformation.

@Override
public void loadMangaInformation(Manga manga, boolean forceReload) throws Exception {
    if (manga.getChapters().isEmpty() || forceReload) {
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        String user = prefs.getString("username_" + getServerName(), "");
        String password = prefs.getString("dwp_" + getServerName(), "");
        String data = getNavigatorAndFlushParameters().get(manga.getPath(), new BatotoLoginInterceptor(user, password));
        // Summary
        manga.setSynopsis(getFirstMatchDefault("Description:</td>\\s+<td>(.*?)</td>", data, context.getString(R.string.nodisponible)));
        // Cover
        manga.setImages(HOST + getFirstMatchDefault("<img src=\"(/forums/upload.+?)\"", data, ""));
        if (manga.getImages().equals(HOST))
            manga.setImages("");
        // Author
        manga.setAuthor(getFirstMatchDefault("search\\?artist_name=.+?>([^<]+)", data, context.getString(R.string.nodisponible)));
        // Genre
        manga.setGenre(getFirstMatchDefault("Genres:</td>\\s+<td>([\\s\\S]+?)<img[^>]+?alt=.edit", data, context.getString(R.string.nodisponible)));
        // Status
        manga.setFinished(!getFirstMatchDefault("Status:<\\/td>\\s+<td>([^<]+)", data, "").contains("Ongoing"));
        // Chapters
        Pattern pattern = Pattern.compile("<a href=\"([^\"]+)\" title=\"[^\"]+\">.+?>([^<]+).+?title=\"(.+?)\".+?<a[^>]+>([^<]+)", Pattern.DOTALL);
        data = getFirstMatchDefault("ipb_table chapters_list\"([\\s\\S]+?)</table", data, "");
        Matcher matcher = pattern.matcher(data);
        String lang = "Spanish";
        while (matcher.find()) {
            if (matcher.group(3).contains(lang)) {
                manga.addChapterFirst(new Chapter("(" + matcher.group(3) + ") " + matcher.group(2) + " [" + matcher.group(4) + "]", matcher.group(1)));
            }
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) SharedPreferences(android.content.SharedPreferences) Matcher(java.util.regex.Matcher) Chapter(ar.rulosoft.mimanganu.componentes.Chapter)

Example 35 with Chapter

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

the class DesuMe method loadMangaInformation.

@Override
public void loadMangaInformation(Manga manga, boolean forceReload) throws Exception {
    if (manga.getChapters().isEmpty() || forceReload) {
        String data = getNavigatorAndFlushParameters().get(HOST + manga.getPath());
        // cover image
        manga.setImages(HOST + getFirstMatchDefault("src=\"(/data/manga/covers/[^\"]+)", data, ""));
        // summary
        manga.setSynopsis(getFirstMatchDefault("class=\"prgrph\">([^<]+)", data, context.getString(R.string.nodisponible)));
        // ongoing or completed
        manga.setFinished(!data.contains("b-anime_status_tag ongoing"));
        // author - n/a
        manga.setAuthor(context.getString(R.string.nodisponible));
        // genre
        manga.setGenre(getFirstMatchDefault("(<a class=\"tag Tooltip\".+?)</ul>", data, context.getString(R.string.nodisponible)).replace("</li> <li>", ", "));
        // chapter
        Pattern p = Pattern.compile("<h4><a href=\"(/manga/[^\"]+).+?title=\"([^\"]+)", Pattern.DOTALL);
        Matcher m = p.matcher(data);
        while (m.find()) {
            // remove 'volume' to ease sorting after chapters
            String title = m.group(2).replaceFirst("^Том \\d+.\\s+", "");
            manga.addChapterFirst(new Chapter(title, m.group(1)));
        }
    }
}
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