refactor: Update usage of delegated sources' ids
This commit is contained in:
parent
7c63f84f5f
commit
9ffeb13ef3
7 changed files with 33 additions and 16 deletions
|
|
@ -68,6 +68,9 @@ class MangaRestorer(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restore a single manga
|
||||||
|
*/
|
||||||
suspend fun restoreManga(
|
suspend fun restoreManga(
|
||||||
backupManga: BackupManga,
|
backupManga: BackupManga,
|
||||||
backupCategories: List<BackupCategory>,
|
backupCategories: List<BackupCategory>,
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import exh.metadata.metadata.NHentaiSearchMetadata
|
||||||
import exh.metadata.metadata.RaisedSearchMetadata
|
import exh.metadata.metadata.RaisedSearchMetadata
|
||||||
import exh.metadata.metadata.base.RaisedTag
|
import exh.metadata.metadata.base.RaisedTag
|
||||||
import exh.source.DelegatedHttpSource
|
import exh.source.DelegatedHttpSource
|
||||||
|
import exh.source.NHENTAI_SOURCE_ID
|
||||||
import exh.util.trimOrNull
|
import exh.util.trimOrNull
|
||||||
import exh.util.urlImportFetchSearchManga
|
import exh.util.urlImportFetchSearchManga
|
||||||
import exh.util.urlImportFetchSearchMangaSuspend
|
import exh.util.urlImportFetchSearchMangaSuspend
|
||||||
|
|
@ -214,7 +215,7 @@ class NHentai(delegate: HttpSource, val context: Context) :
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val otherId = 7309872737163460316L
|
const val otherId = NHENTAI_SOURCE_ID
|
||||||
|
|
||||||
private val jsonParser = Json {
|
private val jsonParser = Json {
|
||||||
ignoreUnknownKeys = true
|
ignoreUnknownKeys = true
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,12 @@
|
||||||
package exh
|
package exh
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.source.online.all.NHentai
|
|
||||||
import exh.source.BlacklistedSources
|
import exh.source.BlacklistedSources
|
||||||
import exh.source.EH_SOURCE_ID
|
import exh.source.EH_SOURCE_ID
|
||||||
|
import exh.source.HBROWSE_OLD_ID
|
||||||
import exh.source.HBROWSE_SOURCE_ID
|
import exh.source.HBROWSE_SOURCE_ID
|
||||||
|
import exh.source.NHENTAI_OLD_ID
|
||||||
|
import exh.source.NHENTAI_SOURCE_ID
|
||||||
|
import exh.source.TSUMINO_OLD_ID
|
||||||
import exh.source.TSUMINO_SOURCE_ID
|
import exh.source.TSUMINO_SOURCE_ID
|
||||||
import tachiyomi.domain.manga.model.Manga
|
import tachiyomi.domain.manga.model.Manga
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
|
@ -11,25 +14,28 @@ import java.net.URISyntaxException
|
||||||
|
|
||||||
object EXHMigrations {
|
object EXHMigrations {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Migrate old source ID of delegated sources in old backup
|
||||||
|
*/
|
||||||
fun migrateBackupEntry(manga: Manga): Manga {
|
fun migrateBackupEntry(manga: Manga): Manga {
|
||||||
var newManga = manga
|
var newManga = manga
|
||||||
if (newManga.source == 6907L) {
|
if (newManga.source == NHENTAI_OLD_ID) {
|
||||||
newManga = newManga.copy(
|
newManga = newManga.copy(
|
||||||
// Migrate the old source to the delegated one
|
// Migrate the old source to the delegated one
|
||||||
source = NHentai.otherId,
|
source = NHENTAI_SOURCE_ID,
|
||||||
// Migrate nhentai URLs
|
// Migrate nhentai URLs
|
||||||
url = getUrlWithoutDomain(newManga.url),
|
url = getUrlWithoutDomain(newManga.url),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Migrate Tsumino source IDs
|
// Migrate Tsumino source IDs
|
||||||
if (newManga.source == 6909L) {
|
if (newManga.source == TSUMINO_OLD_ID) {
|
||||||
newManga = newManga.copy(
|
newManga = newManga.copy(
|
||||||
source = TSUMINO_SOURCE_ID,
|
source = TSUMINO_SOURCE_ID,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newManga.source == 6912L) {
|
if (newManga.source == HBROWSE_OLD_ID) {
|
||||||
newManga = newManga.copy(
|
newManga = newManga.copy(
|
||||||
source = HBROWSE_SOURCE_ID,
|
source = HBROWSE_SOURCE_ID,
|
||||||
url = newManga.url + "/c00001/",
|
url = newManga.url + "/c00001/",
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,13 @@ import eu.kanade.tachiyomi.data.backup.models.Backup
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||||
import eu.kanade.tachiyomi.data.sync.SyncDataJob
|
import eu.kanade.tachiyomi.data.sync.SyncDataJob
|
||||||
import eu.kanade.tachiyomi.source.AndroidSourceManager
|
import eu.kanade.tachiyomi.source.AndroidSourceManager
|
||||||
import eu.kanade.tachiyomi.source.online.all.NHentai
|
|
||||||
import eu.kanade.tachiyomi.util.system.workManager
|
import eu.kanade.tachiyomi.util.system.workManager
|
||||||
import exh.eh.EHentaiThrottleManager
|
import exh.eh.EHentaiThrottleManager
|
||||||
import exh.eh.EHentaiUpdateWorker
|
import exh.eh.EHentaiUpdateWorker
|
||||||
import exh.metadata.metadata.EHentaiSearchMetadata
|
import exh.metadata.metadata.EHentaiSearchMetadata
|
||||||
import exh.source.EH_SOURCE_ID
|
import exh.source.EH_SOURCE_ID
|
||||||
import exh.source.EXH_SOURCE_ID
|
import exh.source.EXH_SOURCE_ID
|
||||||
|
import exh.source.NHENTAI_SOURCE_ID
|
||||||
import exh.source.nHentaiSourceIds
|
import exh.source.nHentaiSourceIds
|
||||||
import exh.util.jobScheduler
|
import exh.util.jobScheduler
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
|
@ -299,9 +299,9 @@ object DebugFunctions {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun migrateLangNhentaiToMultiLangSource() {
|
fun migrateLangNhentaiToMultiLangSource() {
|
||||||
val sources = nHentaiSourceIds - NHentai.otherId
|
val sources = nHentaiSourceIds - NHENTAI_SOURCE_ID
|
||||||
|
|
||||||
runBlocking { handler.await { ehQueries.migrateAllNhentaiToOtherLang(NHentai.otherId, sources) } }
|
runBlocking { handler.await { ehQueries.migrateAllNhentaiToOtherLang(NHENTAI_SOURCE_ID, sources) } }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun exportProtobufScheme() = ProtoBufSchemaGenerator.generateSchemaText(Backup.serializer().descriptor)
|
fun exportProtobufScheme() = ProtoBufSchemaGenerator.generateSchemaText(Backup.serializer().descriptor)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package mihon.core.migration.migrations
|
package mihon.core.migration.migrations
|
||||||
|
|
||||||
import eu.kanade.domain.manga.interactor.UpdateManga
|
import eu.kanade.domain.manga.interactor.UpdateManga
|
||||||
|
import exh.source.HBROWSE_OLD_ID
|
||||||
import exh.source.HBROWSE_SOURCE_ID
|
import exh.source.HBROWSE_SOURCE_ID
|
||||||
import mihon.core.migration.MigrateUtils
|
import mihon.core.migration.MigrateUtils
|
||||||
import mihon.core.migration.Migration
|
import mihon.core.migration.Migration
|
||||||
|
|
@ -15,7 +16,7 @@ class DelegateHBrowseMigration : Migration {
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean = withIOContext {
|
override suspend fun invoke(migrationContext: MigrationContext): Boolean = withIOContext {
|
||||||
val getMangaBySource = migrationContext.get<GetMangaBySource>() ?: return@withIOContext false
|
val getMangaBySource = migrationContext.get<GetMangaBySource>() ?: return@withIOContext false
|
||||||
val updateManga = migrationContext.get<UpdateManga>() ?: return@withIOContext false
|
val updateManga = migrationContext.get<UpdateManga>() ?: return@withIOContext false
|
||||||
MigrateUtils.updateSourceId(migrationContext, HBROWSE_SOURCE_ID, 6912)
|
MigrateUtils.updateSourceId(migrationContext, HBROWSE_SOURCE_ID, HBROWSE_OLD_ID)
|
||||||
|
|
||||||
// Migrate BHrowse URLs
|
// Migrate BHrowse URLs
|
||||||
val hBrowseManga = getMangaBySource.await(HBROWSE_SOURCE_ID)
|
val hBrowseManga = getMangaBySource.await(HBROWSE_SOURCE_ID)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package mihon.core.migration.migrations
|
package mihon.core.migration.migrations
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.source.online.all.NHentai
|
import exh.source.NHENTAI_OLD_ID
|
||||||
|
import exh.source.NHENTAI_SOURCE_ID
|
||||||
import mihon.core.migration.MigrateUtils
|
import mihon.core.migration.MigrateUtils
|
||||||
import mihon.core.migration.Migration
|
import mihon.core.migration.Migration
|
||||||
import mihon.core.migration.MigrationContext
|
import mihon.core.migration.MigrationContext
|
||||||
|
|
@ -10,7 +11,7 @@ class DelegateNHentaiMigration : Migration {
|
||||||
override val version: Float = 6f
|
override val version: Float = 6f
|
||||||
|
|
||||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean = withIOContext {
|
override suspend fun invoke(migrationContext: MigrationContext): Boolean = withIOContext {
|
||||||
MigrateUtils.updateSourceId(migrationContext, NHentai.otherId, 6907)
|
MigrateUtils.updateSourceId(migrationContext, NHENTAI_SOURCE_ID, NHENTAI_OLD_ID)
|
||||||
|
|
||||||
return@withIOContext true
|
return@withIOContext true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,13 @@ package exh.source
|
||||||
const val LEWD_SOURCE_SERIES = 6900L
|
const val LEWD_SOURCE_SERIES = 6900L
|
||||||
const val EH_SOURCE_ID = LEWD_SOURCE_SERIES + 1
|
const val EH_SOURCE_ID = LEWD_SOURCE_SERIES + 1
|
||||||
const val EXH_SOURCE_ID = LEWD_SOURCE_SERIES + 2
|
const val EXH_SOURCE_ID = LEWD_SOURCE_SERIES + 2
|
||||||
const val PURURIN_SOURCE_ID = 2221515250486218861
|
const val NHENTAI_SOURCE_ID = 7309872737163460316L
|
||||||
const val TSUMINO_SOURCE_ID = 6707338697138388238
|
const val PURURIN_SOURCE_ID = 2221515250486218861L
|
||||||
const val EIGHTMUSES_SOURCE_ID = 1802675169972965535
|
const val TSUMINO_SOURCE_ID = 6707338697138388238L
|
||||||
const val HBROWSE_SOURCE_ID = 1401584337232758222
|
const val EIGHTMUSES_SOURCE_ID = 1802675169972965535L
|
||||||
|
const val HBROWSE_SOURCE_ID = 1401584337232758222L
|
||||||
const val MERGED_SOURCE_ID = LEWD_SOURCE_SERIES + 69
|
const val MERGED_SOURCE_ID = LEWD_SOURCE_SERIES + 69
|
||||||
|
|
||||||
|
const val NHENTAI_OLD_ID = 6907L
|
||||||
|
const val TSUMINO_OLD_ID = 6909L
|
||||||
|
const val HBROWSE_OLD_ID = 6912L
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue