Fix Bilibili URL intent (#10104)
* Fix Bilibili URL intent. * Add chapter image format preference. Co-authored-by: FourTOne5 <59261191+FourTOne5@users.noreply.github.com> * Remove isNsfw from extension. Co-authored-by: FourTOne5 <59261191+FourTOne5@users.noreply.github.com>
This commit is contained in:
parent
26b1407331
commit
ea29bd30b1
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
<application>
|
<application>
|
||||||
<activity
|
<activity
|
||||||
android:name=".en.bilibilicomics.BilibiliComicsUrlActivity"
|
android:name=".all.bilibili.BilibiliUrlActivity"
|
||||||
android:excludeFromRecents="true"
|
android:excludeFromRecents="true"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:theme="@android:style/Theme.NoDisplay">
|
android:theme="@android:style/Theme.NoDisplay">
|
||||||
|
@ -33,6 +33,16 @@
|
||||||
android:host="m.bilibilicomics.com"
|
android:host="m.bilibilicomics.com"
|
||||||
android:pathPattern="/detail/mc..*"
|
android:pathPattern="/detail/mc..*"
|
||||||
android:scheme="https" />
|
android:scheme="https" />
|
||||||
|
|
||||||
|
<data
|
||||||
|
android:host="manga.bilibili.com"
|
||||||
|
android:pathPattern="/detail/mc..*"
|
||||||
|
android:scheme="https" />
|
||||||
|
|
||||||
|
<data
|
||||||
|
android:host="manga.bilibili.com"
|
||||||
|
android:pathPattern="/m/detail/mc..*"
|
||||||
|
android:scheme="https" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
|
@ -6,8 +6,7 @@ ext {
|
||||||
extName = 'BILIBILI'
|
extName = 'BILIBILI'
|
||||||
pkgNameSuffix = 'all.bilibili'
|
pkgNameSuffix = 'all.bilibili'
|
||||||
extClass = '.BilibiliFactory'
|
extClass = '.BilibiliFactory'
|
||||||
extVersionCode = 1
|
extVersionCode = 2
|
||||||
isNsfw = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
@ -79,9 +79,7 @@ abstract class Bilibili(
|
||||||
|
|
||||||
protected open val resolutionPrefTitle: String = "Chapter image resolution"
|
protected open val resolutionPrefTitle: String = "Chapter image resolution"
|
||||||
|
|
||||||
protected open val resolutionPrefEntries: Array<String> = arrayOf("Raw", "HD", "SD")
|
protected open val imagePrefTitle: String = "Chapter image format"
|
||||||
|
|
||||||
protected open val resolutionPrefEntryValues: Array<String> = arrayOf("@1200w.jpg", "@800w.jpg", "@600w_50q.jpg")
|
|
||||||
|
|
||||||
private val preferences: SharedPreferences by lazy {
|
private val preferences: SharedPreferences by lazy {
|
||||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||||
|
@ -92,6 +90,9 @@ abstract class Bilibili(
|
||||||
private val chapterImageResolution: String
|
private val chapterImageResolution: String
|
||||||
get() = preferences.getString("${RESOLUTION_PREF_KEY}_$lang", RESOLUTION_PREF_DEFAULT_VALUE)!!
|
get() = preferences.getString("${RESOLUTION_PREF_KEY}_$lang", RESOLUTION_PREF_DEFAULT_VALUE)!!
|
||||||
|
|
||||||
|
private val chapterImageFormat: String
|
||||||
|
get() = preferences.getString("${IMAGE_FORMAT_PREF_KEY}_$lang", IMAGE_FORMAT_PREF_DEFAULT_VALUE)!!
|
||||||
|
|
||||||
override fun popularMangaRequest(page: Int): Request {
|
override fun popularMangaRequest(page: Int): Request {
|
||||||
val requestPayload = buildJsonObject {
|
val requestPayload = buildJsonObject {
|
||||||
put("area_id", -1)
|
put("area_id", -1)
|
||||||
|
@ -376,8 +377,10 @@ abstract class Bilibili(
|
||||||
}
|
}
|
||||||
|
|
||||||
val imageQuality = chapterImageResolution
|
val imageQuality = chapterImageResolution
|
||||||
|
val imageFormat = chapterImageFormat
|
||||||
|
|
||||||
val imageTokenRequest = imageTokenRequest(result.data!!.images.map { it.path + imageQuality })
|
val imageUrls = result.data!!.images.map { "${it.path}@$imageQuality.$imageFormat" }
|
||||||
|
val imageTokenRequest = imageTokenRequest(imageUrls)
|
||||||
val imageTokenResponse = client.newCall(imageTokenRequest).execute()
|
val imageTokenResponse = client.newCall(imageTokenRequest).execute()
|
||||||
val imageTokenResult = imageTokenResponse.parseAs<List<BilibiliPageDto>>()
|
val imageTokenResult = imageTokenResponse.parseAs<List<BilibiliPageDto>>()
|
||||||
|
|
||||||
|
@ -409,8 +412,8 @@ abstract class Bilibili(
|
||||||
val resolutionPref = ListPreference(screen.context).apply {
|
val resolutionPref = ListPreference(screen.context).apply {
|
||||||
key = "${RESOLUTION_PREF_KEY}_$lang"
|
key = "${RESOLUTION_PREF_KEY}_$lang"
|
||||||
title = resolutionPrefTitle
|
title = resolutionPrefTitle
|
||||||
entries = resolutionPrefEntries
|
entries = RESOLUTION_PREF_ENTRIES
|
||||||
entryValues = resolutionPrefEntryValues
|
entryValues = RESOLUTION_PREF_ENTRY_VALUES
|
||||||
setDefaultValue(RESOLUTION_PREF_DEFAULT_VALUE)
|
setDefaultValue(RESOLUTION_PREF_DEFAULT_VALUE)
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
|
|
||||||
|
@ -425,7 +428,27 @@ abstract class Bilibili(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val imageFormatPref = ListPreference(screen.context).apply {
|
||||||
|
key = "${IMAGE_FORMAT_PREF_KEY}_$lang"
|
||||||
|
title = imagePrefTitle
|
||||||
|
entries = IMAGE_FORMAT_PREF_ENTRIES
|
||||||
|
entryValues = IMAGE_FORMAT_PREF_ENTRY_VALUES
|
||||||
|
setDefaultValue(IMAGE_FORMAT_PREF_DEFAULT_VALUE)
|
||||||
|
summary = "%s"
|
||||||
|
|
||||||
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
|
val selected = newValue as String
|
||||||
|
val index = findIndexOfValue(selected)
|
||||||
|
val entry = entryValues[index] as String
|
||||||
|
|
||||||
|
preferences.edit()
|
||||||
|
.putString("${IMAGE_FORMAT_PREF_KEY}_$lang", entry)
|
||||||
|
.commit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
screen.addPreference(resolutionPref)
|
screen.addPreference(resolutionPref)
|
||||||
|
screen.addPreference(imageFormatPref)
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract fun getAllGenres(): Array<BilibiliTag>
|
abstract fun getAllGenres(): Array<BilibiliTag>
|
||||||
|
@ -504,8 +527,15 @@ abstract class Bilibili(
|
||||||
const val PREFIX_ID_SEARCH = "id:"
|
const val PREFIX_ID_SEARCH = "id:"
|
||||||
private val ID_SEARCH_PATTERN = "^id:(mc)?(\\d+)$".toRegex()
|
private val ID_SEARCH_PATTERN = "^id:(mc)?(\\d+)$".toRegex()
|
||||||
|
|
||||||
private const val RESOLUTION_PREF_KEY = "imageResolution"
|
private const val RESOLUTION_PREF_KEY = "chapterImageResolution"
|
||||||
private const val RESOLUTION_PREF_DEFAULT_VALUE = ""
|
private val RESOLUTION_PREF_ENTRIES = arrayOf("Raw", "HD", "SD")
|
||||||
|
private val RESOLUTION_PREF_ENTRY_VALUES = arrayOf("1200w", "800w", "600w_50q")
|
||||||
|
private val RESOLUTION_PREF_DEFAULT_VALUE = RESOLUTION_PREF_ENTRY_VALUES[0]
|
||||||
|
|
||||||
|
private const val IMAGE_FORMAT_PREF_KEY = "chapterImageFormat"
|
||||||
|
private val IMAGE_FORMAT_PREF_ENTRIES = arrayOf("JPG", "WEBP", "PNG")
|
||||||
|
private val IMAGE_FORMAT_PREF_ENTRY_VALUES = arrayOf("jpg", "webp", "png")
|
||||||
|
private val IMAGE_FORMAT_PREF_DEFAULT_VALUE = IMAGE_FORMAT_PREF_ENTRY_VALUES[0]
|
||||||
|
|
||||||
private const val THUMBNAIL_RESOLUTION = "@512w.jpg"
|
private const val THUMBNAIL_RESOLUTION = "@512w.jpg"
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,9 @@ class BilibiliManhua : Bilibili("哔哩哔哩漫画", "https://manga.bilibili.co
|
||||||
// Machine translated, needs to be revisited.
|
// Machine translated, needs to be revisited.
|
||||||
override val resolutionPrefTitle: String = "章节图像分辨率"
|
override val resolutionPrefTitle: String = "章节图像分辨率"
|
||||||
|
|
||||||
|
// Machine translated, needs to be revisited.
|
||||||
|
override val imagePrefTitle: String = "章节图像格式"
|
||||||
|
|
||||||
override fun getAllStatus(): Array<String> = arrayOf("全部", "连载", "完结")
|
override fun getAllStatus(): Array<String> = arrayOf("全部", "连载", "完结")
|
||||||
|
|
||||||
override fun getAllSortOptions(): Array<String> = arrayOf("人气推荐", "更新时间", "追漫人数", "上架时间")
|
override fun getAllSortOptions(): Array<String> = arrayOf("人气推荐", "更新时间", "追漫人数", "上架时间")
|
||||||
|
|
|
@ -23,7 +23,7 @@ class BilibiliUrlActivity : Activity() {
|
||||||
|
|
||||||
val pathSegments = intent?.data?.pathSegments
|
val pathSegments = intent?.data?.pathSegments
|
||||||
if (pathSegments != null && pathSegments.size > 1) {
|
if (pathSegments != null && pathSegments.size > 1) {
|
||||||
val titleId = pathSegments[1]
|
val titleId = if (pathSegments.size == 3) pathSegments[2] else pathSegments[1]
|
||||||
|
|
||||||
val mainIntent = Intent().apply {
|
val mainIntent = Intent().apply {
|
||||||
action = "eu.kanade.tachiyomi.SEARCH"
|
action = "eu.kanade.tachiyomi.SEARCH"
|
||||||
|
|
Loading…
Reference in New Issue