Update ignore feature added
Bug fixed
This commit is contained in:
@@ -22,7 +22,7 @@ import java.net.URL
|
||||
data class Gallery(
|
||||
val related: List<Int>,
|
||||
val langList: List<Pair<String, String>>,
|
||||
val cover: URL,
|
||||
val cover: String,
|
||||
val title: String,
|
||||
val artists: List<String>,
|
||||
val groups: List<String>,
|
||||
@@ -31,7 +31,7 @@ data class Gallery(
|
||||
val series: List<String>,
|
||||
val characters: List<String>,
|
||||
val tags: List<String>,
|
||||
val thumbnails: List<URL>
|
||||
val thumbnails: List<String>
|
||||
)
|
||||
fun getGallery(galleryID: Int) : Gallery {
|
||||
val url = "https://hitomi.la/galleries/$galleryID.html"
|
||||
@@ -48,7 +48,7 @@ fun getGallery(galleryID: Int) : Gallery {
|
||||
Pair(it.text(), it.attr("href").replace(".html", ""))
|
||||
}
|
||||
|
||||
val cover = URL(protocol + doc.selectFirst(".cover img").attr("src"))
|
||||
val cover = protocol + doc.selectFirst(".cover img").attr("src")
|
||||
val title = doc.selectFirst(".gallery h1 a").text()
|
||||
val artists = doc.select(".gallery h2 a").map { it.text() }
|
||||
val groups = doc.select(".gallery-info a[href~=^/group/]").map { it.text() }
|
||||
@@ -70,7 +70,7 @@ fun getGallery(galleryID: Int) : Gallery {
|
||||
val thumbnails = Regex("'(//tn.hitomi.la/smalltn/\\d+/\\d+.+)',")
|
||||
.findAll(doc.select("script").last().html())
|
||||
.map {
|
||||
URL(protocol + it.groups[1]!!.value)
|
||||
protocol + it.groups[1]!!.value
|
||||
}.toList()
|
||||
|
||||
return Gallery(related, langList, cover, title, artists, groups, type, language, series, characters, tags, thumbnails)
|
||||
|
||||
@@ -57,30 +57,33 @@ fun doSearch(query: String, sortByPopularity: Boolean = false) : List<Int> {
|
||||
var results = when {
|
||||
sortByPopularity -> getGalleryIDsFromNozomi(null, "popular", "all")
|
||||
positiveTerms.isEmpty() -> getGalleryIDsFromNozomi(null, "index", "all")
|
||||
else -> getGalleryIDsForQuery(positiveTerms.poll())
|
||||
else -> listOf()
|
||||
}
|
||||
|
||||
runBlocking {
|
||||
@Synchronized fun filterPositive(newResults: List<Int>) {
|
||||
results = results.filter { newResults.binarySearch(it) >= 0 }
|
||||
results = when {
|
||||
results.isEmpty() -> newResults
|
||||
else -> newResults.sorted().let { sorted ->
|
||||
results.filter { sorted.binarySearch(it) >= 0 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized fun filterNegative(newResults: List<Int>) {
|
||||
results = results.filter { newResults.binarySearch(it) < 0 }
|
||||
results = newResults.sorted().let { sorted ->
|
||||
results.filter { sorted.binarySearch(it) < 0 }
|
||||
}
|
||||
}
|
||||
|
||||
//positive results
|
||||
positiveResults.forEach {
|
||||
val result = it.await()
|
||||
|
||||
filterPositive(result.sorted())
|
||||
filterPositive(it.await())
|
||||
}
|
||||
|
||||
//negative results
|
||||
negativeResults.forEach {
|
||||
val result = it.await()
|
||||
|
||||
filterNegative(result.sorted())
|
||||
filterNegative(it.await())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package xyz.quaver.hitomi
|
||||
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.net.URL
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
@@ -175,22 +174,18 @@ fun getGalleryIDsFromNozomi(area: String?, tag: String, language: String) : List
|
||||
}
|
||||
|
||||
try {
|
||||
with (URL(nozomiAddress).openConnection() as HttpsURLConnection) {
|
||||
requestMethod = "GET"
|
||||
val bytes = URL(nozomiAddress).readBytes()
|
||||
|
||||
val nozomi = ArrayList<Int>()
|
||||
val nozomi = ArrayList<Int>()
|
||||
|
||||
val bytes = inputStream.readBytes()
|
||||
val arrayBuffer = ByteBuffer
|
||||
.wrap(bytes)
|
||||
.order(ByteOrder.BIG_ENDIAN)
|
||||
|
||||
val arrayBuffer = ByteBuffer
|
||||
.wrap(bytes)
|
||||
.order(ByteOrder.BIG_ENDIAN)
|
||||
while (arrayBuffer.hasRemaining())
|
||||
nozomi.add(arrayBuffer.int)
|
||||
|
||||
while (arrayBuffer.hasRemaining())
|
||||
nozomi.add(arrayBuffer.int)
|
||||
|
||||
return nozomi
|
||||
}
|
||||
return nozomi
|
||||
} catch (e: Exception) {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user