manga-download / haruneko

Prototype of HakuNeko based on NW.js + TypeScript
https://haruneko-docs.pages.dev
129 stars 32 forks source link

Feature : improving language support for medias #115

Open MikeZeDev opened 1 year ago

MikeZeDev commented 1 year ago

Some random thoughts on how we could have better language support for medias.

{ id : 1234, title : One Piece, language : en_US }

instead of

{ 1234, "One Piece", en_US }

for clarity. This could help avoid errors because i think further. We may have to extract other things in the future and messing with values order will have disastrous effects.

This could event help in other cases : when you have to return a custom ID in copy/paste decorators, you are forced to rewrite FetchManga to match the rest of the code (think "API"). If extractor value got "id", use it instead of default (pathname or pathname+search according to arguments)

This way is more flexible as we can further expand it with stuff for animes : { audio : jp_JP, subtitles : [])

TLDR : Extractors revamping.

Now there are questions :

MikeZeDev commented 1 year ago
MikeZeDev commented 1 year ago

When fetching MANGAS :

1) Manga does not have a language per se

Manga language can be inferred from website language tag, providing it is UNIQUE and not "Multilingual". Plugins should then have only one language tag : its either "one language" or "multilingual" tag. Manga constructor should be affected.

2) Manga has language info (unique language) => we just need to set the good tag. Provide a language mapping table in plugin and a fallback just in case. Maybe we need a new "Tags.Language.Unknown"?

3) Manga has more than one language (when fetching said manga). > just set the "multilingual" tag

when fetching CHAPTERS:

1) Chapter has no language defined > use parent "Manga" language. If cases has been covered mangas should always have one.

2) Chapter has one language defined > give it the good tag

3) Chapter has multiple language : > Multi-language tag. I imagine the website API would provide different pages list for different language

MikeZeDev commented 1 year ago

There are special cases where external elements (sessions tokens, cookies, account parameters) are affecting content's language.

Such plugins may have language settings (to exclude languages) , custom initialization , a way to switch between languages if possible (for requests). As for tags, website plugin should have Multilingual tag.

Its possible that website use different ID for the same manga in different language, making it two mangas. If its the contrary we should make sure manga id is unique, maybe by adding langage code.

MikeZeDev commented 1 year ago

Sheep talked about an interesting case : suppose a website add a langage for a manga (not in another manga entry).

ronny1982 commented 12 months ago

As of now the language and translation group (if present) must be part of the title. This is by design since the title is used as folder name and should be unique for each manga/chapter.

In addition the Tags can be used to provide such meta information for the UI (maybe for filtering) e.g.,

const manga = new Manga(plugin, ...);
manga.Tags.push(Tags.Language.English);
manga.Tags.push(Tags.Language.French);

const chapter1 = new Chapter(manga, ...);
chapter1.Tags.push(Tags.Language.English);

const chapter2 = new Chapter(manga, ...);
chapter2.Tags.push(Tags.Language.French);

const chapter3 = new Chapter(manga, ...);
chapter3.Tags.push(...manga.Tags.filter(tag => tag.Category === R.Tags_Language));

Some of the use-cases should already be covered with this existing functionality.

MikeZeDev commented 7 months ago

Its good to add language tags to mangas but for now they are not saved, meaning its lost after program is closed.