Search in sources :

Example 16 with Navigator

use of ar.rulosoft.navegadores.Navigator in project MiMangaNu by raulhaag.

the class Mangapedia method getMangasFiltered.

@Override
public ArrayList<Manga> getMangasFiltered(int[][] filters, int pageNumber) throws Exception {
    String web = HOST + "/project_code/script/moreMangas.php";
    if (pageNumber == 1) {
        web = HOST + "/project_code/script/search.php";
    }
    Navigator nav = getNavigatorAndFlushParameters();
    String boundary = Navigator.getNewBoundary();
    nav.addHeader("Content-Type", "multipart/form-data; boundary=" + boundary);
    nav.addHeader("X-Requested-With", "XMLHttpRequest");
    MultipartBody.Builder mBodyBuilder = new MultipartBody.Builder(boundary).setType(MultipartBody.FORM);
    mBodyBuilder.addFormDataPart("artist", "");
    mBodyBuilder.addFormDataPart("searchType", "advance");
    mBodyBuilder.addFormDataPart("pageNumber", "" + pageNumber);
    mBodyBuilder.addFormDataPart("searchTerm", "");
    mBodyBuilder.addFormDataPart("searchByLetter", "");
    for (int i = 0; i < valDemographic.length; i++) {
        if (Util.getInstance().contains(filters[0], i)) {
            mBodyBuilder.addFormDataPart(valDemographic[i], "1");
        } else {
            mBodyBuilder.addFormDataPart(valDemographic[i], "0");
        }
    }
    for (int i = 0; i < valGenre.length; i++) {
        if (Util.getInstance().contains(filters[1], i)) {
            mBodyBuilder.addFormDataPart(valGenre[i], "1");
        } else {
            mBodyBuilder.addFormDataPart(valGenre[i], "0");
        }
    }
    for (int i = 0; i < valType.length; i++) {
        if (Util.getInstance().contains(filters[2], i)) {
            mBodyBuilder.addFormDataPart(valType[i], "1");
        } else {
            mBodyBuilder.addFormDataPart(valType[i], "0");
        }
    }
    mBodyBuilder.addFormDataPart("sortBy", valSortBy[filters[3][0]]);
    mBodyBuilder.addFormDataPart("sortOrder", valSortOrder[filters[4][0]]);
    return getMangasString(nav.post(web, mBodyBuilder.build()));
}
Also used : Navigator(ar.rulosoft.navegadores.Navigator) MultipartBody(okhttp3.MultipartBody)

Example 17 with Navigator

use of ar.rulosoft.navegadores.Navigator in project MiMangaNu by raulhaag.

the class MyMangaIo method getNavigatorWithNeededHeader.

private Navigator getNavigatorWithNeededHeader() throws Exception {
    Navigator nav = Navigator.getInstance();
    nav.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
    return nav;
}
Also used : Navigator(ar.rulosoft.navegadores.Navigator)

Example 18 with Navigator

use of ar.rulosoft.navegadores.Navigator in project MiMangaNu by raulhaag.

the class BatoTo method testLogin.

// just log in batoto to store the cookie if all ok
@Override
public boolean testLogin(String user, String password) throws Exception {
    Navigator nav = getNavigatorAndFlushParameters();
    CookieJar ccj = nav.getHttpClient().cookieJar();
    VolatileCookieJar cj = new VolatileCookieJar();
    nav.setCookieJar(cj);
    String data = nav.get(HOST + "/forums/index.php?app=core&amp;module=global&amp;section=login");
    HashMap<String, String> params = Navigator.getFormParamsFromSource(data);
    nav = getNavigatorAndFlushParameters();
    nav.addPost("auth_key", params.get("auth_key"));
    nav.addPost("ips_password", password);
    nav.addPost("ips_username", user);
    nav.addPost("referer", "https://bato.to/forums/");
    nav.addPost("rememberMe", "1");
    nav.post(HOST + "/forums/index.php?app=core&module=global&section=login&do=process");
    List<Cookie> cookies = Navigator.getCookieJar().loadForRequest(HttpUrl.parse("https://bato.to"));
    nav.setCookieJar(ccj);
    return cj.contain("member_id");
}
Also used : Cookie(okhttp3.Cookie) Navigator(ar.rulosoft.navegadores.Navigator) VolatileCookieJar(ar.rulosoft.navegadores.VolatileCookieJar) CookieJar(okhttp3.CookieJar) VolatileCookieJar(ar.rulosoft.navegadores.VolatileCookieJar)

Example 19 with Navigator

use of ar.rulosoft.navegadores.Navigator in project MiMangaNu by raulhaag.

the class DesuMe 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");
    nav.addPost("q", term);
    nav.addPost("_xfResponseType", "json");
    String data = nav.post(HOST + "/manga/find");
    try {
        JSONObject result = new JSONObject(data).getJSONObject("results");
        Iterator<String> it = result.keys();
        while (it.hasNext()) {
            String title = it.next();
            String id = getFirstMatch("/(\\d+)\\.jpg", result.getJSONObject(title).getString("avatar"), context.getString(R.string.server_failed_locate_manga_url));
            String web = "/manga/" + title.replace(" ", "-").toLowerCase() + "." + id + "/";
            mangas.add(new Manga(getServerID(), title, web, false));
        }
    } catch (JSONException e) {
    // do nothing
    }
    return mangas;
}
Also used : JSONObject(org.json.JSONObject) Navigator(ar.rulosoft.navegadores.Navigator) ArrayList(java.util.ArrayList) JSONException(org.json.JSONException) Manga(ar.rulosoft.mimanganu.componentes.Manga)

Example 20 with Navigator

use of ar.rulosoft.navegadores.Navigator in project MiMangaNu by raulhaag.

the class KissManga method search.

@Override
public ArrayList<Manga> search(String term) throws Exception {
    // make use of AdvanceSearch, more data is then needed
    Navigator nav = getNavigatorAndFlushParameters();
    // do not hide Doujinshi in result
    nav.addHeader("Cookie", "vns_doujinshi=1; ");
    nav.addPost("keyword", URLEncoder.encode(term, "UTF-8"));
    nav.addPost("type", "Manga");
    String source = nav.post(HOST + "/Search/SearchSuggest");
    source = source.replaceAll("<\\*span>", "");
    ArrayList<Manga> searchList = new ArrayList<>();
    Pattern p = Pattern.compile(PATTERN_SEARCH, Pattern.DOTALL);
    Matcher m = p.matcher(source);
    while (m.find()) {
        searchList.add(new Manga(getServerID(), m.group(2), m.group(1), false));
    }
    return searchList;
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) Navigator(ar.rulosoft.navegadores.Navigator) ArrayList(java.util.ArrayList) Manga(ar.rulosoft.mimanganu.componentes.Manga)

Aggregations

Navigator (ar.rulosoft.navegadores.Navigator)21 ArrayList (java.util.ArrayList)6 JSONObject (org.json.JSONObject)6 Manga (ar.rulosoft.mimanganu.componentes.Manga)5 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 RequestBody (okhttp3.RequestBody)2 JSONArray (org.json.JSONArray)2 JSONException (org.json.JSONException)2 Bitmap (android.graphics.Bitmap)1 LargeTest (android.support.test.filters.LargeTest)1 Chapter (ar.rulosoft.mimanganu.componentes.Chapter)1 VolatileCookieJar (ar.rulosoft.navegadores.VolatileCookieJar)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Cookie (okhttp3.Cookie)1 CookieJar (okhttp3.CookieJar)1 MultipartBody (okhttp3.MultipartBody)1 Test (org.junit.Test)1