Gallery chapter metadata will now be automatically downloaded when importing galleries.
This commit is contained in:
parent
c30aa710f3
commit
d4b35736c0
@ -4,8 +4,10 @@ import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
|||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.source.SourceManager
|
import eu.kanade.tachiyomi.data.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.util.UrlUtil
|
import eu.kanade.tachiyomi.util.UrlUtil
|
||||||
|
import eu.kanade.tachiyomi.util.syncChaptersWithSource
|
||||||
import exh.metadata.MetadataHelper
|
import exh.metadata.MetadataHelper
|
||||||
import exh.metadata.copyTo
|
import exh.metadata.copyTo
|
||||||
|
import timber.log.Timber
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.net.MalformedURLException
|
import java.net.MalformedURLException
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
@ -26,6 +28,7 @@ class GalleryAdder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val sourceObj = sourceManager.get(source)
|
val sourceObj = sourceManager.get(source)
|
||||||
|
?: throw IllegalStateException("Could not find EH source!")
|
||||||
|
|
||||||
val pathOnlyUrl = UrlUtil.getPath(url)
|
val pathOnlyUrl = UrlUtil.getPath(url)
|
||||||
|
|
||||||
@ -35,13 +38,11 @@ class GalleryAdder {
|
|||||||
title = url
|
title = url
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceObj?.let {
|
//Copy basics
|
||||||
//Copy basics
|
manga.copyFrom(sourceObj.fetchMangaDetails(manga).toBlocking().first())
|
||||||
manga.copyFrom(sourceObj.fetchMangaDetails(manga).toBlocking().first())
|
|
||||||
|
|
||||||
//Apply metadata
|
//Apply metadata
|
||||||
metadataHelper.fetchMetadata(url, source == 2)?.copyTo(manga)
|
metadataHelper.fetchMetadata(url, source == 2)?.copyTo(manga)
|
||||||
}
|
|
||||||
|
|
||||||
if(fav) manga.favorite = true
|
if(fav) manga.favorite = true
|
||||||
|
|
||||||
@ -49,6 +50,15 @@ class GalleryAdder {
|
|||||||
manga.id = it
|
manga.id = it
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Fetch and copy chapters
|
||||||
|
try {
|
||||||
|
sourceObj.fetchChapterList(manga).map {
|
||||||
|
syncChaptersWithSource(db, it, manga, sourceObj)
|
||||||
|
}.toBlocking().first()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Timber.w(e, "Failed to update chapters for gallery: ${manga.title}!")
|
||||||
|
}
|
||||||
|
|
||||||
return manga
|
return manga
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user