Skip to content
This repository has been archived by the owner on Jul 23, 2020. It is now read-only.

Commit

Permalink
fix tmo fix #441 fix #442
Browse files Browse the repository at this point in the history
  • Loading branch information
raulhaag committed Sep 26, 2017
1 parent a0ad38a commit 59e2390
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
26 changes: 21 additions & 5 deletions app/src/androidTest/java/ar/rulosoft/mimanganu/testNine.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,21 @@ public void testImages() throws Exception {
Navigator nav = Navigator.navigator;
nav.addHeader("Accept-Language", "es-AR,es;q=0.8,en-US;q=0.5,en;q=0.3");
nav.addHeader("Accept-Encoding", "deflate");
String boundary = Navigator.getNewBoundary();
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);
Expand All @@ -68,18 +82,20 @@ public void testImages() throws Exception {
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));//*/
Log.e("Body", bodyToString(request));//
//RequestBody body = RequestBody
// .create(MediaType.parse("multipart/form-data; boundary"),mBodyBuilder.build());
.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);
Log.e("Aaaaaaaaaaaa", data);/*/


}

}
19 changes: 13 additions & 6 deletions app/src/main/java/ar/rulosoft/mimanganu/servers/TuMangaOnline.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import ar.rulosoft.mimanganu.componentes.Database;
import ar.rulosoft.mimanganu.componentes.Manga;
import ar.rulosoft.mimanganu.componentes.ServerFilter;
import ar.rulosoft.navegadores.Navigator;

/**
* Created by Raul on 05/04/2016.
Expand Down Expand Up @@ -91,7 +92,7 @@ public ArrayList<Manga> getMangas() throws Exception {

@Override
public ArrayList<Manga> search(String term) throws Exception {
JSONObject jsonObject = new JSONObject(getNavigatorAndFlushParameters().get("http://www.tumangaonline.com/api/v1/mangas?categorias=%5B%5D&generos=%5B%5D&itemsPerPage=20&nameSearch=" + URLEncoder.encode(term, "UTF-8") + "&page=1&puntuacion=0&searchBy=nombre&sortDir=asc&sortedBy=nombre"));
JSONObject jsonObject = new JSONObject(getNavWithNeededHeaders().get("http://www.tumangaonline.com/api/v1/mangas?categorias=%5B%5D&generos=%5B%5D&itemsPerPage=20&nameSearch=" + URLEncoder.encode(term, "UTF-8") + "&page=1&puntuacion=0&searchBy=nombre&sortDir=asc&sortedBy=nombre"));
return getMangasJsonArray(jsonObject.getJSONArray("data"));
}

Expand All @@ -102,15 +103,15 @@ public void loadChapters(Manga manga, boolean forceReload) throws Exception {

public void loadChapters(Manga manga, boolean forceReload, boolean last) throws Exception {
ArrayList<Chapter> result = new ArrayList<>();
String data = getNavigatorAndFlushParameters().get("http://www.tumangaonline.com/api/v1/mangas/" + manga.getPath() + "/capitulos?page=" + 1 + "&tomo=-1");
String data = getNavWithNeededHeaders().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 {
data = getNavigatorAndFlushParameters().get("http://www.tumangaonline.com/api/v1/mangas/" + manga.getPath() + "/capitulos?page=" + i + "&tomo=-1");
data = getNavWithNeededHeaders().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()));
Expand Down Expand Up @@ -141,7 +142,7 @@ private ArrayList<Chapter> getChaptersJsonArray(JSONArray jsonArray, String mid)

@Override
public void loadMangaInformation(Manga manga, boolean forceReload) throws Exception {
JSONObject object = new JSONObject(getNavigatorAndFlushParameters().get("http://www.tumangaonline.com/api/v1/mangas/" + manga.getPath()));
JSONObject object = new JSONObject(getNavWithNeededHeaders().get("http://www.tumangaonline.com/api/v1/mangas/" + manga.getPath()));
manga.setImages("http://img1.tumangaonline.com/" + object.getString("imageUrl"));
manga.setSynopsis(object.getJSONObject("info").getString("sinopsis"));
if (object.getJSONArray("autores").length() != 0) {
Expand Down Expand Up @@ -310,12 +311,18 @@ public ArrayList<Manga> getMangasFiltered(int[][] filters, int pageNumber) throw
estadoV[filters[3][0]] + "&generos=%5B" + gens + "%5D&itemsPerPage=20&page=" +
pageNumber + "&puntuacion=0&searchBy=nombre" + sortByValues[filters[5][0]] +
"&tipo=" + typeV[filters[0][0]];

JSONObject jsonObject = new JSONObject(getNavigatorAndFlushParameters().get(web));
JSONObject jsonObject = new JSONObject(getNavWithNeededHeaders().get(web));
lastPage = jsonObject.getInt("last_page");
return getMangasJsonArray(jsonObject.getJSONArray("data"));
} else {
return new ArrayList<>();
}
}

private Navigator getNavWithNeededHeaders() {
Navigator nav = getNavigatorAndFlushParameters();
nav.addHeader("Cache-mode","no-cache");
nav.addHeader("Referer","https://www.tumangaonline.com/biblioteca");
return nav;
}
}

0 comments on commit 59e2390

Please sign in to comment.