Mango icon indicating copy to clipboard operation
Mango copied to clipboard

[Feature Request] Tachiyomi Support

Open Gyokusai opened this issue 5 years ago • 49 comments

Tachiyomi support for reading on android devices would be very nice for android devices.

Gyokusai avatar May 05 '20 21:05 Gyokusai

Thanks for reaching out!

It looks like Tachiyomi does not have OPDS support (https://github.com/inorichi/tachiyomi/issues/2315), so to use Tachiyomi with Mango I have to develop a Tachiyomi extension for Mango.

Unfortunately I don't write Java/Kotlin, so I will mark this issue as "help wanted" for now. It would be great if you could help to develop the extension! If nobody is able to help, I will try to do it myself when I have the time.

hkalexling avatar May 06 '20 05:05 hkalexling

you could ask @gotson maybe he could help. he already has created a plugin for komga

Ruffyop avatar May 06 '20 16:05 Ruffyop

@Ruffyop good idea! Perhaps I can take a look at the komga plugin and see how it can be done.

hkalexling avatar May 07 '20 04:05 hkalexling

@hkalexling Please pardon me for resurrecting this issue.

I'd also like to suggest a Tachiyomi integration, but basically the other way around. I actualy like Mango on Android very much, simply works.

Therefore I'd like to synchonice or at the very least backup my Tachiyomi library to Mango. Tachiyomi uses external services for a tracking of whats in your library and how far a reader has progressed.

I'd say integrationg these services into Mango would actually aloww for a Tachiyomi / Mango sync without actually having a compatible interface between both environments directly.

The services currently supported by Tachiyomi are:

  • MyAnimeList.net
  • AniList.co
  • Kitsu.io
  • Shikimori.one
  • Bangumi (bgm.tv)

TheMuelli avatar Feb 12 '21 23:02 TheMuelli

For everyone following this, @goldbattle has created a Mango extension for Tachiyomi. It has the basic functionalities that you would expect, and we need to update the Mango API to improve its usability (see #170).

hkalexling avatar Apr 03 '21 05:04 hkalexling

@TheMuelli I think https://github.com/tachiyomiorg/tachiyomi/issues/4282 is what you are looking for?

hkalexling avatar Apr 03 '21 05:04 hkalexling

Seems like the Mango extension doesn't support Mango being addressed through a non-default port, right? That's a shame. :/

GlassedSilver avatar Aug 22 '21 18:08 GlassedSilver

@GlassedSilver Thanks for letting me know. I took a look at the extension code and I think it's a mistake in the implementation. Multiple Mango instances can run on the same server and serve from different ports, so we store the session cookies as mango-sessid-[port-number] to distinguish them. The extension should prompt the user to enter the port number (have it default to 9000) and then use it to match the correct cookies ID. But the current implementation checks mango-sessid-9000 regardless of the actual port. See https://github.com/tachiyomiorg/tachiyomi-extensions/blob/b74b30d4fe5f7c35db111ab84671897e2e72449c/src/all/mango/src/eu/kanade/tachiyomi/extension/all/mango/Mango.kt#L214

I should be able to work on this next month when I have more time.

hkalexling avatar Aug 23 '21 01:08 hkalexling

Sweet! Thank you so much for looking into it then already :)

GlassedSilver avatar Aug 23 '21 01:08 GlassedSilver

It would be nice to be able to add multiple instances like the komga extension do.

Nerothos avatar Aug 24 '21 12:08 Nerothos

Hi, am I wrong or nest folders are not supported? Because the app sees me only the chapters of the series that are immediately a zip / cbz.

In order to understand each other: image Giving me as a mistake that in those series there are no chapters (those that are nested). I am writing here because in the past I have tried in the git issues of tachiyomi extensions, getting no answers from the original programmer (at least until you have fixed the port problem now)

VegethB avatar Sep 10 '21 11:09 VegethB

@zFerry98 I am not entirely sure but I guess Tachiyomi itself doesn't support this, so there's nothing we can do as an extension. It was designed as a general reader that supports hundreds of sources and is not tailored for Mango itself. Please don't blame the Tachiyomi maintainers. They are not familiar with Mango and the Mango extension, so they might not be able to give you answers.

hkalexling avatar Sep 11 '21 01:09 hkalexling

I thought the example discussed showed the hierarchy of files as stored within Mango, no?

Surely as long as Mango knows what chapter is in which file it can pass on to the extension in Tachiyomi however it expects it with or without a hierarchy, no?

GlassedSilver avatar Sep 11 '21 17:09 GlassedSilver

I thought the example discussed showed the hierarchy of files as stored within Mango, no?

Surely as long as Mango knows what chapter is in which file it can pass on to the extension in Tachiyomi however it expects it with or without a hierarchy, no?

image

Unfortunately I don't know how to read the code, but the problem is that all the series that are like in example 2 (manga 2) go into error, saying: this series has no chapters. At the moment I can't even take screenshots from android because it keeps giving me "timeout" (but in the webview it loads after 1 2 minutes).

However, the problem is that if the .zip / cbz is immediately after the first folder (the one with the series name, usually), tachiyomi shows you the chapters / volumes. If there is even one subfolder in the series folder, tachiyomi tells me that he found no chapters / there aren't any.

VegethB avatar Sep 11 '21 17:09 VegethB

I thought the example discussed showed the hierarchy of files as stored within Mango, no? Surely as long as Mango knows what chapter is in which file it can pass on to the extension in Tachiyomi however it expects it with or without a hierarchy, no?

image

Unfortunately I don't know how to read the code, but the problem is that all the series that are like in example 2 (manga 2) go into error, saying: this series has no chapters. At the moment I can't even take screenshots from android because it keeps giving me "timeout" (but in the webview it loads after 1 2 minutes).

However, the problem is that if the .zip / cbz is immediately after the first folder (the one with the series name, usually), tachiyomi shows you the chapters / volumes. If there is even one subfolder in the series folder, tachiyomi tells me that he found no chapters / there aren't any.

Tachiyomi through the Mango extension is only a receiver of what Mango running on a server sends to it. (unless I'm REALLY mistaken and my assumption is wrong, coming from Komga which is how it's handled there)

So if you're trying to organize files in a folder structure like that on your Android with this extension, as far as I understood it, you're looking at the wrong extension I guess?

GlassedSilver avatar Sep 11 '21 21:09 GlassedSilver

@GlassedSilver ? You can't go wrong extension to use. Mango can only communicate with the extension "mango". Also there are no folder organization problems, this is because this is how mango works (unlike Komga which DOES NOT ALLOW SUBFOLDERS). The solution cannot be that I have to adapt myself to tachiyomi (or at least to the hierarchy that Komga uses). Therefore, I asked @hkalexling here if he could confirm if it was a bug this problem.

So there are 2 cases:

  • Who wrote the "Mango" extension, did not put that in the case of subfolders, the chapters must still be taken and put together (ignoring the subfolders, practically it is as if you were moving all the .zips from the subfolders to the main folder);

  • The "Mango" extension does its job, giving Tachiyomi the structure of my library ... Too bad that Tachiyomi doesn't read the subfolders and therefore all the series that have a subfolder are automatically ignored (maybe, because it goes right in the chapter scan process fails, thus bringing the result to 0 rather than totally crashing Tachiyomi).

THEY ARE JUST MY ASSUMPTIONS.

VegethB avatar Sep 11 '21 22:09 VegethB

I know how Komga works and what the difference is to Mango. Take a guess why I'm here. Because I figured Komga is conceptuallly leaning against supporting manga-specific usecases properly and instead resorts to blaming the user for having odd workflows. Sorry, but chapters are not books as in chapters don't have ISBNs.... I digress... No need to rant about that in here. :P

I was just trying to make sure you're not putting the items in a local hierarchy on your phone manually and then trying to use mango and its extension to sync that. Since you use mango fully self-managed and with hiearchy on the server-side it does seem that you encountered unexpected behavior, but I'll reserve judgement here because I don't know so you're rightfully asking hkalexling. :)

One thing I want to point out here though is this: if the extension receiving the files has to store them flattened we have to make sure that the flattened files don't cause file name collisions.

You might have a chapter 1 PER VOLUME. (not that that is a typical numbering to my knowledge, but what do I know, I've seen odder things in my lifetime)

Or something like "volume.cbz" residing in a "Volume 1" folder. Sure, we COULD blame bad naming here, but that's a bit cheap and in the end just causes the same: support tickets. Instead the collissions need to be detected and caught anyhow. Might as well one-way convert them.

Or teach Tachiyomi's dev team the way of the hierarchy folder system and that it is superior, at the very least equally as justified.

Might also be of value for its internal downloader for Mangadex, because Mangadex does have grouping by volume now as well. ;)

GlassedSilver avatar Sep 11 '21 22:09 GlassedSilver

I think @zFerry98 is not trying to organize the manga files on their phone. They have set up the files on their remote server correctly and can access them through the Mango web interface, but they are having trouble accessing the nested items in Tachiyomi through the extension.

To make sure everyone is on the same page, here's how Tachiyomi interacts with its extensions:

  1. The extension defines a list of functions callable from the main app. These include getMangaDetails , getChapterList, and getPageList.
  2. Tachiyomi then simply invokes these functions and wait for them to return data. When a user selects a manga, it invokes getChapterList to get and display the chapter list, and when the user opens a chapter it invokes getPageList to get the list of pages and their URLs.

Here's the base class for all sources: https://github.com/tachiyomiorg/tachiyomi/blob/12a593c3c69ad7767cce7a42f30af96a284474e5/app/src/main/java/eu/kanade/tachiyomi/source/Source.kt

So the issue is, the Mango extension can't just pass anything to Tachiyomi, and there's no getNestedMangaList function that we can override. I am not familiar with Tachiyomi but it likely has no support for nested folders. See https://github.com/tachiyomiorg/tachiyomi/issues/254#issuecomment-275941848

hkalexling avatar Sep 12 '21 00:09 hkalexling

@zFerry98 regarding the timeout issue, we have merged a PR that improves the overall performance of Mango #222. It's already in dev and we will make an official release soon. Hope it can resolve #186 and fix the timeout issue on Tachiyomi.

hkalexling avatar Sep 12 '21 00:09 hkalexling

@GlassedSilver Let me be clear, I'm not trying to offend Komga or the people who prefer it that way. Mango allows you to create a real manga collection ... as long as there is a format compatible with the reader and that's it (unlike Komga which pretends to be Manga server but does not have 1 half compatibility with the WORLD standard of manga).

Better understand the potential of Mango (really long):

image

image

In this case I put volume 0 (which is a separate manga) as an extra to the main series. This is because on Mango the 4 column view becomes "annoying" if there are 20 manga of the same series on the main page ... And this leads to other cool things like this: image image ... even better: image image image image Collection of "Fate Apocrypha" inside the collection of all "Fate" inside the root of the manga all together and all beautiful.

image image


This is called a "collection" ... however (at least for Komga) they cannot be displayed on the same page as the series (and the fact remains that you cannot make the collection in the collection as in mango). If we then count that Komga does not even support the sorting that the whole world uses for the names of chapters and .jpg/png files... Ex: 0.5; a, b, c; etc. ...I find it hard not to go wild if they tell me that Komga is also a manga server. Just open ANY site (mangadex just to name 1 ...) and ALL go to: Manga (folder1) > Volume XX (folder2) > Chapter XX.


I was just trying to make sure you're not putting the items in a local hierarchy on your phone manually and then trying to use mango and its extension to sync that. Since you use mango fully self-managed and with hiearchy on the server-side it does seem that you encountered unexpected behavior, but I'll reserve judgement here because I don't know so you're rightfully asking hkalexling. :)

I could never put 300gb of manga in my smartphone 😂. It's all on the server and all managed by Mango (otherwise you don't need the mango extension on tachiyomi, just put the manga in the folder that tachiyomi uses for the manga you want to add manually).

One thing I want to point out here though is this: if the extension receiving the files has to store them flattened we have to make sure that the flattened files don't cause file name collisions.

You might have a chapter 1 PER VOLUME. (not that that is a typical numbering to my knowledge, but what do I know, I've seen odder things in my lifetime)

Or something like "volume.cbz" residing in a "Volume 1" folder. Sure, we COULD blame bad naming here, but that's a bit cheap and in the end just causes the same: support tickets. Instead the collissions need to be detected and caught anyhow. Might as well one-way convert them.

To get around the problem (since it seems that the tachiyomi development team is unwilling to support nesting), just add the folder name to the file name, ex:

Another > Extra > Volume 1 > Ch. 1.zip
              > Volume 1 > Ch. 1.zip

we get in the chapters list:

Extra_Volume 1 - Ch. 1
Volume 1 - Ch. 1

or

Ch. 1 [Extra_Volume 1]
Ch. 1 [Volume 1]

However, it would be enough to add the name of the subfolder to the file name, then the extension will take care of it and reconvert the logical name into the real name of the file together with the logical path and the real one (to get the file from the server). Always if possible (since I don't know if there are limitations for what the extension can do or otherwise)


@zFerry98 regarding the timeout issue, we have merged a PR that improves the overall performance of Mango #222. It's already in dev and we will make an official release soon. Hope it can resolve #186 and fix the timeout issue on Tachiyomi.

😬 is already in use (the build you find in the pull request you mentioned)

which at first seemed to be fine ... then having added more series to the server it returned in total timeout (even if on the Web side I notice the improvement a lot). I think there is something wrong with how tachiyomi handles the request to populate the getMangaDetails you were talking about. At the moment, mango from the Web is fully enjoyable even if it runs on WSL1. I wanted to use it on tachiyomi because tachiyomi has a more complete and "graphically beautiful" reader (I don't know how to explain it) but above all it marks me the chapters I read on AniList and MAL.

Anyway thanks for the answers, I can assure you that I was seriously giving up on manga until I found this software months ago. I used to swear to the Tenma server and the like. Komga has become the server for DJ and Light Novels (since the latter are mostly without subfolders) image

VegethB avatar Sep 12 '21 10:09 VegethB

To get around the problem (since it seems that the tachiyomi development team is unwilling to support nesting), just add the folder name to the file name, ex:

Another > Extra > Volume 1 > Ch. 1.zip
              > Volume 1 > Ch. 1.zip

we get in the chapters list:

Extra_Volume 1 - Ch. 1
Volume 1 - Ch. 1

or

Ch. 1 [Extra_Volume 1]
Ch. 1 [Volume 1]

However, it would be enough to add the name of the subfolder to the file name, then the extension will take care of it and reconvert the logical name into the real name of the file together with the logical path and the real one (to get the file from the server). Always if possible (since I don't know if there are limitations for what the extension can do or otherwise)

@zFerry98 Then, is it ok that thousands of manga chapters in one series on tachiyomi? as I know, you have 35,000 entries with 40 top titles in your library. (out of story, are these 35,000 entries 300gb?) Anyway, what you mentioned could be possible by fixing mango extension. but sub folder names just would be concatenated for easy implementation. i.e.

Another > Extra > Volume 1 > Ch. 1.zip
        > Volume 1 > Ch. 1.zip

to

Another > Extra Volume 1 Ch. 1.zip
        > Volume 1 Ch. 1.zip

Leeingnyo avatar Sep 12 '21 12:09 Leeingnyo

Then, is it ok that thousands of manga chapters in one series on tachiyomi? as I know, you have 35,000 entries with 40 top titles in your library. (out of story, are these 35,000 entries 300gb?)

Now (from #209): image image

I was wondering where 35,000 came from ... It comes from here #79, we are talking about 1 year ago. I had put the folders as a library and mixed series that are now on Komga (what are now manga collections, some series were folders that served as a library ... since libraries are not yet supported). After several consultations with my friends, we came to the conclusion of separating the "libraries" between the two servers (also, especially since mango was very slow at the time). But despite the large number of files at the time (35,000) the mango root folder was about 70 80 gb. Now there are 27,000 but the content is completely different (only manga compared to DJs and Light Novels and manga together).

VegethB avatar Sep 12 '21 13:09 VegethB

Great discussion guys! I like the idea of concatenating the names of nested folders. I will work on this together with some other improvements for the extension.

hkalexling avatar Sep 12 '21 13:09 hkalexling

@zFerry98 Thank you for replying. Then It would be appeared about 200 entries at chapter list of each top title. is it ok?

@hkalexling I wrote the code in javascript for a PoC. I think replacing chapterListParse would be worked.

async function chapterListParse(url) {
    var response = await fetch(url);
    var json = await response.json(); // get contens as json
    
    var parse = (title) => {
        var deepEntries = [];
        var titles = [title];
        while (titles.length) {
            parseInternal(titles, deepEntries);
        }
        return deepEntries;
    }
    
    var parseInternal = (titles, array, prefix = '') => {
        if (titles.length === 0) return;
        const title = titles.shift();
        const titleId = title.id;
        const titleName = `${prefix}${prefix.length === 0 ? '' : ' '}${title.title}`;
        title.entries.forEach(entry => array.push({
            entry,
            titleId,
            titleName,
        }));
        titles.push(...title.titles);
    }
    
    var flattenEntries = parse(json);
    return flattenEntries.map(({ entry, titleId, titleName, }, index) => ({
        chapter_number: index + 1,
        name: `${index + 1} - ${titleName} ${entry.display_name}`,
        url: `/page/${titleId}/${entry.id}/${entry.pages}/`,
        date_upload: 1000 * entry.mtime,
    }));
}

var run = (titleId) => chapterListParse(`/api/book/${titleId}`);
run('your title id').then(console.log);

Leeingnyo avatar Sep 12 '21 13:09 Leeingnyo

Great discussion guys! I like the idea of concatenating the names of nested folders. I will work on this together with some other improvements for the extension.

Good to know 👍. I'm fighting with Tachiyomi to figure out what triggers the "timeout". Since tachiyomi does not give me clues (I also tried with the logcat reader but it does not find relevant results with "timeout", "192.168.1.2" and "mango" 😪), the only clue is the home page which is about 1 minute to show themselves. Because the "/library" page loads in no more than 5-10 seconds.

VegethB avatar Sep 12 '21 13:09 VegethB

@Leeingnyo Thanks that would be helpful! While we are at it, I also plan to allow sorting entries from the API as there's an issue on this for the extension: https://github.com/tachiyomiorg/tachiyomi-extensions/issues/7980

@zFerry98 I think I have an idea why you are getting timeout. Currently we don't have an API endpoint for returning the top-level titles, so the extension has to request /api/library, which returns the whole library as JSON. As you can imagine this would take a VERY long for large libraries. I will add a new endpoint for returning top-level titles only and it should resolve the issue.

hkalexling avatar Sep 12 '21 13:09 hkalexling

Then It would be appeared about 200 entries at chapter list of each top title. is it ok?

So my server explodes 😂. Root tree: output.txt

we are talking about 166 main series, based on the type of series there are from 4 to 24 volumes (some are gigantic series such as bleach with 74 volumes or one piece with 100 volumes and over 1000 chapters), on average a volume are or 4 chapters or 10. There are so many files for this. If we then count that some series are super ultra extreme high resolution (we are talking about 8k resolutions and some I thought they were even at 16k 🤣)

VegethB avatar Sep 12 '21 13:09 VegethB

@zFerry98 Dude, THANK YOU.

You have said everything that has ever been on my mind about Komga. I really appreciate the app for what it is for comics, although that's not really "my turf" anymore. I used to read the Micky Mouse magazine and the thicker "LTB"s as they are referenced here in Germany (Donald Duck comic books as in... books not mags)

Might come back to Komga again for that kinda stuff, but OH MY GOD you cannot properly organize manga in there without nannying the heck out of your chapters.

The application doesn't even TRY to read the chapter number and assign a proper "book number". The claim to "also be for manga" is as far fetched as anything else. You could say it can also be an image gallery viewer, because technically you can store and serve up images in there... Sure... But it's not supported properly. UX is a nightmare for manga users.

The second you have "off chapters" things get real ugly.

Anyways, my ranting could only just further repeat what you already so eloquently put. This is exactly why I came here. Everything you said speaks to me on so many levels.

One of the things I'm most passionate about is good, thorough and very detailed relational assignment (would be cool to mark one manga as a spin-off to another one within a franchise... huh? ;) @hkalexling), meta data support that's really strong rather than going the path of "let's be REALLLLLY considerate about which metadata we CANNOT live without... hey, everyone has very different needs how fine-grained they like their library to be managed and searchable. Oh and obviously good reading progress tracking.

The combination of read progress tracked from server (server app and Web Reader) to client (through Tachiyomi extension ideally and additionally mirroring progress to MAL, AniList and Kitsu as well!) is really... just... lovely!

That's the stuff I'm into! :D

As for DJs... yeah still under massive (re-)construction, but I'm closely watching the HappyPandaX project. The current application is a bit buggy and hard to understand at first, so my usage with it is on a hiatus at the moment, but the moment a new release drops I'll get into it with a test lib of some beloved doujis right away again. :D

As for LNs... well... would love to keep em next to the mangas they often are buddies with within the same franchise so... in Mango if possible.

Now... I'd get REALLY super overly happy to have really good doujinshi support in here as well, but right now HPX looks so promising... ARGH... especially since it already has such good meta data support and everything, just needs technical - not conceptual rework.

But the idea of... clicking on a franchise and seeing.... EVERYTHING associated with it at ONE GLANCE...

Manga, LN, Doujinshis... all under one roof! Imagine that! Ah beautiful!

And for stuff like fanart... well I do have my own Danbooru instance (LAN-only)... if I could link to the franchise tag's search query to my own danbooru instance from within Mango, maybe even embed results... side by side...

Basically a franchise viewer and everything I got on it is literally one click away.... Hey even... list my Steam games or such...

Okay I need to cool down... This is.... just heavenly fantasy. :D

GlassedSilver avatar Sep 13 '21 00:09 GlassedSilver

Also related: https://github.com/tachiyomiorg/tachiyomi/issues/1803

GlassedSilver avatar Sep 18 '21 18:09 GlassedSilver

@hkalexling Timeout again 😭🤣 with 0.24.0 test build. "timeout" out of thin air. I didn't touch anything, not even restarted or anything (server side). I haven't added any other series or anything. It just went back to giving timeouts.

VegethB avatar Sep 21 '21 20:09 VegethB