Search in sources :

Example 1 with Navigator

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

the class testNine method testImages.

@Test
public void testImages() throws Exception {
    Navigator nav = Navigator.getInstance();
    nav.addHeader("Accept-Language", "es-AR,es;q=0.8,en-US;q=0.5,en;q=0.3");
    nav.addHeader("Accept-Encoding", "deflate");
    nav.addHeader("Accept", "application/json, text/plain, */*");
    nav.addHeader("Accept-Encoding", "gzip, deflate, br");
    nav.addHeader("Accept-Language", "es-AR,es;q=0.8,en-US;q=0.5,en;q=0.3");
    nav.addHeader("Cache-mode", "no-cache");
    // nav.addHeader("Connection","keep-alive");
    nav.addHeader("Cookie", "__cfduid=d7025d17b59e189d890c2cc05b9feb5c31505483555; tmoSession=eyJpdiI6ImZXZUlPZjVWOGNKS2VCRkVcL1I3XC9iZz09IiwidmFsdWUiOiJ0MEhzdXF0XC93YkFvSkJlUnVvZ3hnN011WWtGUzdEdnJrY1ZOakhnTVRBTGJQZk91NmphTTFaNDhhbUozUnZnRmJndGtBdkNHZlFsTTFZT2RvSWlBSGc9PSIsIm1hYyI6ImMxODZmYmRkNTJiZTQ4YjUwZGQ0MTBkYTRlOWExNmU1NjM3YWFkMTA2MGJjNGJhMzMwOGY3NjY0YmFhMDIyMmIifQ%3D%3D");
    // nav.addHeader("Host","www.tumangaonline.com");
    nav.addHeader("Referer", "https://www.tumangaonline.com/biblioteca");
    // nav.addHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0");
    // nav.addHeader("X-Requested-With","XMLHttpRequest");
    Log.e("respuesta", nav.get("https://www.tumangaonline.com/api/v1/mangas/2968/capitulos?page=2&tomo=-1"));
/*        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("categoryID[1]","1");
        mBodyBuilder.addFormDataPart("sortBy","0");
        mBodyBuilder.addFormDataPart("sortOrder","0");
        mBodyBuilder.addFormDataPart("searchType","advance");
        mBodyBuilder.addFormDataPart("pageNumber","1");
        mBodyBuilder.addFormDataPart("searchTerm","");
        mBodyBuilder.addFormDataPart("searchByLetter","");
        for(int i = 0; i < 25; i++){
            mBodyBuilder.addFormDataPart("categoryID["+i+"]","0");
        }
        for(int i = 0; i < 10; i++){
            mBodyBuilder.addFormDataPart("typeID["+i+"]","0");
        }
        for(int i = 0; i < 6; i++){
            mBodyBuilder.addFormDataPart("typeBookID["+i+"]","0");
        }

        Request request = new Request.Builder()
                .url("http://mangapedia.fr/project_code/script/search.php")
                .method("POST", mBodyBuilder.build())
                .build();
        Log.e("Body", bodyToString(request));//
        //RequestBody body = RequestBody
               .create(MediaType.parse("multipart/form-data; boundary"),mBodyBuilder.build());

        String data = nav.post("http://mangapedia.fr/project_code/script/search.php",
                mBodyBuilder.build());
        Log.e("Aaaaaaaaaaaa", data);/*/
}
Also used : Navigator(ar.rulosoft.navegadores.Navigator) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest)

Example 2 with Navigator

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

the class TestServersCommon method testLoadImage.

private void testLoadImage(String image) throws Exception {
    String[] parts = image.split("\\|");
    logMessage(String.format(Locale.getDefault(), "[IMG] %s", parts[0]));
    assertNotNull(getContext(), image);
    assertFalse(getContext(), image.isEmpty());
    if (parts.length == 1)
        assertTrue(getContext(), (image.split("//", -1).length - 1) <= 1);
    else
        assertTrue(getContext(), (image.split("//", -1).length - 1) <= 2);
    // additional test for NineManga servers to detect broken hotlinking
    assertFalse(getContext("NineManga: hotlink detection - server delivers bogus image link"), image.equals("http://es.taadd.com/files/img/57ead05682694a7c026f99ad14abb8c1.jpg"));
    // check if the image loaded has at least 1kB (assume proper content)
    Navigator nav = Navigator.getInstance();
    if (parts.length > 1) {
        nav.addHeader("Referer", parts[1]);
    }
    image = nav.getAndReturnResponseCodeOnFailure(parts[0]);
    assertTrue(getContext("[CONTENT] " + image), image.length() > 1024);
}
Also used : Navigator(ar.rulosoft.navegadores.Navigator)

Example 3 with Navigator

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

the class NineManga method getNavigatorWithNeededHeader.

/**
 * Helper function to set up the <code>Navigator</code> with additional headers.
 * Some servers need additional information to be added to the request header in order to work.
 * This function provides such an object.
 *
 * @return a <code>Navigator</code> object with extended headers
 * @throws Exception if an error occurred
 */
private Navigator getNavigatorWithNeededHeader() throws Exception {
    if (!cookieInit) {
        generateNeededCookie();
    }
    Navigator nav = Navigator.getInstance();
    nav.addHeader("Accept-Language", "es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3");
    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 4 with Navigator

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

the class ReadComicOnline method search.

@Override
public ArrayList<Manga> search(String term) throws Exception {
    Navigator nav = getNavigatorAndFlushParameters();
    nav.addPost("keyword", URLEncoder.encode(term, "UTF-8"));
    String source = nav.post(HOST + "/Search/Comic");
    ArrayList<Manga> searchList;
    Pattern p = Pattern.compile(PATTERN_SEARCH, Pattern.DOTALL);
    Matcher m = p.matcher(source);
    if (m.find()) {
        searchList = new ArrayList<>();
        searchList.add(new Manga(READCOMICONLINE, m.group(2), m.group(1), m.group().contains("Status:</span>&nbsp;Completed")));
    } else {
        searchList = getMangasSource(source);
    }
    return searchList;
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) Navigator(ar.rulosoft.navegadores.Navigator) Manga(ar.rulosoft.mimanganu.componentes.Manga)

Example 5 with Navigator

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

the class TuMangaOnline method loadChapters.

@SuppressWarnings("unused")
public void loadChapters(Manga manga, boolean forceReload, boolean last) throws Exception {
    ArrayList<Chapter> result = new ArrayList<>();
    Navigator nav = getNavigatorAndFlushParameters();
    nav.addHeader("Cache-mode", "no-cache");
    nav.addHeader("Referer", "http://www.tumangaonline.com/biblioteca/mangas/" + manga.getPath() + "/" + URLEncoder.encode(manga.getTitle(), "UTF-8"));
    String data = nav.get("http://www.tumangaonline.com/api/v1/mangas/" + manga.getPath() + "/capitulos?page=" + 1 + "&tomo=-1");
    if (data != null && data.length() > 3) {
        JSONObject object = new JSONObject(data);
        int last_page = object.getInt("last_page");
        result.addAll(0, getChaptersJsonArray(object.getJSONArray("data"), manga.getPath()));
        if (!last)
            for (int i = 2; i <= last_page; i++) {
                try {
                    nav = getNavigatorAndFlushParameters();
                    nav.addHeader("Cache-mode", "no-cache");
                    nav.addHeader("Referer", "http://www.tumangaonline.com/biblioteca/mangas/" + manga.getPath() + "/" + URLEncoder.encode(manga.getTitle(), "UTF-8"));
                    data = nav.get("http://www.tumangaonline.com/api/v1/mangas/" + manga.getPath() + "/capitulos?page=" + i + "&tomo=-1");
                    if (data != null && data.length() > 3) {
                        object = new JSONObject(data);
                        result.addAll(0, getChaptersJsonArray(object.getJSONArray("data"), manga.getPath()));
                    }
                } catch (Exception ignore) {
                }
            }
    }
    manga.setChapters(result);
}
Also used : JSONObject(org.json.JSONObject) Navigator(ar.rulosoft.navegadores.Navigator) Chapter(ar.rulosoft.mimanganu.componentes.Chapter) ArrayList(java.util.ArrayList) JSONException(org.json.JSONException)

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