Paperback-iOS / app

Repository to host app releases, issues, and feature requests for Paperback
https://paperback.moe/
661 stars 20 forks source link

[REQUEST] Extensions-common suggestions #255

Open FramboisePi opened 3 years ago

FramboisePi commented 3 years ago

Models

Manga

GameFuzzy commented 3 years ago

To add onto this, it would be nice if langCode for chapter objects would be optional and just default to LanguageCode.UNKNOWN. Same with longStrip for chapter details. Think it should just default to false.

ConradWeiser commented 3 years ago

I've taken a look through the App Source - It seems like a lot of these can be adjusted in Extensions-Common without any app change requirements

As such, I'm looking to make the following changes:

NOTE: Longstrip cannot be made optional without requiring an app-update. I will push this update through, although I will not be making them optional in the sources until this feature propagates to the public version of the app, thus not causing crashes for any version.

I do not think it's a good idea to default Language to unknown. I would like source developers to consciously input the unknown value if it is really unknown.

Explain the purpose of having both rating and avgRating and put them next to each other

Neither rating nor avgRating have any use currently, according to the App code.

FramboisePi commented 3 years ago

Komga also use ABANDONED and HIATUS status. Though I believe the idea is not to have to many status.

Being able to register multiple authors and artists could be useful. Some sources also have other fields like Editors


Manga use a string for langFlag and a string for langName Chapter use a LanguageCode for langCode

Chapter use a Date object for time. Manga use a string for lastUpdate

Is there, for both situation, a reason to use different type?


As it is possible to define the language of a manga with langFlag property I believe langCode could be optional, if a chapter does not define a language, the app would then use the one of the manga.

It would be useful for Komga where languages are available for manga but not chapters

ConradWeiser commented 3 years ago

Making a note here so that I don't forget later, I'd like to bundle in an adjustment to the unit tests allowing them to work through Cloudflare sources too.

Likely this will mean the switch from Axios internally, to a Headless Browser such as Puppeteer

GameFuzzy commented 3 years ago

Making a note here so that I don't forget later, I'd like to bundle in an adjustment to the unit tests allowing them to work through Cloudflare sources too.

Likely this will mean the switch from Axios internally, to a Headless Browser such as Puppeteer

I could maybe try to do this over the weekend

ConradWeiser commented 3 years ago

@GameFuzzy Ensure you're on the latest version of Extensions Common if you decide to give it a try! My suggestion is to keep the Axios implementation unless some kind of toggle is enabled in the Mocha tests.

You may override the current ApiWrapper class which the tests use, though you may be able to simply edit the schedule function which has the current Axios implementation if that ends up easier. Since tests are always going to be done in a NodeJS context, you can just use a environment variable if you really wanted to, globally throwing that setting to use a headless browser over.

There are some downsides with headless browsers. Specifically, you don't actually know when you're on the page you want without some tricks. I've made and attached a gist below which highlights some things you may want to try with Puppeteer to ensure that everything works correctly.

https://gist.github.com/ConradWeiser/91118a7488d8323faa2a977b247abd98

Obviously you'll have to mess with the contents a little, but it highlights the use of waitForSelector(selector: string) and waitForTimeout(ms: number)

tldr; Architect it in a way which makes sense!

GameFuzzy commented 3 years ago

Thanks, I’ll make use of all that

ConradWeiser commented 3 years ago

The prospect of using a Headless browser in the test framework isn't all too easy after some further investigation. An update to extensions-common has been staged which allows Axios to use the interceptors defined for each source which might be 'good enough'.

Is anyone familiar with how Cloudflare handles it's sessions? If in the testing framework, someone opens a Cloudflare website in their browser, and for the tests, copies the cookie information for their session into a request interceptor, would that work fine? Or would a differing useragent invalidate this method.


Changelog

See: https://github.com/Paperback-iOS/extensions-common/commit/251cd128165b5baa388e1310917fafcbb19cabb9

GameFuzzy commented 3 years ago

Is anyone familiar with how Cloudflare handles it's sessions? If in the testing framework, someone opens a Cloudflare website in their browser, and for the tests, copies the cookie information for their session into a request interceptor, would that work fine? Or would a differing useragent invalidate this method.

A different user-agent than the one included in the initial CloudFlare request messes things up, that I’m fairly sure of.