Skip to content

Commit

Permalink
修复画廊详情H@H功能解析失败的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaojieonly committed Oct 28, 2024
1 parent 12f2d13 commit e10b6f9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/com/hippo/ehviewer/client/EhEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -843,10 +843,10 @@ public static ArchiverData getArchiver(@Nullable EhClient.Task task, OkHttpClien

public static Void downloadArchive(@Nullable EhClient.Task task, OkHttpClient okHttpClient,
long gid, String token, String or, String res) throws Throwable {
if (or == null || or.length() == 0) {
if (or == null) {
throw new EhException("Invalid form param or: " + or);
}
if (res == null || res.length() == 0) {
if (res == null || res.isEmpty()) {
throw new EhException("Invalid res: " + res);
}
FormBody.Builder builder = new FormBody.Builder();
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/hippo/ehviewer/client/EhUrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ public static String getAddFavorites(long gid, String token) {
}

public static String getDownloadArchive(long gid, String token, String or) {
if (or.isEmpty()){
return getHost() + "archiver.php?gid=" + gid + "&token=" + token;
}
return getHost() + "archiver.php?gid=" + gid + "&token=" + token + "&or=" + or;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ public class ArchiveParser {
@SuppressWarnings("unchecked")
public static Pair<String, Pair<String, String>[]> parse(String body) {
Matcher m = PATTERN_FORM.matcher(body);
if (!m.find()) {
return new Pair<String, Pair<String, String>[]>("", new Pair[0]);
String paramOr = "";
if (m.find()) {
paramOr = m.group(1);
}
String paramOr = m.group(1);

List<Pair<String, String>> archiveList = new ArrayList<>();
m = PATTERN_ARCHIVE.matcher(body);
while (m.find()) {
Expand All @@ -54,13 +55,13 @@ public static Pair<String, Pair<String, String>[]> parse(String body) {
Pair<String, String> item = new Pair<>(res, name);
archiveList.add(item);
}
return new Pair<String, Pair<String, String>[]>(paramOr, archiveList.toArray(new Pair[archiveList.size()]));
return new Pair<>(paramOr, archiveList.toArray(new Pair[0]));
}

public static ArchiverData parseArchiver(String body) {
ArchiverData data = new ArchiverData();
Document document = Jsoup.parse(body);
if (Settings.getGallerySite()== EhUrl.SITE_E){
if (Settings.getGallerySite() == EhUrl.SITE_E) {
try {
Element bodyElement = (Element) document.childNode(2).childNode(3).childNode(1);
data.funds = bodyElement.child(2).text();
Expand All @@ -76,7 +77,7 @@ public static ArchiverData parseArchiver(String body) {
data.resampleUrl = resample.child(1).attr("action");
} catch (Exception ignore) {
}
}else {
} else {
try {
Element bodyElement = (Element) document.childNode(2).childNode(3).childNode(1);
data.funds = bodyElement.child(0).text();
Expand All @@ -99,7 +100,7 @@ public static ArchiverData parseArchiver(String body) {

public static String parseArchiverDownloadUrl(String body) {
Matcher m = PATTERN_ARCHIVER_DOWNLOAD_URL.matcher(body);
if (!m.find()){
if (!m.find()) {
return null;
}
return m.group(1);
Expand Down

0 comments on commit e10b6f9

Please sign in to comment.