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

Add Nijiero-ch extension 1.0 #3245

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 7 additions & 0 deletions src/all/nijiero/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ext {
extName = 'Nijiero'
extClass = '.Nijiero'
extVersionCode = 1
isNsfw = true
}
apply from: "$rootDir/common.gradle"
Binary file added src/all/nijiero/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/all/nijiero/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/all/nijiero/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/all/nijiero/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
package eu.kanade.tachiyomi.extension.all.nijiero

import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.model.UpdateStrategy
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.Request
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import java.text.SimpleDateFormat
import java.util.Locale

class Nijiero : ParsedHttpSource() {
override val name = "Nijiero"
override val lang = "all"
override val supportsLatest = true

override val baseUrl = "https://nijiero-ch.com"

override val client = network.cloudflareClient

class TagFilter : Filter.Select<String>("Category", nijieroTags)

override fun pageListParse(document: Document): List<Page> {
return document.select("#entry > ul > li a[href]").mapIndexed { i, linkElement ->
val linkUrl = linkElement.attr("href").removeSuffix(".webp")
Page(i, document.location(), linkUrl)
}
}

override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException()

private val spaceRegex = Regex("""\s+""")
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
val tagIdx: Int = (filters.last() as TagFilter).state

val keyword = when {
query.isBlank() -> nijieroTags[tagIdx]
else -> query
}.replace(spaceRegex, "-").lowercase()

val uniqueParam = System.currentTimeMillis()
var url = baseUrl.toHttpUrl().newBuilder()
.addEncodedPathSegment("category")
.addEncodedPathSegment(keyword)
.addEncodedPathSegment("page")
.addEncodedPathSegment(page.toString())
.addQueryParameter("refresh", uniqueParam.toString())
.build()

// if 404, recheck
if (client.newCall(GET(url, headers)).execute().code == 404) {
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be better to do this in an interceptor, so you can simply return the response as is if available or make new request and return it's response

Copy link
Author

Choose a reason for hiding this comment

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

This code should actually check if the current page was not found as a tag, so it tries again with category... not sure what you mean by that, sorry.

Copy link
Contributor

@AwkwardPeak7 AwkwardPeak7 May 28, 2024

Choose a reason for hiding this comment

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

I mean instead of make a call just to check if it exists, add an interceptor to detect it and make new call there.

basically return the tag request from here, in the interceptor prceed the call and check if it is 404 and url contains tag (this request) and if so, modify the request and call again, otherwise just return the original response.

something like this:

private fun tagCategoryInterceptor(chain: Interceptor.Chain): Response {
        val request = chain.request()
        val url = request.url.toString()
        val response = chain.proceed(request)

        if (!response.isSuccessful && response.code == 404 && url.contains("/category/")) {
            val newUrl = url.replace("/category/","/tag/")
            val newRequest = request.newBuilder()
                .url(newUrl)
                .build()
            
            return chain.proceed(newRequest)
        }

        return response
    }

url = baseUrl.toHttpUrl().newBuilder()
.addEncodedPathSegment("tag")
.addEncodedPathSegment(keyword)
.addEncodedPathSegment("page")
.addEncodedPathSegment(page.toString())
.addQueryParameter("refresh", uniqueParam.toString())
.build()
Comment on lines +58 to +64
Copy link
Contributor

@choppeh choppeh May 27, 2024

Choose a reason for hiding this comment

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

I couldn't find this path in the source

Copy link
Author

Choose a reason for hiding this comment

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

...? You mean, like, file path? If you mean the website, try $baseurl/tag/gif, that should exist.

// if there is a better solution just *tell me* .
}

return GET(url, headers)
}
override fun searchMangaNextPageSelector() = ".next.page-numbers"
override fun searchMangaSelector() = ".contentList > div:has(a)"
override fun searchMangaFromElement(element: Element) = SManga.create().apply {
element.select("a").let { link ->
element.selectFirst("img")?.let {
thumbnail_url = imageFromElement(it)
}
title = link.attr("title")
setUrlWithoutDomain(link.attr("href"))
initialized = true
}
}

override fun popularMangaRequest(page: Int): Request {
val uniqueParam = System.currentTimeMillis()
val url = baseUrl.toHttpUrl().newBuilder()
.addPathSegment("ranking.html")
.addQueryParameter("refresh", uniqueParam.toString())
.build()

return GET(url, headers)
}
override fun popularMangaNextPageSelector() = null
override fun popularMangaSelector() = "#mainContent .allRunkingArea.tabContent.cf > div"
override fun popularMangaFromElement(element: Element) = searchMangaFromElement(element)

override fun latestUpdatesRequest(page: Int): Request {
val uniqueParam = System.currentTimeMillis()
var url = baseUrl.toHttpUrl().newBuilder()
.addEncodedPathSegment("page")
.addEncodedPathSegment(page.toString())
.addQueryParameter("refresh", uniqueParam.toString())
.build()

return GET(url, headers)
}
override fun latestUpdatesNextPageSelector() = searchMangaNextPageSelector()
override fun latestUpdatesSelector() = "#mainContent > div:has(a)"
override fun latestUpdatesFromElement(element: Element) = searchMangaFromElement(element)

override fun mangaDetailsParse(document: Document): SManga = SManga.create().apply {
title = document.selectFirst("div.arrow.mb0 h1.type01_hl")?.text() ?: document.title()
thumbnail_url = document.select("meta[property=og:image]").attr("content")
status = SManga.COMPLETED
genre = getGenres(document)
update_strategy = UpdateStrategy.ONLY_FETCH_ONCE
}
private fun getGenres(document: Document): String {
val genres = document.select("dl.cf:contains(カテゴリ) a").map {
it.attr("href").trimEnd('/').split("/").last()
}.map {
it.replace("-", " ")
}
return genres.joinToString()
}
protected open fun imageFromElement(element: Element): String? {
return when {
element.hasAttr("data-src") -> element.attr("abs:data-src")
element.hasAttr("data-lazy-src") -> element.attr("abs:data-lazy-src")
element.hasAttr("srcset") -> element.attr("abs:srcset").substringBefore(" ")
element.hasAttr("data-cfsrc") -> element.attr("abs:data-cfsrc")
else -> element.attr("abs:src")
}
}

override fun chapterListSelector() = "html"
override fun chapterFromElement(element: Element) = SChapter.create().apply {
setUrlWithoutDomain(element.select("link[rel=canonical]").attr("abs:href"))
name = "GALLERY"
date_upload = parseDate(element.selectFirst("div.postInfo.cf div.postDate.cf time.entry-date.date.published.updated")?.attr("datetime").orEmpty())
}

private fun parseDate(dateStr: String): Long {
return runCatching { DATE_FORMATTER.parse(dateStr)?.time }
.getOrNull() ?: 0L
}

companion object {
private val DATE_FORMATTER by lazy {
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX", Locale.ENGLISH)
}
}

override fun getFilterList(): FilterList = FilterList(
Filter.Header("You can search for a tag or category, anything else will result in 404(NOT FOUND)."),
Filter.Header("To use category, make sure the search box is empty."),
TagFilter(),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
package eu.kanade.tachiyomi.extension.all.nijiero

public val nijieroTags = arrayOf(
vetleledaal marked this conversation as resolved.
Show resolved Hide resolved
"下着姿",
"トロ顔",
"69",
"anal",
"anime-game",
"anime-game/このすば",
"anime-game/5hanayome",
"anime-game/amagami",
"anime-game/azurlane",
"anime-game/bangdream",
"anime-game/eva-anime",
"anime-game/fagirl",
"anime-game/fairytail",
"anime-game/fate",
"anime-game/girls-und-panzer",
"anime-game/goblinslayer",
"anime-game/gochiusa",
"anime-game/granblue",
"anime-game/haruhi",
"anime-game/hidamari-sketch",
"anime-game/hinakonote",
"anime-game/idolmaster",
"anime-game/k-on",
"anime-game/kancolle",
"anime-game/kemono-friends",
"anime-game/kimetsu",
"anime-game/kinmosa",
"anime-game/lovelive",
"anime-game/magi",
"anime-game/nisekoi",
"anime-game/pokemon",
"anime-game/precure",
"anime-game/priconne",
"anime-game/raramagi",
"anime-game/releasethespyce",
"anime-game/saenai",
"anime-game/saki-anime",
"anime-game/senrankagura",
"anime-game/shingeki",
"anime-game/shoujozensen",
"anime-game/splatoon",
"anime-game/taimanin-yukikaze",
"anime-game/touhou-project",
"anime-game/trinity-7",
"anime-game/vocaloid",
"arm",
"arm-job",
"ass-job",
"bandaid",
"barefoot",
"bath",
"bitch",
"blindfold",
"boyish",
"bukkake",
"bunches",
"butt",
"choker",
"cim",
"clothing/bikini",
"clothing/bikini/sukumizu",
"clothing/bikini/swimsuit",
"clothing/bloomers",
"clothing/body-suit",
"clothing/bunny-girl",
"clothing/cheerleader",
"clothing/cheongsam",
"clothing/dress",
"clothing/garterbelt",
"clothing/gothic-lolita",
"clothing/kimono",
"clothing/lingerie",
"clothing/lingerie/loincloth",
"clothing/lingerie/sportsbra",
"clothing/maid-clothes",
"clothing/miko",
"clothing/nurse",
"clothing/onepiece",
"clothing/parker",
"clothing/santa-claus",
"clothing/shorts",
"clothing/sister",
"clothing/skirt",
"clothing/spats",
"clothing/stocking",
"clothing/suit",
"clothing/sweater",
"clothing/trousers",
"clothing/uniform",
"clothing/weddingdress",
"condom",
"creampie",
"cross-section",
"cum-shot",
"cunnilingus",
"cunt-juice",
"deepthroat",
"dildo",
"double",
"embarrass",
"erotic-humiliation",
"face",
"face/ahegao",
"face/crying",
"face/drool",
"face/teary-eyed",
"fellatio",
"fingering",
"flasher",
"footjob",
"gangbang",
"glasses",
"gyaru",
"hair-job",
"hair/black-hair",
"hair/blond",
"hair/hairstyle",
"hair/hairstyle/ponytail",
"hair/hairstyle/shorthair",
"hair/pink-hair",
"hair/silver-hair",
"handbra",
"handjob",
"harem",
"headphone",
"hermaphroditism",
"incest",
"jito",
"jk",
"kiss",
"knee-socks",
"kunoichi",
"lesbian",
"loli",
"masturbation",
"menheal",
"miko-clothing",
"milk",
"molest",
"naked",
"naked-apron",
"naked-shirt",
"non-erotic",
"non-person/elf",
"non-person/kemomimi",
"older-sister",
"on-all-four",
"otokonoko",
"outdoor-sex",
"pantsjob",
"pantyjob",
"peeing",
"piledriver",
"plump",
"pornographic-pose",
"pov",
"prostitution",
"pussy",
"pussy/cameltoe",
"rape",
"rape/male-rape",
"rut",
"school-uniform",
"sex",
"sex-after",
"sex/cowgirl-position",
"sex/daishuki-hold",
"sex/doggystyle",
"sex/doggystyle/spoons-position",
"sex/lost-virgin",
"sex/missionary-position",
"sex/side-position",
"sex/sitting-sex",
"sex/sitting-sex/背面座位",
"sex/sitting-sex/face-to-face-position",
"sex/standing",
"slave",
"sm",
"sm/m",
"sm/s",
"socks",
"sole",
"spread-pussy",
"squirt",
"stomach",
"straight-shota",
"subjectivity",
"swinger",
"tadpoling",
"tan-line",
"tasty",
"teacher",
"thighs",
"tiedup",
"tits",
"tits/big-tits",
"tits/cute-titties",
"tits/grope",
"tits/nice-boobs",
"tits/nipples",
"tittyfuck",
"toilet",
"torture",
"transvestite",
"tuckedup",
"tyakui",
"tyakui/half-naked",
"tyakui/wedgie",
"undressing",
"upskirt",
"uptight",
"various",
"virgin",
"words",
)