diff --git a/src/en/vizshonenjump/README.md b/src/en/vizshonenjump/README.md index 94f9854ff..ac29ada15 100644 --- a/src/en/vizshonenjump/README.md +++ b/src/en/vizshonenjump/README.md @@ -16,7 +16,7 @@ over at [Extension FAQ] or [Getting Started]. ### Why are some chapters missing? -VIZ Shonen Jump is a paid subscription-based service and you need an active monthly subscription to +**VIZ Shonen Jump** and **VIZ Manga** are paid subscription-based services and you need an active monthly subscription to be able to read most of the chapters available in their service. These locked chapters will be filtered out from the chapter list by default if you're not signed in. To sign in with your existing account, follow the guide available below. @@ -25,7 +25,7 @@ your existing account, follow the guide available below. ### Reading subscription-locked chapters -The **VIZ Shonen Jump** sources allows the reading of paid chapters if you have +The **VIZ** sources allows the reading of paid chapters if you have an active paid subscription on their service. > **Warning** diff --git a/src/en/vizshonenjump/build.gradle b/src/en/vizshonenjump/build.gradle index 791646ebd..efb96094a 100644 --- a/src/en/vizshonenjump/build.gradle +++ b/src/en/vizshonenjump/build.gradle @@ -3,10 +3,10 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlinx-serialization' ext { - extName = 'VIZ Shonen Jump' + extName = 'VIZ' pkgNameSuffix = 'en.vizshonenjump' - extClass = '.VizShonenJump' - extVersionCode = 18 + extClass = '.VizFactory' + extVersionCode = 19 } dependencies { diff --git a/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizShonenJump.kt b/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/Viz.kt similarity index 96% rename from src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizShonenJump.kt rename to src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/Viz.kt index 110aef2f9..cc5a87b1d 100644 --- a/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizShonenJump.kt +++ b/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/Viz.kt @@ -28,9 +28,10 @@ import java.text.SimpleDateFormat import java.util.Locale import java.util.concurrent.TimeUnit -class VizShonenJump : ParsedHttpSource() { - - override val name = "VIZ Shonen Jump" +open class Viz( + final override val name: String, + private val servicePath: String, +) : ParsedHttpSource() { override val baseUrl = "https://www.viz.com" @@ -48,7 +49,7 @@ class VizShonenJump : ParsedHttpSource() { override fun headersBuilder(): Headers.Builder = Headers.Builder() .add("User-Agent", USER_AGENT) .add("Origin", baseUrl) - .add("Referer", "$baseUrl/shonenjump") + .add("Referer", "$baseUrl/$servicePath") private val json: Json by injectLazy() @@ -62,7 +63,7 @@ class VizShonenJump : ParsedHttpSource() { .build() return GET( - url = "$baseUrl/read/shonenjump/section/free-chapters", + url = "$baseUrl/read/$servicePath/section/free-chapters", headers = newHeaders, cache = CacheControl.FORCE_NETWORK, ) @@ -115,9 +116,12 @@ class VizShonenJump : ParsedHttpSource() { override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable { if (query.startsWith(PREFIX_URL_SEARCH)) { + val url = query.substringAfter(PREFIX_URL_SEARCH) + val service = url.split("/")[1] + if (service != servicePath) return Observable.just(MangasPage(emptyList(), false)) return fetchMangaDetails( SManga.create().apply { - this.url = query.substringAfter(PREFIX_URL_SEARCH) + this.url = url this.title = "" this.initialized = false }, @@ -224,7 +228,7 @@ class VizShonenJump : ParsedHttpSource() { override fun pageListRequest(chapter: SChapter): Request { val mangaUrl = chapter.url .substringBefore("-chapter") - .replace("jump/", "jump/chapters/") + .replace("$servicePath/", "$servicePath/chapters/") val newHeaders = headersBuilder() .set("Referer", baseUrl + mangaUrl) diff --git a/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizShonenJumpDto.kt b/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizDto.kt similarity index 100% rename from src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizShonenJumpDto.kt rename to src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizDto.kt diff --git a/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizFactory.kt b/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizFactory.kt new file mode 100644 index 000000000..5bd95d0f1 --- /dev/null +++ b/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizFactory.kt @@ -0,0 +1,10 @@ +package eu.kanade.tachiyomi.extension.en.vizshonenjump + +import eu.kanade.tachiyomi.source.SourceFactory + +class VizFactory : SourceFactory { + override fun createSources() = listOf( + Viz("VIZ Shonen Jump", "shonenjump"), + Viz("VIZ Manga", "vizmanga"), + ) +} diff --git a/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizImageInterceptor.kt b/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizImageInterceptor.kt index 07b22530a..c31b4f2db 100644 --- a/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizImageInterceptor.kt +++ b/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizImageInterceptor.kt @@ -57,7 +57,7 @@ class VizImageInterceptor : Interceptor { .add("Accept", "*/*") .add("Origin", "https://www.viz.com") .add("Referer", "https://www.viz.com/") - .add("User-Agent", VizShonenJump.USER_AGENT) + .add("User-Agent", Viz.USER_AGENT) .build() return GET(url, headers) diff --git a/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizUrlActivity.kt b/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizUrlActivity.kt index b4fa4b7d2..eb91352f6 100644 --- a/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizUrlActivity.kt +++ b/src/en/vizshonenjump/src/eu/kanade/tachiyomi/extension/en/vizshonenjump/VizUrlActivity.kt @@ -22,7 +22,7 @@ class VizUrlActivity : Activity() { action = "eu.kanade.tachiyomi.SEARCH" putExtra( "query", - "${VizShonenJump.PREFIX_URL_SEARCH}/${pathSegments[0]}/chapters/$seriesSlug", + "${Viz.PREFIX_URL_SEARCH}/${pathSegments[0]}/chapters/$seriesSlug", ) putExtra("filter", packageName) }