Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create API to enable more efficient updates on supporting sources #765

Open
4 tasks done
TheUnlocked opened this issue May 6, 2024 · 0 comments
Open
4 tasks done
Labels
Feature request New feature or request

Comments

@TheUnlocked
Copy link

TheUnlocked commented May 6, 2024

Describe your suggested feature

Background

Tachiyomi clients currently need to be careful about performing certain bulk actions because an excessive number of network requests could put significant load on sources and cause users to get throttled or blacklisted. Even for sources that don't punish users who make a large number of requests, it is still in the philosophy of Tachiyomi/Mihon to avoid causing excess strain. This is evidenced by the push notifications Mihon presents when a user attempts to update a large number of manga at one time, as well as by various restrictions and optimizations that have been put in place to avoid large numbers of requests going through at one time.

Some sources do have functionality that allows fetching details on a large number of manga at once. However, because extensions-lib doesn't provide any way to tell clients that, extensions for sources that could hypothetically provide these enhanced capabilities still need to go at the same slow pace as every other source, making one request per manga. While there is an UnmeteredSource interface, it has no methods so it doesn't actually enable more efficient updates, it's just used for sources that don't care about a large number of requests (such as the local source).

Feature request

Mihon should introduce either a new interface or new methods on an existing interface (or some other design) that extensions can implement to take control of mass updates on supporting clients.

For example, a possible API (with default implementations) could look like:

interface MangaUpdate {
    /**
     * If true and newDetails is null, this will inform the client to fetch manga details individually
     */
    var hasDetailsChanged: Boolean
    /**
     * If true and newChapterList is null, this will inform the client to fetch chapter lists individually
     */
    var hasChapterListChanged: Boolean
    var newDetails: SManga?
    var newChapterList: List<SChapter>?

    companion object {
        fun create(): MangaUpdate = throw NotImplementedError()
    }
}

interface Source {

    // existing methods...

    /**
     * Get information about required updates for a group of manga
     *
     * @param manga the list of manga to update.
     * @return update information for each manga.
     *  The returned list must be the same length and in the same order as the original list.
     */
    suspend fun getMultipleMangaUpdates(manga: List<SManga>): List<MangaUpdate>
        = manga.map { MangaUpdate.create().apply {
            hasDetailsChanged = true
            hasChapterListChanged = true
        } }

    /**
     * Get groups of manga to update together when updating multiple manga.
     *
     * @param manga the list of manga to partition.
     * @return a list of partitions of manga. Every input manga should be included in exactly one partition.
     */
    fun partitionMangaForUpdate(manga: List<SManga>): List<List<SManga>>
        = manga.map { listOf(it) }

}

An additional set of functions/properties for performance tuning and for opting into more frequent updates could also be useful, but I think the above would already provide significant benefit on its own.

Other details

No response

Acknowledgements

  • I have searched the existing issues and this is a new ticket, NOT a duplicate or related to another open or closed issue.
  • I have written a short but informative title.
  • I have updated the app to version 0.16.5.
  • I will fill out all of the requested information in this form.
@TheUnlocked TheUnlocked added the Feature request New feature or request label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant