diff --git a/app/src/main/java/io/legado/app/help/storage/OldRule.kt b/app/src/main/java/io/legado/app/help/storage/OldRule.kt index 27738806c..361fd1402 100644 --- a/app/src/main/java/io/legado/app/help/storage/OldRule.kt +++ b/app/src/main/java/io/legado/app/help/storage/OldRule.kt @@ -45,4 +45,10 @@ object OldRule { } return url } + + fun uaToHeader(ua: String?): String? { + if (ua.isNullOrEmpty()) return null + val map = mapOf(Pair("user_agent", ua)) + return GSON.toJson(map) + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/storage/Restore.kt b/app/src/main/java/io/legado/app/help/storage/Restore.kt index 0e9b73dbf..82d256d88 100644 --- a/app/src/main/java/io/legado/app/help/storage/Restore.kt +++ b/app/src/main/java/io/legado/app/help/storage/Restore.kt @@ -109,6 +109,7 @@ object Restore { source.loginUrl = jsonItem.readString("loginUrl") source.bookUrlPattern = jsonItem.readString("ruleBookUrlPattern") source.customOrder = jsonItem.readInt("serialNumber") ?: 0 + source.header = OldRule.uaToHeader(jsonItem.readString("httpUserAgent")) val searchRule = SearchRule( searchUrl = OldRule.toNewUrl(jsonItem.readString("ruleSearchUrl")), bookList = jsonItem.readString("ruleSearchList"),