-
Notifications
You must be signed in to change notification settings - Fork 550
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
Rewrite MangaTube extension #7241
base: main
Are you sure you want to change the base?
Conversation
This commit includes a complete rewrite of the MangaTube extension, improving functionality and compatibility by leveraging the backend API and adopting models for a cleaner architecture.
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { | ||
val url = "$baseUrl/api/manga/search?page=$page&query=$query" | ||
|
||
Log.d("MangaTube", "Search for: $query") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove logs
|
||
private val json: Json by injectLazy() | ||
return GET(url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return GET(url) | |
return GET(url, headers) |
pass headers to set appropriate useragent and other headers to requests
.map { response -> | ||
parseMangaFromJson(response, page < 96) | ||
if(!res.success){ | ||
throw Exception("Something went wrong!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can it be more specific?
mangas[manga.title] = manga | ||
SManga.create().apply { | ||
title = manga.title | ||
url = "$baseUrl${manga.url}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set relative urls or slug/id
genre = manga.genre.map { genre -> Genre.fromId(genre)!! } | ||
.joinToString(", ") { genre -> genre.displayName } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
genre = manga.genre.map { genre -> Genre.fromId(genre)!! } | |
.joinToString(", ") { genre -> genre.displayName } | |
genre = manga.genre.joinToString { genre -> Genre.fromId(genre)!!.displayName } |
} | ||
|
||
override fun latestUpdatesSelector() = "div#series-updates div.series-update:not([style\$=none])" | ||
override fun latestUpdatesParse(response: Response): MangasPage { | ||
val body = MangaTubeHelper.checkResponse(response) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider calling this method in an interceptor since you are checking response every time
} | ||
|
||
override fun latestUpdatesNextPageSelector() = "button#load-more-updates" | ||
override fun mangaDetailsRequest(manga: SManga): Request { | ||
val url = "$baseUrl/api/manga/${mangas[manga.title]!!.id}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
save the id in the actual SManga url when returning, the hashmap above will not be initialized on app restart
this.contains("abgeschlossen", ignoreCase = true) -> SManga.COMPLETED | ||
else -> SManga.UNKNOWN | ||
override fun chapterListRequest(manga: SManga): Request { | ||
val url = "$baseUrl/api/manga/${mangas[manga.title]!!.slug}/chapters" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
url = "$baseUrl${chapter.readerURL}" | ||
name = chapter.name.ifBlank { "Chapter ${chapter.number}" } | ||
date_upload = | ||
SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(chapter.publishedAt)!!.time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialize `SimpleDateFormat in the class to avoide initializing it every time, and wrap the parsing in try catch to avoide breaking in case of bad dates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider creating one dto file with all the dtos in the package root (not in dto subpackage).
also use regular classes instead of data class unless needed
This commit includes a complete rewrite of the MangaTube extension, improving functionality and compatibility by leveraging the backend API and adopting models for a cleaner architecture.
Checklist:
extVersionCode
value inbuild.gradle
for individual extensionsoverrideVersionCode
orbaseVersionCode
as needed for all multisrc extensionsisNsfw = true
flag inbuild.gradle
when appropriateid
if a source's name or language were changedweb_hi_res_512.png
when adding a new extensionIssues Closed
Closes #4240
Closes #4112
Notes for Reviewers
This rewrite uses the backend API of MangaTube instad of crawling the data, this should be faster
Users must open the webview for IP verification if their IP is not pre-approved by MangaTube.
This is my first pull request, and I'm open to feedback. Please let me know if any changes or improvements are needed!