Skip to content

Commit

Permalink
3.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
LagradOst committed Feb 11, 2024
1 parent 3593eb5 commit 0aa680e
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 61 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ android {
minSdkVersion 21
targetSdkVersion 34
versionCode 54
versionName "3.1.6"
versionName "3.1.7"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,7 @@ object BookDownloader2 {
val totalBytes = ArrayList<Byte>()
var progress = 0
val startedTime = System.currentTimeMillis()

file.parentFile?.mkdirs()
file.createNewFile()
val size = DEFAULT_BUFFER_SIZE
var lastUpdatedMs = 0L
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import com.lagradost.quicknovel.MainAPI
import com.lagradost.quicknovel.MainActivity.Companion.app
import com.lagradost.quicknovel.SearchResponse
import com.lagradost.quicknovel.fixUrlNull
import com.lagradost.quicknovel.mvvm.logError
import com.lagradost.quicknovel.newEpubResponse
import com.lagradost.quicknovel.newSearchResponse
import org.jsoup.Jsoup

class AnnasArchive : MainAPI() {
override val hasMainPage = false
Expand All @@ -23,13 +24,17 @@ class AnnasArchive : MainAPI() {

override suspend fun search(query: String): List<SearchResponse> {
val url = "$mainUrl/search?lang=&content=&ext=epub&sort=&q=$query"

val document = app.get(url).document
// they somehow comment out the shit????
val text = app.get(url).text.replace(Regex("<!--([\\W\\w]*?)-->")) {
it.groupValues[1]
}
val document = Jsoup.parse(text)
return document.select("div.mb-4 > div > a").mapNotNull { element ->
val href = fixUrlNull(element.attr("href")) ?: return@mapNotNull null
val poster = fixUrlNull(element.selectFirst("div.flex-none > div > img")?.attr("src"))
val name = element.selectFirst("div.relative > h3")?.text() ?: return@mapNotNull null
SearchResponse(name = name, url = href, posterUrl = poster, apiName = this.name)
newSearchResponse(name = name, url = href) {
posterUrl = fixUrlNull(element.selectFirst("div.flex-none > div > img")?.attr("src"))
}
}
}

Expand Down Expand Up @@ -69,26 +74,39 @@ class AnnasArchive : MainAPI() {
}

override suspend fun load(url: String): LoadResponse {
/* cloudflare
val md5Prefix = "$mainUrl/md5/"
if (url.startsWith(md5Prefix)) {
try {
return loadFromJsonUrl(url.removePrefix(md5Prefix))
} catch (t: Throwable) {
logError(t)
}
}
}*/

// backup non json parser
val document = app.get(url).document

return newEpubResponse(
name = document.selectFirst("main > div > div.text-3xl")?.ownText()!!,
url = url,
links = document.select("div.mb-6 > ul.mb-4 > li > a").mapNotNull { element ->
links = document.select("ul.mb-4 > li > a.js-download-link").mapNotNull { element ->
val link = fixUrlNull(element.attr("href")) ?: return@mapNotNull null
// member
if (link.contains("fast_download")) {
return@mapNotNull null
}
// cloudflare
if (link.contains("slow_download")) {
return@mapNotNull null
}
// no idea why this is in the js dl link
if (link.endsWith("/datasets")) {
return@mapNotNull null
}
extract(link, element.text())
}) {
posterUrl = document.selectFirst("main > div > img")?.attr("src")
posterUrl = document.selectFirst("main > div > div > img")?.attr("src")
author = document.selectFirst("main > div > div.italic")?.ownText()
synopsis = document.selectFirst("main > div > div.js-md5-top-box-description")?.text()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class FreewebnovelProvider : LibReadProvider() {
override val hasMainPage = true
override val iconId = R.drawable.icon_freewebnovel
override val iconBackgroundId = R.color.wuxiaWorldOnlineColor
override val removeHtml = true

override suspend fun loadMainPage(
page: Int,
Expand All @@ -36,6 +37,7 @@ class FreewebnovelProvider : LibReadProvider() {

override suspend fun loadHtml(url: String): String? {
val response = app.get(url)

val document = Jsoup.parse(
response.text
.replace("New novel chapters are published on Freewebnovel.com.", "")
Expand All @@ -44,7 +46,14 @@ class FreewebnovelProvider : LibReadProvider() {
""
)
)
return document.selectFirst("div.txt>.notice-text")?.html()
document.selectFirst("p")?.remove() // .m-read .txt sub, .m-read .txt p:nth-child(1)
/*for (e in document.select("p")) {
if (e.text().contains("The source of this ") || e.selectFirst("a")?.hasAttr("href") == true) {
e.remove()
}
}*/
document.selectFirst("div.txt>.notice-text")?.remove()
return document.selectFirst("div.txt")?.html()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ open class LibReadProvider : MainAPI() {
override val name = "LibRead"
override val mainUrl = "https://libread.com"
override val hasMainPage = true
open val removeHtml = false // because the two sites use .html or not for no reason

override val iconId = R.drawable.icon_libread

Expand Down Expand Up @@ -119,6 +120,7 @@ open class LibReadProvider : MainAPI() {
}

override suspend fun load(url: String): LoadResponse? {
val trimmed = url.trim().removeSuffix("/")
val response = app.get(url)
val document = response.document
val name = document.selectFirst("h1.tit")?.text() ?: return null
Expand All @@ -131,9 +133,15 @@ open class LibReadProvider : MainAPI() {
)
)

val prefix = if (removeHtml) {
trimmed.removeSuffix(".html")
} else {
trimmed
}

val data =
Jsoup.parse(chaptersDataphp.text.replace("""\""", "")).select("option").map { c ->
val cUrl = url + '/' + c.attr("value").split('/').last()
val cUrl = "$prefix/${c.attr("value").split('/').last()}" // url + '/' +
val cName = c.text().ifEmpty {
"chapter $c"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import com.lagradost.quicknovel.MainActivity.Companion.app
import org.jsoup.Jsoup
import org.jsoup.nodes.Element

class ReadNovelFullProvider : AllNovelProvider() { // todo check
/*class ReadNovelFullProvider : AllNovelProvider() { // todo check
override val mainUrl = "https://readnovelfull.com"
override val name = "ReadNovelFull"
override val ajaxUrl = "ajax/chapter-archive"
}
/*
}*/

class ReadNovelFullProvider : MainAPI() {
override val mainUrl = "https://readnovelfull.com"
override val name = "ReadNovelFull"
Expand All @@ -22,23 +22,20 @@ class ReadNovelFullProvider : MainAPI() {
).document

val headers = document.select("div.col-novel-main > div.list-novel > div.row")
if (headers.size <= 0) return emptyList()

return headers.mapNotNull { h ->
val divs = h.select("> div > div")
val poster = divs[0].selectFirst("> img")?.attr("src")?.replace("t-200x89", "t-300x439")
val titleHeader = divs[1].selectFirst("> h3.novel-title > a")
val href = titleHeader?.attr("href")
val title = titleHeader?.text()
val latestChapter = divs[2].selectFirst("> a > span")?.text()
SearchResponse(
title ?: return@mapNotNull null,
fixUrl(href ?: return@mapNotNull null),
fixUrlNull(poster),
null,
latestChapter,
this.name
)
//val latestChapter = divs[2].selectFirst("> a > span")?.text()
newSearchResponse(
name = title ?: return@mapNotNull null,
url = href ?: return@mapNotNull null
) {
posterUrl = fixUrlNull(poster)
}
}
}

Expand All @@ -56,19 +53,15 @@ class ReadNovelFullProvider : MainAPI() {
val header = document.selectFirst("div.col-info-desc")
val bookInfo = header?.selectFirst("> div.info-holder > div.books")
val title = bookInfo?.selectFirst("> div.desc > h3.title")?.text()
val poster = bookInfo?.selectFirst("> div.book > img")?.attr("src")

val desc = header?.selectFirst("> div.desc")
val rateInfo = desc?.selectFirst("> div.rate-info")
val votes =
rateInfo?.select("> div.small > em > strong > span")?.last()?.text()?.toIntOrNull()

val rate = rateInfo?.selectFirst("> div.rate")

val novelId = rate?.selectFirst("> div#rating")?.attr("data-novel-id")
?: throw Exception("novelId not found")
val rating = rate.selectFirst("> input")?.attr("value")?.toFloatOrNull()?.times(100)
?.toInt()

val syno = document.selectFirst("div.desc-text")?.text()

val infoMetas = desc.select("> ul.info-meta > li")

Expand All @@ -81,42 +74,37 @@ class ReadNovelFullProvider : MainAPI() {
return null
}

val author = getData("Author:")?.selectFirst("> a")?.text()
val tags = getData("Genre:")?.select("> a")?.map { it.text() }
val statusText = getData("Status:")?.selectFirst("> a")?.text()
val status = when (statusText) {
"Ongoing" -> STATUS_ONGOING
"Completed" -> STATUS_COMPLETE
else -> STATUS_NULL
}
val dataUrl = "$mainUrl/ajax/chapter-archive?novelId=$novelId"
val dataResponse = app.get(dataUrl)
val dataDocument =
Jsoup.parse(dataResponse.text) ?: throw ErrorLoadingException("invalid dataDocument")
val items =
dataDocument.select("div.panel-body > div.row > div > ul.list-chapter > li > a")
.mapNotNull {
ChapterData(
it.selectFirst("> span")?.text() ?: return@mapNotNull null,
fixUrl(it.attr("href")),
null,
null
newChapterData(
name = it.selectFirst("> span")?.text() ?: return@mapNotNull null,
url = it.attr("href") ?: return@mapNotNull null,
)
}
return StreamResponse(
url,
title ?: throw ErrorLoadingException("No name"),
items,
author,
poster,
rating,
votes,
null,
syno,
tags,
status
)
return newStreamResponse(
name = title ?: throw ErrorLoadingException("No name"),
url = url,
data = items
) {
author = getData("Author:")?.selectFirst("> a")?.text()
tags = getData("Genre:")?.select("> a")?.map { it.text() }
val statusText = getData("Status:")?.selectFirst("> a")?.text()
status = when (statusText) {
"Ongoing" -> STATUS_ONGOING
"Completed" -> STATUS_COMPLETE
else -> STATUS_NULL
}
synopsis = document.selectFirst("div.desc-text")?.text()
rating = rate.selectFirst("> input")?.attr("value")?.toFloatOrNull()?.times(100)
?.toInt()
peopleVoted =
rateInfo.select("> div.small > em > strong > span")?.last()?.text()?.toIntOrNull()
posterUrl = bookInfo.selectFirst("> div.book > img")?.attr("src")
}
}
}
*/
4 changes: 2 additions & 2 deletions app/src/main/java/com/lagradost/quicknovel/util/Apis.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.lagradost.quicknovel.providers.*

class Apis {
companion object {
val apis: Array<MainAPI> = arrayOf(
val apis: List<MainAPI> = arrayOf(
//AllProvider(),
// NovelPassionProvider(), // Site gone
BestLightNovelProvider(),
Expand Down Expand Up @@ -48,7 +48,7 @@ class Apis {
IndoWebNovelProvider(),
SakuraNovelProvider(),
WattpadProvider(),
)
).sortedBy { it.name }

fun getApiFromName(name: String): APIRepository {
return getApiFromNameOrNull(name) ?: APIRepository(apis[1])
Expand Down

0 comments on commit 0aa680e

Please sign in to comment.