Clean up or parameter as it's no longer required
This commit is contained in:
1 parent
5c50d7622b
commit
58f85cc436
4 files changed
+7
-11
No files matched your search
@@ -306,8 +306,8 @@ object EhEngine {
|
||||
suspend fun getFavoriteNote(gid: Long, token: String) = ehRequest(EhUrl.getAddFavorites(gid, token), EhUrl.getGalleryDetailUrl(gid, token))
|
||||
.fetchUsingAsText(FavoritesParser::parseNote)
|
||||
|
||||
suspend fun downloadArchive(gid: Long, token: String, or: String?, res: String, isHAtH: Boolean): String? {
|
||||
val url = EhUrl.getDownloadArchive(gid, token, or)
|
||||
suspend fun downloadArchive(gid: Long, token: String, res: String, isHAtH: Boolean): String? {
|
||||
val url = EhUrl.getDownloadArchive(gid, token)
|
||||
val referer = EhUrl.getGalleryDetailUrl(gid, token)
|
||||
val request = ehRequest(url, referer, EhUrl.origin) {
|
||||
formBody {
|
||||
|
||||
@@ -125,10 +125,9 @@ object EhUrl {
|
||||
addQueryParameter("act", "addfav")
|
||||
}.buildString()
|
||||
|
||||
fun getDownloadArchive(gid: Long, token: String, or: String?) = ehUrl("archiver.php") {
|
||||
fun getDownloadArchive(gid: Long, token: String) = ehUrl("archiver.php") {
|
||||
addQueryParameter("gid", "$gid")
|
||||
addQueryParameter("token", token)
|
||||
addQueryParameterIfNotBlank("or", or)
|
||||
}.buildString()
|
||||
|
||||
fun getTagDefinitionUrl(tag: String) = "https://ehwiki.org/wiki/" + tag.replace(' ', '_')
|
||||
|
||||
@@ -25,8 +25,6 @@ object ArchiveParser {
|
||||
Regex("<strong>(.*)</strong>.*<a href=\"([^\"]*)\">Click Here To Start Downloading</a>")
|
||||
private val PATTERN_CURRENT_FUNDS =
|
||||
Regex("<p>([\\d,]+) GP \\[[^]]*] ([\\d,]+) Credits \\[[^]]*]</p>")
|
||||
private val PATTERN_HATH_FORM =
|
||||
Regex("<form id=\"hathdl_form\" action=\"[^\"]*?or=([^=\"]*?)\" method=\"post\">")
|
||||
private val PATTERN_HATH_ARCHIVE =
|
||||
Regex("<p><a href=\"[^\"]*\" onclick=\"return do_hathdl\\('([0-9]+|org)'\\)\">([^<]+)</a></p>\\s*<p>([\\w. ]+)</p>\\s*<p>([\\w. ]+)</p>")
|
||||
private const val ERROR_NEED_HATH_CLIENT =
|
||||
@@ -35,7 +33,6 @@ object ArchiveParser {
|
||||
"You do not have enough funds to download this archive."
|
||||
|
||||
fun parse(body: String, maybeFunds: Funds?): Result {
|
||||
val paramOr = PATTERN_HATH_FORM.find(body)?.groupValues[1]
|
||||
val archiveList = ArrayList<Archive>()
|
||||
Jsoup.parse(body).select("#db>div>div").forEach { element ->
|
||||
if (element.childrenSize() > 0 && !element.attr("style").contains("color:#CCCCCC")) {
|
||||
@@ -63,7 +60,7 @@ object ArchiveParser {
|
||||
val fundsC = ParserUtils.parseInt(get(2), 0)
|
||||
Funds(fundsGP, fundsC)
|
||||
}
|
||||
return Result(paramOr, archiveList, funds)
|
||||
return Result(archiveList, funds)
|
||||
}
|
||||
|
||||
fun parseArchiveUrl(body: String): String? {
|
||||
@@ -77,7 +74,7 @@ object ArchiveParser {
|
||||
// TODO: Check more errors
|
||||
}
|
||||
|
||||
data class Result(val paramOr: String?, val archiveList: List<Archive>, val funds: Funds)
|
||||
data class Result(val archiveList: List<Archive>, val funds: Funds)
|
||||
}
|
||||
|
||||
class Archive(
|
||||
|
||||
@@ -173,7 +173,7 @@ fun AnimatedVisibilityScope.GalleryDetailScreen(args: GalleryDetailScreenArgs, n
|
||||
showSnackbar(signInFirst)
|
||||
} else {
|
||||
runSuspendCatching {
|
||||
val (paramOr, archiveList, funds) = bgWork { archiveResult.await() }
|
||||
val (archiveList, funds) = bgWork { archiveResult.await() }
|
||||
if (archiveList.isEmpty()) {
|
||||
showSnackbar(noArchive)
|
||||
} else {
|
||||
@@ -184,7 +184,7 @@ fun AnimatedVisibilityScope.GalleryDetailScreen(args: GalleryDetailScreenArgs, n
|
||||
onItemClick = { resume(it) },
|
||||
)
|
||||
}
|
||||
EhEngine.downloadArchive(gid, token, paramOr, selected.res, selected.isHAtH)?.let {
|
||||
EhEngine.downloadArchive(gid, token, selected.res, selected.isHAtH)?.let {
|
||||
val uri = Uri.parse(it)
|
||||
val intent = Intent().apply {
|
||||
action = Intent.ACTION_VIEW
|
||||
|
||||
Reference in new issue
Block a user