Cleanup
This commit is contained in:
parent
44385ed9cc
commit
b63df25f7b
@ -26,7 +26,6 @@ import eu.kanade.tachiyomi.source.SourceManager
|
|||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.source.model.toSChapter
|
import eu.kanade.tachiyomi.source.model.toSChapter
|
||||||
import eu.kanade.tachiyomi.source.model.toSManga
|
import eu.kanade.tachiyomi.source.model.toSManga
|
||||||
import eu.kanade.tachiyomi.source.online.all.MangaDex
|
|
||||||
import eu.kanade.tachiyomi.source.online.all.MergedSource
|
import eu.kanade.tachiyomi.source.online.all.MergedSource
|
||||||
import eu.kanade.tachiyomi.ui.library.LibraryGroup
|
import eu.kanade.tachiyomi.ui.library.LibraryGroup
|
||||||
import eu.kanade.tachiyomi.ui.manga.track.TrackItem
|
import eu.kanade.tachiyomi.ui.manga.track.TrackItem
|
||||||
@ -45,6 +44,7 @@ import exh.metadata.metadata.base.insertFlatMetadataAsync
|
|||||||
import exh.source.LIBRARY_UPDATE_EXCLUDED_SOURCES
|
import exh.source.LIBRARY_UPDATE_EXCLUDED_SOURCES
|
||||||
import exh.source.MERGED_SOURCE_ID
|
import exh.source.MERGED_SOURCE_ID
|
||||||
import exh.source.getMainSource
|
import exh.source.getMainSource
|
||||||
|
import exh.source.isMdBasedSource
|
||||||
import exh.source.mangaDexSourceIds
|
import exh.source.mangaDexSourceIds
|
||||||
import exh.util.executeOnIO
|
import exh.util.executeOnIO
|
||||||
import exh.util.nullIfBlank
|
import exh.util.nullIfBlank
|
||||||
@ -460,7 +460,7 @@ class LibraryUpdateService(
|
|||||||
Timber.e(exception)
|
Timber.e(exception)
|
||||||
}
|
}
|
||||||
ioScope.launch(handler) {
|
ioScope.launch(handler) {
|
||||||
if (source is MangaDex && trackManager.mdList.isLogged) {
|
if (source.isMdBasedSource() && trackManager.mdList.isLogged) {
|
||||||
val tracks = db.getTracks(manga).executeOnIO()
|
val tracks = db.getTracks(manga).executeOnIO()
|
||||||
if (tracks.isEmpty() || tracks.none { it.sync_id == TrackManager.MDLIST }) {
|
if (tracks.isEmpty() || tracks.none { it.sync_id == TrackManager.MDLIST }) {
|
||||||
var track = trackManager.mdList.createInitialTracker(manga)
|
var track = trackManager.mdList.createInitialTracker(manga)
|
||||||
|
@ -179,38 +179,43 @@ class EHentai(
|
|||||||
tags += parsedTags
|
tags += parsedTags
|
||||||
|
|
||||||
if (infoElements != null) {
|
if (infoElements != null) {
|
||||||
getGenre(infoElements.getOrNull(1))?.let { genre = it }
|
genre = getGenre(infoElements.getOrNull(1))
|
||||||
|
|
||||||
getDateTag(infoElements.getOrNull(2))?.let { datePosted = it }
|
datePosted = getDateTag(infoElements.getOrNull(2))
|
||||||
|
|
||||||
getRating(infoElements.getOrNull(3))?.let { averageRating = it }
|
averageRating = getRating(infoElements.getOrNull(3))
|
||||||
|
|
||||||
getUploader(infoElements.getOrNull(4))?.let { uploader = it }
|
uploader = getUploader(infoElements.getOrNull(4))
|
||||||
|
|
||||||
getPageCount(infoElements.getOrNull(5))?.let { length = it }
|
length = getPageCount(infoElements.getOrNull(5))
|
||||||
} else {
|
} else {
|
||||||
val parsedGenre = body.selectFirst(".gl1c div")
|
val parsedGenre = body.selectFirst(".gl1c div")
|
||||||
getGenre(genreString = parsedGenre?.text()?.nullIfBlank()?.toLowerCase()?.replace(" ", ""))?.let { genre = it }
|
genre = getGenre(
|
||||||
|
genreString = parsedGenre?.text()
|
||||||
|
?.nullIfBlank()
|
||||||
|
?.toLowerCase()
|
||||||
|
?.replace(" ", "")
|
||||||
|
)
|
||||||
|
|
||||||
val info = body.selectFirst(".gl2c")
|
val info = body.selectFirst(".gl2c")
|
||||||
val extraInfo = body.selectFirst(".gl4c")
|
val extraInfo = body.selectFirst(".gl4c")
|
||||||
|
|
||||||
val infoList = info.select("div div")
|
val infoList = info.select("div div")
|
||||||
|
|
||||||
getDateTag(infoList.getOrNull(8))?.let { datePosted = it }
|
datePosted = getDateTag(infoList.getOrNull(8))
|
||||||
|
|
||||||
getRating(infoList.getOrNull(9))?.let { averageRating = it }
|
averageRating = getRating(infoList.getOrNull(9))
|
||||||
|
|
||||||
val extraInfoList = extraInfo.select("div")
|
val extraInfoList = extraInfo.select("div")
|
||||||
|
|
||||||
if (extraInfoList.getOrNull(2) == null) {
|
if (extraInfoList.getOrNull(2) == null) {
|
||||||
getUploader(extraInfoList.getOrNull(0))?.let { uploader = it }
|
uploader = getUploader(extraInfoList.getOrNull(0))
|
||||||
|
|
||||||
getPageCount(extraInfoList.getOrNull(1))?.let { length = it }
|
length = getPageCount(extraInfoList.getOrNull(1))
|
||||||
} else {
|
} else {
|
||||||
getUploader(extraInfoList.getOrNull(1))?.let { uploader = it }
|
uploader = getUploader(extraInfoList.getOrNull(1))
|
||||||
|
|
||||||
getPageCount(extraInfoList.getOrNull(2))?.let { length = it }
|
length = getPageCount(extraInfoList.getOrNull(2))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,6 @@ import eu.kanade.tachiyomi.source.Source
|
|||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import eu.kanade.tachiyomi.source.online.MetadataSource
|
import eu.kanade.tachiyomi.source.online.MetadataSource
|
||||||
import eu.kanade.tachiyomi.source.online.all.MangaDex
|
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.FabController
|
import eu.kanade.tachiyomi.ui.base.controller.FabController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.ToolbarLiftOnScrollController
|
import eu.kanade.tachiyomi.ui.base.controller.ToolbarLiftOnScrollController
|
||||||
@ -108,6 +107,7 @@ import exh.recs.RecommendsController
|
|||||||
import exh.source.MERGED_SOURCE_ID
|
import exh.source.MERGED_SOURCE_ID
|
||||||
import exh.source.getMainSource
|
import exh.source.getMainSource
|
||||||
import exh.source.isEhBasedSource
|
import exh.source.isEhBasedSource
|
||||||
|
import exh.source.isMdBasedSource
|
||||||
import kotlinx.coroutines.CancellationException
|
import kotlinx.coroutines.CancellationException
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.NonCancellable
|
import kotlinx.coroutines.NonCancellable
|
||||||
@ -548,7 +548,7 @@ class MangaController :
|
|||||||
clipData = ClipData.newRawUri(null, stream)
|
clipData = ClipData.newRawUri(null, stream)
|
||||||
type = "image/*"
|
type = "image/*"
|
||||||
}
|
}
|
||||||
startActivity(Intent.createChooser(intent, activity?.getString(R.string.action_share)))
|
startActivity(Intent.createChooser(intent, activity.getString(R.string.action_share)))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.message?.let { activity?.toast(it) } ?: activity?.toast(R.string.error_sharing_cover)
|
e.message?.let { activity?.toast(it) } ?: activity?.toast(R.string.error_sharing_cover)
|
||||||
}
|
}
|
||||||
@ -767,7 +767,7 @@ class MangaController :
|
|||||||
// AZ -->
|
// AZ -->
|
||||||
fun openRecommends() {
|
fun openRecommends() {
|
||||||
val source = presenter.source.getMainSource()
|
val source = presenter.source.getMainSource()
|
||||||
if (source is MangaDex) {
|
if (source.isMdBasedSource()) {
|
||||||
MaterialDialog(activity!!)
|
MaterialDialog(activity!!)
|
||||||
.title(R.string.az_recommends)
|
.title(R.string.az_recommends)
|
||||||
.listItemsSingleChoice(
|
.listItemsSingleChoice(
|
||||||
@ -777,8 +777,8 @@ class MangaController :
|
|||||||
)
|
)
|
||||||
) { _, index, _ ->
|
) { _, index, _ ->
|
||||||
when (index) {
|
when (index) {
|
||||||
0 -> router.pushController(MangaDexSimilarController(presenter.manga, source).withFadeTransaction())
|
0 -> router.pushController(MangaDexSimilarController(presenter.manga, source as CatalogueSource).withFadeTransaction())
|
||||||
1 -> router.pushController(RecommendsController(presenter.manga, source).withFadeTransaction())
|
1 -> router.pushController(RecommendsController(presenter.manga, source as CatalogueSource).withFadeTransaction())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.show()
|
.show()
|
||||||
|
@ -99,6 +99,8 @@ fun isMetadataSource(source: Long) = source in 6900..6999 ||
|
|||||||
|
|
||||||
fun Source.isEhBasedSource() = id == EH_SOURCE_ID || id == EXH_SOURCE_ID
|
fun Source.isEhBasedSource() = id == EH_SOURCE_ID || id == EXH_SOURCE_ID
|
||||||
|
|
||||||
|
fun Source.isMdBasedSource() = id in mangaDexSourceIds
|
||||||
|
|
||||||
fun Manga.isEhBasedManga() = source == EH_SOURCE_ID || source == EXH_SOURCE_ID
|
fun Manga.isEhBasedManga() = source == EH_SOURCE_ID || source == EXH_SOURCE_ID
|
||||||
|
|
||||||
fun Source.getMainSource(): Source = if (this is EnhancedHttpSource) {
|
fun Source.getMainSource(): Source = if (this is EnhancedHttpSource) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user