Don't fetch metadata if source is GalleryDetail
This commit is contained in:
1 parent
af32d7eea7
commit
f1a856cb45
2 files changed
+34
-14
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package com.hippo.ehviewer.spider
|
||||
|
||||
import com.hippo.ehviewer.client.EhUrl
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
import com.hippo.ehviewer.client.data.TagNamespace
|
||||
import com.hippo.unifile.UniFile
|
||||
@@ -18,6 +19,7 @@ import nl.adaptivity.xmlutil.serialization.XmlElement
|
||||
import nl.adaptivity.xmlutil.xmlStreaming
|
||||
|
||||
const val COMIC_INFO_FILE = "ComicInfo.xml"
|
||||
private const val TAG_ORIGINAL = "original"
|
||||
|
||||
private val xml = XML {
|
||||
recommended {
|
||||
@@ -33,18 +35,35 @@ fun GalleryInfo.getComicInfo(): ComicInfo {
|
||||
val groups = mutableListOf<String>()
|
||||
val characters = mutableListOf<String>()
|
||||
val parodies = mutableListOf<String>()
|
||||
val tags = mutableListOf<String>()
|
||||
simpleTags?.forEach { tagString ->
|
||||
val (namespace, tag) = tagString.split(':', limit = 2)
|
||||
with(TagNamespace) {
|
||||
when (val ns = TagNamespace(namespace)) {
|
||||
Artist, Cosplayer -> artists.add(tag)
|
||||
Group -> groups.add(tag)
|
||||
Character -> characters.add(tag)
|
||||
Parody -> if (tag != "original") parodies.add(tag)
|
||||
Other -> tags.add(tag)
|
||||
Female, Male, Mixed -> ns.toPrefix()?.let { tags.add("$it:$tag") }
|
||||
else -> Unit
|
||||
val otherTags = mutableListOf<String>()
|
||||
with(TagNamespace) {
|
||||
when (this@getComicInfo) {
|
||||
is GalleryDetail -> tags.forEach { tagList ->
|
||||
when (val ns = TagNamespace(tagList.groupName)) {
|
||||
Artist, Cosplayer -> artists.addAll(tagList)
|
||||
Group -> groups.addAll(tagList)
|
||||
Character -> characters.addAll(tagList)
|
||||
Parody -> tagList.forEach { tag -> if (tag != TAG_ORIGINAL) parodies.add(tag) }
|
||||
Other -> otherTags.addAll(tagList)
|
||||
Female, Male, Mixed -> ns.toPrefix()?.let { prefix ->
|
||||
tagList.forEach { tag -> otherTags.add("$prefix:$tag") }
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
|
||||
else -> simpleTags?.forEach { tagString ->
|
||||
val (namespace, tag) = tagString.split(':', limit = 2)
|
||||
when (val ns = TagNamespace(namespace)) {
|
||||
Artist, Cosplayer -> artists.add(tag)
|
||||
Group -> groups.add(tag)
|
||||
Character -> characters.add(tag)
|
||||
Parody -> if (tag != TAG_ORIGINAL) parodies.add(tag)
|
||||
Other -> otherTags.add(tag)
|
||||
Female, Male, Mixed -> ns.toPrefix()?.let { otherTags.add("$it:$tag") }
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,7 +72,7 @@ fun GalleryInfo.getComicInfo(): ComicInfo {
|
||||
alternateSeries = titleJpn.takeUnless { it.isNullOrBlank() },
|
||||
writer = groups.takeUnless { it.isEmpty() }?.joinToString(),
|
||||
penciller = artists.takeUnless { it.isEmpty() }?.joinToString(),
|
||||
genre = tags.takeUnless { it.isEmpty() }?.joinToString(),
|
||||
genre = otherTags.takeUnless { it.isEmpty() }?.joinToString(),
|
||||
web = EhUrl.getGalleryDetailUrl(gid, token),
|
||||
pageCount = pages,
|
||||
languageISO = simpleLanguage?.lowercase(),
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.hippo.ehviewer.EhDB
|
||||
import com.hippo.ehviewer.Settings
|
||||
import com.hippo.ehviewer.client.EhEngine
|
||||
import com.hippo.ehviewer.client.EhUtils.getSuitableTitle
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
import com.hippo.ehviewer.client.ehRequest
|
||||
import com.hippo.ehviewer.client.getImageKey
|
||||
@@ -319,7 +320,7 @@ class SpiderDen(val info: GalleryInfo) {
|
||||
downloadDir?.run {
|
||||
createFile(COMIC_INFO_FILE)?.also {
|
||||
runCatching {
|
||||
if (fetchMetadata) {
|
||||
if (info !is GalleryDetail && fetchMetadata) {
|
||||
withNonCancellableContext {
|
||||
EhEngine.fillGalleryListByApi(listOf(info))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user