mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-08-17 19:47:08 +08:00
修复bug,针对部分没有MD5名字的视频也能支持导出
This commit is contained in:
@@ -30,6 +30,7 @@ const state = vi.hoisted(() => ({
|
||||
voiceLookups: [] as number[],
|
||||
videoLookups: [] as {
|
||||
createTime?: number
|
||||
byteLength?: number
|
||||
duration?: number
|
||||
width?: number
|
||||
height?: number
|
||||
@@ -163,7 +164,13 @@ vi.mock('../../src/main/video-asset-service', () => ({
|
||||
VideoAssetService: class {
|
||||
resolve(
|
||||
_hashes: string[],
|
||||
options?: { createTime?: number; duration?: number; width?: number; height?: number }
|
||||
options?: {
|
||||
createTime?: number
|
||||
byteLength?: number
|
||||
duration?: number
|
||||
width?: number
|
||||
height?: number
|
||||
}
|
||||
): { success: boolean; url: string } {
|
||||
state.videoLookups.push(options || {})
|
||||
return { success: true, url: 'wxe-media://local/fixture-video' }
|
||||
@@ -255,7 +262,7 @@ describe('media export flow', () => {
|
||||
type: '视频',
|
||||
contentData: {
|
||||
type: 'video',
|
||||
md5: 'b'.repeat(32),
|
||||
byteLength: 6402169,
|
||||
duration: 68,
|
||||
width: 279,
|
||||
height: 630
|
||||
@@ -326,6 +333,7 @@ describe('media export flow', () => {
|
||||
})
|
||||
expect(state.videoLookups[0]).toEqual({
|
||||
createTime: 1_785_549_600,
|
||||
byteLength: 6402169,
|
||||
duration: 68,
|
||||
width: 279,
|
||||
height: 630
|
||||
|
||||
@@ -16,6 +16,24 @@ describe('message parser', () => {
|
||||
).toMatchObject({ type: 'sticker', md5: 'abcdefabcdefabcdefabcdefabcdefab' })
|
||||
})
|
||||
|
||||
it('keeps video metadata when WeChat omits every MD5 field', () => {
|
||||
const parsed = parseMessageContent(
|
||||
'<msg><videomsg length="6402169" playlength="30" cdnthumbwidth="224" cdnthumbheight="398" aeskey="25201cc658042689d1ad6747cea2b240" rawmd5="" /></msg>',
|
||||
43
|
||||
)
|
||||
|
||||
expect(parsed).toEqual({
|
||||
type: 'video',
|
||||
md5: undefined,
|
||||
newMd5: undefined,
|
||||
rawMd5: undefined,
|
||||
byteLength: 6402169,
|
||||
duration: 30,
|
||||
width: 224,
|
||||
height: 398
|
||||
})
|
||||
})
|
||||
|
||||
it('parses merged forwards and preserves nested visible text', () => {
|
||||
const parsed = parseMessageContent(
|
||||
'<appmsg><type>19</type><title>转发多条内容</title><recorditem><dataitem datatype="1"><sourcename>测试成员</sourcename><datadesc>脱敏内容</datadesc></dataitem></recorditem></appmsg>',
|
||||
|
||||
@@ -119,6 +119,30 @@ describe('VideoAssetService local fallback', () => {
|
||||
expect(service.pathForUrl(result.poster!)).toBe(posterPath)
|
||||
})
|
||||
|
||||
it('finds an MD5-less video by byte length, thumbnail size, and duration', async () => {
|
||||
const { accountRoot, service } = createService()
|
||||
const month = join(accountRoot, 'msg', 'video', '2026-08')
|
||||
mkdirSync(month, { recursive: true })
|
||||
const targetStem = '9a3b17272822a65ce6e396ecded9ccdc'
|
||||
const otherStem = '47e890579eacf48c46187ae998332202'
|
||||
const target = mp4Fixture(30, 'target-video-with-distinct-byte-length')
|
||||
writeFileSync(join(month, `${targetStem}.mp4`), target)
|
||||
writeFileSync(join(month, `${targetStem}_thumb.jpg`), jpegFixture(224, 398))
|
||||
writeFileSync(join(month, `${otherStem}.mp4`), mp4Fixture(30, 'other'))
|
||||
writeFileSync(join(month, `${otherStem}_thumb.jpg`), jpegFixture(224, 398))
|
||||
|
||||
const result = await service.resolve([], {
|
||||
createTime: monthTimestamp(2026, 8),
|
||||
byteLength: target.length,
|
||||
duration: 30,
|
||||
width: 224,
|
||||
height: 398
|
||||
})
|
||||
|
||||
expect(result.success).toBe(true)
|
||||
expect(service.pathForUrl(result.url!)).toBe(join(month, `${targetStem}.mp4`))
|
||||
})
|
||||
|
||||
it('does not guess when multiple files match the same metadata', async () => {
|
||||
const { accountRoot, service } = createService()
|
||||
const month = join(accountRoot, 'msg', 'video', '2026-02')
|
||||
|
||||
Reference in New Issue
Block a user