feat: more thumbnails, descriptions (thanks to @yupcm)
This commit is contained in:
parent
11655bd38d
commit
8822ef6805
25 changed files with 279 additions and 101 deletions
|
@ -9,6 +9,7 @@ import androidx.core.content.ContextCompat
|
|||
import androidx.core.util.Pair
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import ani.dantotsu.copyToClipboard
|
||||
import ani.dantotsu.databinding.ItemCharacterBinding
|
||||
import ani.dantotsu.loadImage
|
||||
import ani.dantotsu.setAnimation
|
||||
|
@ -32,6 +33,9 @@ class CharacterAdapter(
|
|||
binding.itemCompactRelation.text = whitespace
|
||||
binding.itemCompactImage.loadImage(character.image)
|
||||
binding.itemCompactTitle.text = character.name
|
||||
binding.root.setOnClickListener {
|
||||
copyToClipboard(character.name ?: "")
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = characterList.size
|
||||
|
|
|
@ -13,6 +13,7 @@ import ani.dantotsu.media.anime.Episode
|
|||
import ani.dantotsu.media.anime.SelectorDialogFragment
|
||||
import ani.dantotsu.media.manga.MangaChapter
|
||||
import ani.dantotsu.others.AniSkip
|
||||
import ani.dantotsu.others.Anify
|
||||
import ani.dantotsu.others.Jikan
|
||||
import ani.dantotsu.others.Kitsu
|
||||
import ani.dantotsu.parsers.AnimeSources
|
||||
|
@ -99,6 +100,15 @@ class MediaDetailsViewModel : ViewModel() {
|
|||
if (kitsuEpisodes.value == null) kitsuEpisodes.postValue(Kitsu.getKitsuEpisodesDetails(s))
|
||||
}
|
||||
}
|
||||
private val anifyEpisodes: MutableLiveData<Map<String, Episode>> =
|
||||
MutableLiveData<Map<String, Episode>>(null)
|
||||
|
||||
fun getAnifyEpisodes(): LiveData<Map<String, Episode>> = anifyEpisodes
|
||||
suspend fun loadAnifyEpisodes(s: Int) {
|
||||
tryWithSuspend {
|
||||
if (anifyEpisodes.value == null) anifyEpisodes.postValue(Anify.fetchAndParseMetadata(s))
|
||||
}
|
||||
}
|
||||
|
||||
private val fillerEpisodes: MutableLiveData<Map<String, Episode>> =
|
||||
MutableLiveData<Map<String, Episode>>(null)
|
||||
|
|
|
@ -26,4 +26,5 @@ data class Anime(
|
|||
var slug: String? = null,
|
||||
var kitsuEpisodes: Map<String, Episode>? = null,
|
||||
var fillerEpisodes: Map<String, Episode>? = null,
|
||||
var anifyEpisodes: Map<String, Episode>? = null,
|
||||
) : Serializable
|
|
@ -49,6 +49,7 @@ import ani.dantotsu.media.MediaType
|
|||
import ani.dantotsu.navBarHeight
|
||||
import ani.dantotsu.notifications.subscription.SubscriptionHelper
|
||||
import ani.dantotsu.notifications.subscription.SubscriptionHelper.Companion.saveSubscription
|
||||
import ani.dantotsu.others.Anify
|
||||
import ani.dantotsu.others.LanguageMapper
|
||||
import ani.dantotsu.parsers.AnimeParser
|
||||
import ani.dantotsu.parsers.AnimeSources
|
||||
|
@ -214,8 +215,9 @@ class AnimeWatchFragment : Fragment() {
|
|||
media.selected!!.sourceIndex = model.watchSources!!.list.lastIndex
|
||||
} else {
|
||||
awaitAll(
|
||||
async { model.loadKitsuEpisodes(media) },
|
||||
async { model.loadFillerEpisodes(media) }
|
||||
//async { model.loadKitsuEpisodes(media) }, if someday anify dies
|
||||
//async { model.loadFillerEpisodes(media) },
|
||||
async { model.loadAnifyEpisodes(media.id)}
|
||||
)
|
||||
}
|
||||
model.loadEpisodes(media, media.selected!!.sourceIndex)
|
||||
|
@ -231,19 +233,6 @@ class AnimeWatchFragment : Fragment() {
|
|||
val episodes = loadedEpisodes[media.selected!!.sourceIndex]
|
||||
if (episodes != null) {
|
||||
episodes.forEach { (i, episode) ->
|
||||
fun getThumbnail(episodes: List<MediaStreamingEpisode>): List<Pair<String, FileUrl?>> {
|
||||
return episodes.mapNotNull { episode ->
|
||||
val regex = Regex("""Episode\s*(\d+)\s*-\s*(.*)""")
|
||||
val number = episode.title?.let {
|
||||
val matchResult = regex.matchEntire(it)
|
||||
matchResult?.destructured?.component1()
|
||||
}
|
||||
number?.let { number to FileUrl[episode.thumbnail] }
|
||||
}
|
||||
}
|
||||
|
||||
val getThumbnail = getThumbnail(media.streamingEpisodes ?: emptyList())
|
||||
|
||||
if (media.anime?.fillerEpisodes != null) {
|
||||
if (media.anime!!.fillerEpisodes!!.containsKey(i)) {
|
||||
episode.title =
|
||||
|
@ -258,11 +247,23 @@ class AnimeWatchFragment : Fragment() {
|
|||
episode.title = if (MediaNameAdapter.removeEpisodeNumberCompletely(
|
||||
episode.title ?: ""
|
||||
).isBlank()
|
||||
) media.anime!!.kitsuEpisodes!![i]?.title
|
||||
)
|
||||
media.anime!!.kitsuEpisodes!![i]?.title
|
||||
?: episode.title else episode.title
|
||||
?: media.anime!!.kitsuEpisodes!![i]?.title ?: episode.title
|
||||
episode.thumb = getThumbnail.find { it.first == i }?.second
|
||||
?: media.anime!!.kitsuEpisodes!![i]?.thumb ?: episode.thumb
|
||||
episode.thumb = media.anime!!.kitsuEpisodes!![i]?.thumb ?: episode.thumb
|
||||
}
|
||||
}
|
||||
if (media.anime?.anifyEpisodes != null) {
|
||||
if (media.anime!!.anifyEpisodes!!.containsKey(i)) {
|
||||
episode.desc = media.anime!!.anifyEpisodes!![i]?.desc ?: episode.desc
|
||||
episode.title = if (MediaNameAdapter.removeEpisodeNumberCompletely(
|
||||
episode.title ?: ""
|
||||
).isBlank()
|
||||
) media.anime!!.anifyEpisodes!![i]?.title ?: episode.title else episode.title
|
||||
?: media.anime!!.anifyEpisodes!![i]?.title ?: episode.title
|
||||
episode.thumb = media.anime!!.anifyEpisodes!![i]?.thumb ?: episode.thumb
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -309,6 +310,10 @@ class AnimeWatchFragment : Fragment() {
|
|||
if (i != null)
|
||||
media.anime?.fillerEpisodes = i
|
||||
}
|
||||
model.getAnifyEpisodes().observe(viewLifecycleOwner) { i ->
|
||||
if (i != null)
|
||||
media.anime?.anifyEpisodes = i
|
||||
}
|
||||
}
|
||||
|
||||
fun onSourceChange(i: Int): AnimeParser {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue