完善哔哩哔哩双图回复回执校验

回执核对原评论线程、唯一正文及全部绑定图片顺序,补充回复总数校验与回归测试。

记录真机双图入口复查结果,更新拾见 0.1.25 使用说明和开发进度。
This commit is contained in:
2026-11-27 10:47:56 +08:00
parent 1bb9b022fe
commit d7071dc40b
9 changed files with 112 additions and 16 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ powershell -NoProfile -File ./scripts/verify-apk.ps1
选择「小红书」后,可设置单次任务笔记上限和每条笔记回复上限。任务会按内容类型搜索,停留到设定时长后返回结果列表打开下一条笔记。部分 vivo 设备首次会弹出跨应用打开提示,确认是「拾见」打开「小红书」后可选择「始终打开」。若等待超时,返回拾见点「继续任务」。
选择「哔哩哔哩」后,任务按普通视频计数。在 vivo Android 12 的哔哩哔哩 9.21.0 上,同一视频的顶层评论有图片按钮,指向原评论的楼中楼回复框和「插入内容」面板均没有图片选项。拾见会在提交前暂停带图任务,并保留当前视频进度。该设备上的新版回复界面仍待完成实发和自动回执验收。 [哔哩哔哩发图说明](https://www.bilibili.com/opus/752428294212681795)
选择「哔哩哔哩」后,任务按普通视频计数。在 vivo Android 12 的哔哩哔哩 9.21.0 上,顶层评论有图片按钮。楼中楼回复填入正文后依然没有图片按钮,「插入内容」打开视频和专栏搜索。拾见会在提交前暂停带图任务,并保留当前视频进度。该设备上的新版回复界面仍待完成实发和自动回执验收。 [哔哩哔哩发图说明](https://www.bilibili.com/opus/752428294212681795)
4. 在「任务」点「开始任务」。保持手机解锁,由拾见打开目标平台。运行期间让目标平台留在前台。在拾见任务页或用通知栏按钮可暂停。登录、验证、页面布局不可识别等中断可在手机处理后点「继续任务」。
5. 发送后,拾见尝试核对原评论下新增的本人回复,匹配正文和同一回复内的全部绑定图片后登记回执。图文自动核对需要 Android 11 或更新版本,图片比对在手机内存中完成。待核对卡片出现「自动核对回复」时,可让拾见再次查找并核对这条回复。若仍显示待核对,可到原评论下核对正文及图片,再选择「确认已发送」或「跳过此回复」。待核对期间会阻止自动重发。
+2 -2
View File
@@ -13,8 +13,8 @@ android {
applicationId = "com.jieliu.app"
minSdk = 26
targetSdk = 35
versionCode = 25
versionName = "0.1.24"
versionCode = 26
versionName = "0.1.25"
}
compileOptions {
@@ -243,15 +243,19 @@ internal class BilibiliComments(
private fun UiPage.hasEditor(): Boolean = nodes.any { it.editable && it.focused }
private fun UiPage.rows(list: UiNode, videoKey: String): List<Row> {
val parsed = parsedRows(list, videoKey)
val counts = parsed.groupingBy { it.target.key }.eachCount()
return parsed.filter { counts[it.target.key] == 1 }
}
private fun UiPage.parsedRows(list: UiNode, videoKey: String): List<Row> {
val viewport = Rect(list.bounds)
val parsed = if (BilibiliComposeComments.isList(this, list)) {
return if (BilibiliComposeComments.isList(this, list)) {
BilibiliComposeComments.rows(this, list) { author, body ->
CommentTarget(commentKey(videoKey, author, body), body, author)
}
} else nodes.filter { it.directParent() === list && viewport.contains(it.bounds) }
.mapNotNull { row(it, videoKey) }
val counts = parsed.groupingBy { it.target.key }.eachCount()
return parsed.filter { counts[it.target.key] == 1 }
}
private fun UiPage.row(container: UiNode, videoKey: String): Row? {
@@ -328,13 +332,14 @@ internal class BilibiliComments(
}
private fun UiPage.threadRows(list: UiNode, videoKey: String, target: CommentTarget): ThreadRows? {
val rows = rows(list, videoKey)
val rows = parsedRows(list, videoKey)
val original = rows.firstOrNull()?.takeIf { it.target == target } ?: return null
val children = nodes.filter { it.directParent() === list && list.bounds.contains(it.bounds) }
val complete = if (BilibiliComposeComments.isList(this, list)) {
BilibiliComposeComments.completeThread(this, list, rows.size - 1)
} else !list.supports(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) &&
!list.supports(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD) && children.none { child ->
!list.supports(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD) && nativeThreadTotalMatches(children, rows.size - 1) &&
children.none { child ->
val members = members(child)
child.labels().any(::blocksThreadCompletion) || members.any { it.labels().any(::blocksThreadCompletion) } ||
members.any { it.resourceId in setOf("item_include_header", "name_layout") } && row(child, videoKey) == null
@@ -342,6 +347,13 @@ internal class BilibiliComments(
return ThreadRows(original, rows.drop(1), complete)
}
private fun UiPage.nativeThreadTotalMatches(children: List<UiNode>, nestedCount: Int): Boolean = children.all { child ->
val totals = nodes.filter { it.directParent() === child && it.resourceId == "count_view" }
if (totals.isEmpty() || nodes.none { it.directParent() === child && it.resourceId == "sort" }) return@all true
val total = totals.singleOrNull() ?: return@all false
total.labels().mapNotNull(BilibiliLabels::detailReplyTotal).distinct().singleOrNull() == nestedCount
}
private fun blocksThreadCompletion(label: String): Boolean =
label in setOf("展开更多评论", "查看更多回复", "加载中", "加载失败", "点击重试")
@@ -51,7 +51,7 @@ internal object BilibiliComposeComments {
): List<BilibiliComments.Row> {
if (!isList(page, list)) return emptyList()
val siblings = page.children(list)
val parsed = siblings.mapIndexedNotNull { index, row ->
return siblings.mapIndexedNotNull { index, row ->
val identity = rowIdentity(page, list, row) ?: return@mapIndexedNotNull null
val author = identity.author.text
val body = identity.body
@@ -74,8 +74,6 @@ internal object BilibiliComposeComments {
photos(page, row, body.bounds, reply.label.bounds), own, threadEntry, emptyThread,
)
}
val counts = parsed.groupingBy { it.target.key }.eachCount()
return parsed.filter { counts[it.target.key] == 1 }
}
/** The native count must account for every visible nested row before proving a full thread. */
@@ -4,10 +4,14 @@ import com.jieliu.app.task.RECHECK_WINDOW_MS
internal object BilibiliLabels {
private val replyCount = Regex("(?:(?:全部|查看|展开|共)\\s*)?(\\d+)\\s*条回复(?:\\s*[>>])?")
private val detailTotal = Regex("相关回复(?:共)?\\s*(\\d+)\\s*条")
private val relativeTime = Regex("^(刚刚|[1-9]\\d?\\s*(?:秒|分钟)前)(?:\\s|$)")
fun replyCount(label: String): Int? = replyCount.matchEntire(label)?.groupValues?.get(1)?.toIntOrNull()
fun detailReplyTotal(label: String): Int? = detailTotal.matchEntire(label)?.groupValues?.get(1)?.toIntOrNull()
?: replyCount(label) ?: label.toIntOrNull()?.takeIf { it >= 0 }
fun replyPrompt(label: String, author: String): Boolean {
if (author.isBlank()) return false
return listOf("回复 @", "回复@", "回复 ", "回复").any { prefix ->
@@ -0,0 +1,18 @@
package com.jieliu.app.platform
internal object BilibiliReceiptEvidence {
fun <Row> uniqueReply(
expectedOriginal: CommentTarget,
original: CommentTarget,
threadComplete: Boolean,
expectedText: String,
replies: List<Row>,
bodyOf: (Row) -> String,
): Row? {
if (original != expectedOriginal || !threadComplete) return null
return replies.singleOrNull { bodyOf(it) == expectedText }
}
fun matchesOrderedPhotos(expected: List<PhotoPixels>, actual: List<PhotoPixels>): Boolean =
expected.size == actual.size && expected.indices.all { PublishedPhotoMatcher.matches(expected[it], actual[it]) }
}
@@ -194,7 +194,7 @@ internal class BilibiliReplies(
if (!initial.own && inspectRole(target, null, initial.key, readReceipt) != Role.OTHER) return CommentPublishResult.UNCERTAIN
val current = ui.await(5_000) { readReceipt()?.takeIf { it.key == initial.key } } ?: return CommentPublishResult.UNCERTAIN
if (!verifyImages(current.images, references) { readReceipt()?.takeIf { it.key == initial.key }?.images }) {
if (!verifyImages(current.images, references) { readReceipt()?.takeIf { it == current }?.images }) {
return CommentPublishResult.UNCERTAIN
}
if (references.isNotEmpty()) diagnostic("哔哩哔哩已按顺序核对原回复的全部图片")
@@ -205,7 +205,9 @@ internal class BilibiliReplies(
private fun receiptRow(target: CommentTarget, text: String, count: Int, armedAt: Long): ReceiptRow? =
comments.readThread(target) { page, thread ->
val row = thread.replies.singleOrNull { it.target.text == text } ?: return@readThread null
val row = BilibiliReceiptEvidence.uniqueReply(
target, thread.original.target, thread.complete, text, thread.replies,
) { it.target.text } ?: return@readThread null
val time = row.time ?: return@readThread null
if (!BilibiliLabels.matchesSubmissionTime(time, armedAt, System.currentTimeMillis())) return@readThread null
val pictures = row.images?.takeIf { it.size == count } ?: return@readThread null
@@ -248,8 +250,7 @@ internal class BilibiliReplies(
private fun verifyImages(snapshot: ImageView, expected: List<PhotoPixels>, readBack: () -> ImageView?): Boolean {
val actual = ui.screenshotPhotos(snapshot.window, snapshot.regions) ?: return false
return readBack() == snapshot && actual.size == expected.size &&
expected.indices.all { PublishedPhotoMatcher.matches(expected[it], actual[it]) }
return readBack() == snapshot && BilibiliReceiptEvidence.matchesOrderedPhotos(expected, actual)
}
private fun imageView(page: UiPage, pictures: List<UiNode>): ImageView? {
@@ -0,0 +1,56 @@
package com.jieliu.app.platform
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertSame
import org.junit.Assert.assertTrue
import org.junit.Test
class BilibiliReceiptEvidenceTest {
private data class Reply(val body: String, val photos: List<PhotoPixels>)
private val original = CommentTarget("original", "原评论正文", "原评论作者")
private val text = "完整的回复正文"
private val twoPhotos = listOf(stripedPhoto(vertical = true), stripedPhoto(vertical = false))
private val reply = Reply(text, twoPhotos)
@Test fun matchesExactTextAndBothImagesFromTheSameReply() {
val selected = BilibiliReceiptEvidence.uniqueReply(
original, original, true, text, listOf(Reply("另一条回复", emptyList()), reply), Reply::body,
)
assertSame(reply, selected)
assertTrue(BilibiliReceiptEvidence.matchesOrderedPhotos(twoPhotos, checkNotNull(selected).photos))
}
@Test fun rejectsDifferentOriginalIncompleteThreadAndDuplicateBodies() {
val differentOriginal = original.copy(key = "another-original")
assertNull(BilibiliReceiptEvidence.uniqueReply(original, differentOriginal, true, text, listOf(reply), Reply::body))
assertNull(BilibiliReceiptEvidence.uniqueReply(original, original, false, text, listOf(reply), Reply::body))
assertNull(BilibiliReceiptEvidence.uniqueReply(original, original, true, text, listOf(reply, reply), Reply::body))
assertNull(BilibiliReceiptEvidence.uniqueReply(original, original, true, "$text!", listOf(reply), Reply::body))
}
@Test fun rejectsMissingSwappedOrRepeatedImages() {
assertFalse(BilibiliReceiptEvidence.matchesOrderedPhotos(twoPhotos, twoPhotos.take(1)))
assertFalse(BilibiliReceiptEvidence.matchesOrderedPhotos(twoPhotos, twoPhotos.reversed()))
assertFalse(BilibiliReceiptEvidence.matchesOrderedPhotos(twoPhotos, List(2) { twoPhotos.first() }))
}
@Test fun readsExplicitThreadTotalsWithoutTreatingSortLabelsAsCounts() {
assertEquals(2, BilibiliLabels.detailReplyTotal("相关回复共 2 条"))
assertEquals(2, BilibiliLabels.detailReplyTotal("共2条回复"))
assertEquals(2, BilibiliLabels.detailReplyTotal("2"))
assertNull(BilibiliLabels.detailReplyTotal("按时间"))
}
private fun stripedPhoto(vertical: Boolean): PhotoPixels {
val size = 48
return PhotoPixels(size, size, IntArray(size * size) { index ->
val axis = if (vertical) index % size else index / size
if (axis / 8 % 2 == 0) 0xffab2c1e.toInt() else 0xff2baa95.toInt()
})
}
}
+8 -1
View File
@@ -1,6 +1,13 @@
# 拾见开发进度
最近更新于 2026-11-27 10:24(UTC+8)。以下按开发轮次倒序记录。
最近更新于 2026-11-27 10:42(UTC+8)。以下按开发轮次倒序记录。
## 2026-11-27 · 拾见 0.1.25 哔哩哔哩双图复查与回执校验
- 在同一台 vivo Android 12 手机的哔哩哔哩 9.21.0 上换另一条视频复查。填入临时正文后,定向回复仍无图片按钮。Android 输入法元数据中该编辑器的 `contentMimeTypes` 为 `null`。点进「插入内容」后是「视频」「专栏」搜索,页面无系统相册或文件选择入口。 [Android 富内容文档](https://developer.android.com/develop/ui/views/receive-rich-content)
- 官方视频网页版组件在选中回复对象后也不展示图片按钮。本轮实发为 0,原评论下的双图实发和自动回执仍缺少真机可用入口。 [哔哩哔哩网页版评论组件](https://s1.hdslb.com/bfs/seed/jinkela/commentpc/bili-comments.js) · [哔哩哔哩发图说明](https://www.bilibili.com/opus/752428294212681795)
- 回执要求原评论线程完整。识别到原生回复总数栏时,要求总数与已识别的回复数一致。线程里保留同正文的多条回复用于判断唯一性。截图前后核对同一条回复及其身份和图片区域,再按绑定顺序比对全部图片。证据不足时保留待核对。
- 离线构建及 67 项 JVM 单测通过,Lint 为 0 个错误、4 个既有警告。新增用例覆盖错线程、重复正文、缺图、错序及回复总数解析。0.1.25 APK 通过 v2 签名校验,已覆盖安装并验证冷启动,设备包与本地 APK 的 SHA-256 一致。安装前后的原配置和检查点已核对,真机临时正文已清除。
## 2026-11-27 · 拾见 0.1.24 哔哩哔哩真机联调