use of com.amazonaws.services.s3.Headers in project EhViewer by seven332.
the class EhEngine method downloadArchive.
public static Void downloadArchive(@Nullable EhClient.Task task, OkHttpClient okHttpClient, long gid, String token, String or, String res) throws Exception {
if (or == null || or.length() == 0) {
throw new EhException("Invalid form param or: " + or);
}
if (res == null || res.length() == 0) {
throw new EhException("Invalid res: " + res);
}
FormBody.Builder builder = new FormBody.Builder();
builder.add("hathdl_xres", res);
String url = EhUrl.getDownloadArchive(gid, token, or);
Log.d(TAG, url);
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).post(builder.build()).build();
Call call = okHttpClient.newCall(request);
// Put call
if (null != task) {
task.setCall(call);
}
String body = null;
Headers headers = null;
int code = -1;
try {
Response response = call.execute();
code = response.code();
headers = response.headers();
body = response.body().string();
throwException(call, code, headers, body, null);
} catch (Exception e) {
throwException(call, code, headers, body, e);
throw e;
}
Matcher m = PATTERN_NEED_HATH_CLIENT.matcher(body);
if (m.find()) {
throw new NoHAtHClientException("No H@H client");
}
return null;
}
use of com.amazonaws.services.s3.Headers in project EhViewer by seven332.
the class EhEngine method getPreviewSet.
public static Pair<PreviewSet, Integer> getPreviewSet(@Nullable EhClient.Task task, OkHttpClient okHttpClient, String url) throws Exception {
Log.d(TAG, url);
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).build();
Call call = okHttpClient.newCall(request);
// Put call
if (null != task) {
task.setCall(call);
}
String body = null;
Headers headers = null;
int code = -1;
try {
Response response = call.execute();
code = response.code();
headers = response.headers();
body = response.body().string();
return Pair.create(GalleryDetailParser.parsePreviewSet(body), GalleryDetailParser.parsePreviewPages(body));
} catch (Exception e) {
throwException(call, code, headers, body, e);
throw e;
}
}
use of com.amazonaws.services.s3.Headers in project EhViewer by seven332.
the class EhEngine method rateGallery.
public static RateGalleryParser.Result rateGallery(@Nullable EhClient.Task task, OkHttpClient okHttpClient, long apiUid, String apiKey, long gid, String token, float rating) throws Exception {
final JSONObject json = new JSONObject();
json.put("method", "rategallery");
json.put("apiuid", apiUid);
json.put("apikey", apiKey);
json.put("gid", gid);
json.put("token", token);
json.put("rating", (int) Math.ceil(rating * 2));
final RequestBody requestBody = RequestBody.create(MEDIA_TYPE_JSON, json.toString());
String url = EhUrl.getApiUrl();
Log.d(TAG, url);
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).post(requestBody).build();
Call call = okHttpClient.newCall(request);
// Put call
if (null != task) {
task.setCall(call);
}
String body = null;
Headers headers = null;
int code = -1;
try {
Response response = call.execute();
code = response.code();
headers = response.headers();
body = response.body().string();
return RateGalleryParser.parse(body);
} catch (Exception e) {
throwException(call, code, headers, body, e);
throw e;
}
}
use of com.amazonaws.services.s3.Headers in project EhViewer by seven332.
the class EhEngine method getTorrentList.
public static Pair<String, String>[] getTorrentList(@Nullable EhClient.Task task, OkHttpClient okHttpClient, String url) throws Exception {
Log.d(TAG, url);
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).build();
Call call = okHttpClient.newCall(request);
// Put call
if (null != task) {
task.setCall(call);
}
String body = null;
Headers headers = null;
Pair<String, String>[] result;
int code = -1;
try {
Response response = call.execute();
code = response.code();
headers = response.headers();
body = response.body().string();
result = TorrentParser.parse(body);
} catch (Exception e) {
throwException(call, code, headers, body, e);
throw e;
}
return result;
}
use of com.amazonaws.services.s3.Headers in project EhViewer by seven332.
the class EhEngine method getGalleryList.
public static GalleryListParser.Result getGalleryList(@Nullable EhClient.Task task, OkHttpClient okHttpClient, String url) throws Exception {
Log.d(TAG, url);
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig()).build();
Call call = okHttpClient.newCall(request);
// Put call
if (null != task) {
task.setCall(call);
}
String body = null;
Headers headers = null;
GalleryListParser.Result result;
int code = -1;
try {
Response response = call.execute();
code = response.code();
headers = response.headers();
body = response.body().string();
result = GalleryListParser.parse(body);
} catch (Exception e) {
throwException(call, code, headers, body, e);
throw e;
}
// Filter title and uploader
List<GalleryInfo> list = result.galleryInfoList;
for (int i = 0, n = list.size(); i < n; i++) {
GalleryInfo info = list.get(i);
if (!sEhFilter.filterTitle(info) || !sEhFilter.filterUploader(info)) {
list.remove(i);
i--;
n--;
}
}
if (list.size() > 0 && (Settings.getShowJpnTitle() || sEhFilter.needCallApi())) {
// Fill by api
fillGalleryListByApi(task, okHttpClient, list);
// Filter tag
for (int i = 0, n = list.size(); i < n; i++) {
GalleryInfo info = list.get(i);
if (!sEhFilter.filterTag(info) || !sEhFilter.filterTagNamespace(info)) {
list.remove(i);
i--;
n--;
}
}
}
for (GalleryInfo info : list) {
info.thumb = EhUrl.getFixedPreviewThumbUrl(info.thumb);
}
return result;
}
Aggregations