diff --git a/app/src/main/java/com/hiroshi/cimoc/core/Download.java b/app/src/main/java/com/hiroshi/cimoc/core/Download.java index d20b365e..472fa22e 100644 --- a/app/src/main/java/com/hiroshi/cimoc/core/Download.java +++ b/app/src/main/java/com/hiroshi/cimoc/core/Download.java @@ -150,8 +150,8 @@ public static DocumentFile updateChapterIndex(ContentResolver resolver, Document String jsonString = getJsonFromChapter(task.getTitle(), task.getPath()); DocumentFile dir1 = DocumentUtils.getOrCreateSubDirectory(root, DOWNLOAD); DocumentFile dir2 = DocumentUtils.getOrCreateSubDirectory(dir1, String.valueOf(task.getSource())); - DocumentFile dir3 = DocumentUtils.getOrCreateSubDirectory(dir2, task.getCid().replaceAll("/|\\?", "")); - DocumentFile dir4 = DocumentUtils.getOrCreateSubDirectory(dir3, DecryptionUtils.urlDecrypt(task.getPath().replaceAll("/|\\?", "-"))); + DocumentFile dir3 = DocumentUtils.getOrCreateSubDirectory(dir2, task.getCid().replaceAll("[:/(\\\\)(\\?)<>\"(\\|)(\\.)]", "")); + DocumentFile dir4 = DocumentUtils.getOrCreateSubDirectory(dir3, DecryptionUtils.urlDecrypt(task.getPath().replaceAll("[:/(\\\\)(\\?)<>\"(\\|)(\\.)]", "-"))); if (dir4 != null) { DocumentFile file = DocumentUtils.getOrCreateFile(dir4, FILE_INDEX); DocumentUtils.writeStringToFile(resolver, file, "cimoc".concat(jsonString)); @@ -224,8 +224,8 @@ private static List readPathFromJson(String jsonString) throws JSONExcep public static DocumentFile getChapterDir(DocumentFile root, Comic comic, Chapter chapter, String title) { DocumentFile result = DocumentUtils.findFile(root, DOWNLOAD, String.valueOf(comic.getSource()), - comic.getCid().replaceAll("/|\\?", ""), - DecryptionUtils.urlDecrypt(chapter.getPath().replaceAll("/|\\?", "-")) + comic.getCid().replaceAll("[:/(\\\\)(\\?)<>\"(\\|)(\\.)]", ""), + DecryptionUtils.urlDecrypt(chapter.getPath().replaceAll("[:/(\\\\)(\\?)<>\"(\\|)(\\.)]", "-")) ); if (result == null) { result = DocumentUtils.findFile(root, DOWNLOAD, title, comic.getTitle(), chapter.getTitle()); diff --git a/app/src/main/java/com/hiroshi/cimoc/service/DownloadService.java b/app/src/main/java/com/hiroshi/cimoc/service/DownloadService.java index a6149a6f..bf21abbc 100644 --- a/app/src/main/java/com/hiroshi/cimoc/service/DownloadService.java +++ b/app/src/main/java/com/hiroshi/cimoc/service/DownloadService.java @@ -8,6 +8,7 @@ import android.os.IBinder; import androidx.annotation.Nullable; import androidx.collection.LongSparseArray; + import android.util.Pair; import com.hiroshi.cimoc.App; @@ -226,6 +227,7 @@ private boolean RequestAndWrite(DocumentFile parent, Request request, int num, S response = mHttpClient.newCall(request).execute(); if (response.isSuccessful()) { String displayName = buildFileName(num, url); + displayName = displayName.replaceAll("[:/(\\\\)(\\?)<>\"(\\|)(\\.)]", "_"); DocumentFile file = DocumentUtils.getOrCreateFile(parent, displayName); DocumentUtils.writeBinaryToFile(mContentResolver, file, response.body().byteStream()); return true; diff --git a/app/src/main/java/com/hiroshi/cimoc/source/CopyMH.java b/app/src/main/java/com/hiroshi/cimoc/source/CopyMH.java index 03e4b56e..08d81cd7 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/CopyMH.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/CopyMH.java @@ -23,6 +23,7 @@ import java.util.LinkedList; import java.util.List; +import okhttp3.Headers; import okhttp3.Request; import taobe.tec.jcc.JChineseConvertor; @@ -167,4 +168,9 @@ public Request getCheckRequest(String cid) { public String parseCheck(String html) { return new Node(html).text("div.col-9.comicParticulars-title-right > ul > li:nth-child(5) > span.comicParticulars-right-txt"); } + + @Override + public Headers getHeader() { + return Headers.of("Referer", website); + } } diff --git a/app/src/main/java/com/hiroshi/cimoc/source/MH160.java b/app/src/main/java/com/hiroshi/cimoc/source/MH160.java index c462d3da..33655373 100644 --- a/app/src/main/java/com/hiroshi/cimoc/source/MH160.java +++ b/app/src/main/java/com/hiroshi/cimoc/source/MH160.java @@ -14,6 +14,7 @@ import java.util.LinkedList; import java.util.List; +import okhttp3.Headers; import okhttp3.Request; /** @@ -151,4 +152,9 @@ public String parseCheck(String html) { return new Node(html).text("div.cy_zhangjie_top > :eq(2) > font"); } + @Override + public Headers getHeader() { + return Headers.of("Referer", baseUrl); + } + }