|
|
|
|
@ -1,6 +1,11 @@
|
|
|
|
|
package org.koitharu.kotatsu.test_util
|
|
|
|
|
|
|
|
|
|
import androidx.collection.ArraySet
|
|
|
|
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
|
|
|
|
import org.koitharu.kotatsu.parsers.model.Manga
|
|
|
|
|
import org.koitharu.kotatsu.parsers.model.MangaSource
|
|
|
|
|
import org.koitharu.kotatsu.parsers.model.RATING_UNKNOWN
|
|
|
|
|
import org.koitharu.kotatsu.parsers.util.toRelativeUrl
|
|
|
|
|
|
|
|
|
|
private val PATTERN_URL_ABSOLUTE = Regex("^https?://[\\s\\S]+", setOf(RegexOption.IGNORE_CASE))
|
|
|
|
|
private val PATTERN_URL_RELATIVE = Regex("^/[\\s\\S]+", setOf(RegexOption.IGNORE_CASE))
|
|
|
|
|
@ -36,4 +41,28 @@ internal inline fun <T, K> Collection<T>.maxDuplicates(selector: (T) -> K): K? {
|
|
|
|
|
inline operator fun <T> List<T>.component6(): T = get(5)
|
|
|
|
|
|
|
|
|
|
@Suppress("NOTHING_TO_INLINE")
|
|
|
|
|
inline operator fun <T> List<T>.component7(): T = get(6)
|
|
|
|
|
inline operator fun <T> List<T>.component7(): T = get(6)
|
|
|
|
|
|
|
|
|
|
fun mangaOf(source: MangaSource, url: String): Manga {
|
|
|
|
|
val httpUrl = url.toHttpUrl()
|
|
|
|
|
var id = 1125899906842597L
|
|
|
|
|
source.name.forEach { c -> id = 31 * id + c.code }
|
|
|
|
|
url.forEach { c -> id = 31 * id + c.code }
|
|
|
|
|
return Manga(
|
|
|
|
|
id = id,
|
|
|
|
|
title = httpUrl.pathSegments.last(),
|
|
|
|
|
altTitle = null,
|
|
|
|
|
url = url.toRelativeUrl(httpUrl.host),
|
|
|
|
|
publicUrl = url,
|
|
|
|
|
rating = RATING_UNKNOWN,
|
|
|
|
|
isNsfw = false,
|
|
|
|
|
coverUrl = "",
|
|
|
|
|
tags = emptySet(),
|
|
|
|
|
state = null,
|
|
|
|
|
author = null,
|
|
|
|
|
largeCoverUrl = null,
|
|
|
|
|
description = null,
|
|
|
|
|
chapters = null,
|
|
|
|
|
source = source,
|
|
|
|
|
)
|
|
|
|
|
}
|