Use jnix
This commit is contained in:
1 parent
62509e1500
commit
2206dd85bc
6 files changed
+72
-54
No files matched your search
@@ -40,6 +40,7 @@ import com.hippo.ehviewer.client.parser.ProfileParser
|
||||
import com.hippo.ehviewer.client.parser.RateGalleryParser
|
||||
import com.hippo.ehviewer.client.parser.SignInParser
|
||||
import com.hippo.ehviewer.client.parser.TorrentParser
|
||||
import com.hippo.ehviewer.client.parser.TorrentResult
|
||||
import com.hippo.ehviewer.client.parser.VoteCommentParser
|
||||
import com.hippo.ehviewer.client.parser.VoteTagParser
|
||||
import com.hippo.ehviewer.dailycheck.showEventNotification
|
||||
@@ -129,7 +130,7 @@ private suspend inline fun <T> Request.executeAndParsingWith(block: String.() ->
|
||||
}
|
||||
|
||||
object EhEngine {
|
||||
suspend fun getTorrentList(url: String, gid: Long, token: String?): List<TorrentParser.Result> {
|
||||
suspend fun getTorrentList(url: String, gid: Long, token: String?): TorrentResult {
|
||||
val referer = EhUrl.getGalleryDetailUrl(gid, token)
|
||||
return ehRequest(url, referer).executeAndParsingWith(TorrentParser::parse)
|
||||
}
|
||||
|
||||
@@ -1,30 +1,25 @@
|
||||
/*
|
||||
* Copyright 2016 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hippo.ehviewer.client.parser
|
||||
|
||||
object TorrentParser {
|
||||
fun parse(body: String): List<Result> {
|
||||
val list = mutableListOf<Array<String>>()
|
||||
fun parse(body: String) = run {
|
||||
val list = mutableListOf<Torrent>()
|
||||
parseTorrent(body, list)
|
||||
return list.map { Result(it[0], it[1], it[2].toInt(), it[3].toInt(), it[4].toInt(), it[5], it[6]) }
|
||||
}
|
||||
|
||||
class Result(val posted: String, val size: String, val seeds: Int, val peers: Int, val downloads: Int, val url: String, val name: String) {
|
||||
fun format() = "[$posted] $name [$size] [↑$seeds ↓$peers ✓$downloads]"
|
||||
list
|
||||
}
|
||||
}
|
||||
|
||||
private external fun parseTorrent(body: String, list: List<Array<String>>)
|
||||
class Torrent(
|
||||
val posted: String,
|
||||
val size: String,
|
||||
val seeds: Int,
|
||||
val peers: Int,
|
||||
val downloads: Int,
|
||||
val url: String,
|
||||
val name: String,
|
||||
) {
|
||||
fun format() = "[$posted] $name [$size] [↑$seeds ↓$peers ✓$downloads]"
|
||||
}
|
||||
|
||||
typealias TorrentResult = List<Torrent>
|
||||
|
||||
private external fun parseTorrent(body: String, list: List<Torrent>)
|
||||
@@ -137,7 +137,7 @@ import com.hippo.ehviewer.client.exception.NoHAtHClientException
|
||||
import com.hippo.ehviewer.client.parser.ArchiveParser
|
||||
import com.hippo.ehviewer.client.parser.HomeParser
|
||||
import com.hippo.ehviewer.client.parser.ParserUtils
|
||||
import com.hippo.ehviewer.client.parser.TorrentParser
|
||||
import com.hippo.ehviewer.client.parser.TorrentResult
|
||||
import com.hippo.ehviewer.coil.imageRequest
|
||||
import com.hippo.ehviewer.coil.justDownload
|
||||
import com.hippo.ehviewer.coil.read
|
||||
@@ -204,7 +204,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
private var favButtonText by mutableStateOf("")
|
||||
private var getDetailError by mutableStateOf("")
|
||||
|
||||
private var mTorrentList: List<TorrentParser.Result>? = null
|
||||
private var mTorrentList: TorrentResult? = null
|
||||
private var requestStoragePermissionLauncher = registerForActivityResult(
|
||||
ActivityResultContracts.RequestPermission(),
|
||||
) { result: Boolean ->
|
||||
@@ -1696,7 +1696,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
}
|
||||
}
|
||||
|
||||
private fun bind(data: List<TorrentParser.Result>?) {
|
||||
private fun bind(data: TorrentResult?) {
|
||||
if (null == mDialog || null == mProgressView || null == mErrorText || null == mListView) {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user