From 5f331d1e8a4b4f011635b665e73af15ae3427933 Mon Sep 17 00:00:00 2001 From: xiaojie Date: Sun, 7 Apr 2024 16:32:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A1=A3=E6=A1=88=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E5=9C=A8=E6=8D=90=E8=B5=A0=E7=94=A8=E6=88=B7=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E7=AB=99=E7=82=B9=E4=B8=BA=E9=87=8C=E7=AB=99=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E8=B5=B7=E4=BD=9C=E7=94=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hippo/ehviewer/client/EhTagDatabase.java | 2 + .../ehviewer/client/parser/ArchiveParser.java | 45 ++++++-- .../ui/dialog/ArchiverDownloadDialog.java | 10 +- .../client/parser/ArchiveDownloadDialog.html | 104 ++++++++++++++++++ 4 files changed, 148 insertions(+), 13 deletions(-) create mode 100644 app/src/test/resources/com/hippo/ehviewer/client/parser/ArchiveDownloadDialog.html diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhTagDatabase.java b/app/src/main/java/com/hippo/ehviewer/client/EhTagDatabase.java index 9d171294d..1f476547c 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhTagDatabase.java +++ b/app/src/main/java/com/hippo/ehviewer/client/EhTagDatabase.java @@ -23,6 +23,7 @@ import androidx.annotation.Nullable; +import com.google.firebase.crashlytics.FirebaseCrashlytics; import com.hippo.ehviewer.AppConfig; import com.hippo.ehviewer.EhApplication; import com.hippo.ehviewer.R; @@ -331,6 +332,7 @@ private static boolean save(OkHttpClient client, String url, File file) { return true; } catch (Throwable t) { ExceptionUtils.throwIfFatal(t); + FirebaseCrashlytics.getInstance().recordException(t); return false; } } diff --git a/app/src/main/java/com/hippo/ehviewer/client/parser/ArchiveParser.java b/app/src/main/java/com/hippo/ehviewer/client/parser/ArchiveParser.java index 1e502afb6..39f9f681a 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/parser/ArchiveParser.java +++ b/app/src/main/java/com/hippo/ehviewer/client/parser/ArchiveParser.java @@ -18,7 +18,10 @@ import android.util.Pair; +import com.hippo.ehviewer.Settings; +import com.hippo.ehviewer.client.EhUrl; import com.hippo.ehviewer.client.data.ArchiverData; +import com.hippo.network.UrlBuilder; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; @@ -57,22 +60,40 @@ public static Pair[]> parse(String body) { public static ArchiverData parseArchiver(String body) { ArchiverData data = new ArchiverData(); Document document = Jsoup.parse(body); + if (Settings.getGallerySite()== EhUrl.SITE_E){ + try { + Element bodyElement = (Element) document.childNode(2).childNode(3).childNode(1); + data.funds = bodyElement.child(2).text(); - try { - Element bodyElement = (Element) document.childNode(2).childNode(3).childNode(1); - data.funds = bodyElement.child(2).text(); + Element original = bodyElement.child(3).child(0); + data.originalCost = original.child(0).child(0).text(); + data.originalSize = original.child(2).child(0).text(); + data.originalUrl = original.child(1).attr("action"); - Element original = bodyElement.child(3).child(0); - data.originalCost = original.child(0).child(0).text(); - data.originalSize = original.child(2).child(0).text(); - data.originalUrl = original.child(1).attr("action"); + Element resample = bodyElement.child(3).child(1); + data.resampleCost = resample.child(0).child(0).text(); + data.resampleSize = resample.child(2).child(0).text(); + data.resampleUrl = resample.child(1).attr("action"); + } catch (Exception ignore) { + } + }else { + try { + Element bodyElement = (Element) document.childNode(2).childNode(3).childNode(1); + data.funds = bodyElement.child(0).text(); - Element resample = bodyElement.child(3).child(1); - data.resampleCost = resample.child(0).child(0).text(); - data.resampleSize = resample.child(2).child(0).text(); - data.resampleUrl = resample.child(1).attr("action"); - } catch (Exception ignore) { + Element original = bodyElement.child(1).child(0); + data.originalCost = original.child(0).child(0).text(); + data.originalSize = original.child(2).child(0).text(); + data.originalUrl = original.child(1).attr("action"); + + Element resample = bodyElement.child(1).child(1); + data.resampleCost = resample.child(0).child(0).text(); + data.resampleSize = resample.child(2).child(0).text(); + data.resampleUrl = resample.child(1).attr("action"); + } catch (Exception ignore) { + } } + return data; } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/dialog/ArchiverDownloadDialog.java b/app/src/main/java/com/hippo/ehviewer/ui/dialog/ArchiverDownloadDialog.java index 667d86ea0..1ea588a21 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/dialog/ArchiverDownloadDialog.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/dialog/ArchiverDownloadDialog.java @@ -27,8 +27,10 @@ import com.hippo.ehviewer.AppConfig; import com.hippo.ehviewer.EhApplication; import com.hippo.ehviewer.R; +import com.hippo.ehviewer.Settings; import com.hippo.ehviewer.client.EhClient; import com.hippo.ehviewer.client.EhRequest; +import com.hippo.ehviewer.client.EhUrl; import com.hippo.ehviewer.client.data.ArchiverData; import com.hippo.ehviewer.client.data.GalleryDetail; import com.hippo.ehviewer.client.exception.NoHAtHClientException; @@ -144,7 +146,13 @@ public void onDismiss(DialogInterface dialog) { @Override public void onSuccess(ArchiverData result) { data = result; - String cF = context.getString(R.string.archiver_dialog_current_funds) + data.funds; + String cF; + if (Settings.getGallerySite()== EhUrl.SITE_E){ + cF = context.getString(R.string.archiver_dialog_current_funds) + data.funds; + }else { + cF = data.funds; + } + currentFunds.setText(cF); String oC = context.getString(R.string.archiver_dialog_cost, data.originalCost); String rC = context.getString(R.string.archiver_dialog_cost, data.resampleCost); diff --git a/app/src/test/resources/com/hippo/ehviewer/client/parser/ArchiveDownloadDialog.html b/app/src/test/resources/com/hippo/ehviewer/client/parser/ArchiveDownloadDialog.html new file mode 100644 index 000000000..baeddb8fd --- /dev/null +++ b/app/src/test/resources/com/hippo/ehviewer/client/parser/ArchiveDownloadDialog.html @@ -0,0 +1,104 @@ + + + + Archiver + + + + + + + +
+

COSPLAYTALE NAKO MASHMAID

+ + +
+
+
Download Cost:   + Free!
+ +
+ +
+
+ +

Estimated Size:   18.46 MiB

+
+ +
+
Download Cost:   + Free!
+ +
+ +
+
+ +

Estimated Size:   2.17 MiB

+
+ +
+
+ +
+

H@H Downloader

+
+
+ + + + + + + + + +
+

780x

+

588.4 KiB

+

Free

+
+

980x

+

2.21 MiB

+

Free

+
+

1280x

+

2.17 MiB

+

Free

+
+

1600x

+

5.89 MiB

+

Free

+
+

2400x

+

11.00 MiB

+

Free

+
+

Original

+

18.46 MiB

+

Free

+
+
+ +
+ + \ No newline at end of file