Skip to content
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

WNACG | Added support for ".jpeg" and fixed domain update #6101

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/zh/wnacg/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
extName = 'WNACG'
extClass = '.wnacg'
extVersionCode = 16
extVersionCode = 17
isNsfw = true
}

Expand Down
KenjieDec marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import uy.kohesive.injekt.api.get
import java.io.IOException
import kotlin.random.Random

private const val DEFAULT_LIST = "https://www.hm08.lol,https://www.hm09.lol,https://www.hm10.lol,https://www.hm06.lol,https://www.hm07.lol,https://www.hm05.lol,https://www.hm04.lol,https://www.hm01.lol,https://www.hm02.lol,https://www.hm03.lol,https://www.hm1.lol,https://www.hm2.lol,https://www.hm3.lol"
private const val DEFAULT_LIST = "https://www.wn01.uk,https://www.wn05.cc,https://www.wn04.cc,https://www.wn03.cc"

fun getPreferencesInternal(
context: Context,
Expand Down Expand Up @@ -71,7 +71,7 @@ class UpdateUrlInterceptor(private val preferences: SharedPreferences) : Interce

val failedResponse = try {
val response = chain.proceed(request)
if (response.isSuccessful) return response
if (response.isSuccessful && response.peekBody(Long.MAX_VALUE).string().contains("紳士漫畫")) return response
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could there be a cheaper check? What's the URL that returned successful code?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this effectively blocks away all images? Did you test your changes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least check the content-type like this
if (response.header("content-type")?.startsWith("text/html") != true) { return response }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide the problematic URL so we can decide what's the proper thing to do.

Copy link
Contributor Author

@KenjieDec KenjieDec Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, sorry for the late reply.

At least check the content-type like this if (response.header("content-type")?.startsWith("text/html") != true) { return response }

Hello, thanks for the suggestion. I'll try that! Thank you.

Please provide the problematic URL so we can decide what's the proper thing to do.|

Could there be a cheaper check? What's the URL that returned successful code?

Previous sites such as hm01.lol, hm02.lol, etc., are mostly parked, not dead, and they do return a status code of 200. And as for cheaper check, I'm not really sure, as this is what all I can think of to fix the issue, sorry.

Doesn't this effectively blocks away all images? Did you test your changes?

Sorry, I'm not quite sure what you mean. What images are you referring to? All images loaded just fine on my phone.

I might've misunderstood your suggestion, and I'm sorry if I did, as English is not my primary language. Thank you. 🙏

response.close()
Result.success(response)
} catch (e: Throwable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class wnacg : ParsedHttpSource(), ConfigurableSource {
}

override fun pageListParse(response: Response): List<Page> {
val regex = """//\S*(jpg|png|webp|gif)""".toRegex()
val regex = """//\S*(jpeg|jpg|png|webp|gif)""".toRegex()
val galleryaid =
response.body.string()
return regex.findAll(galleryaid).mapIndexedTo(ArrayList()) { index, match ->
Expand Down