fix(group-album): return video media metadata
Decode the QQ group album video payload, including cover, duration, and multi-resolution URLs. Add a wire-level regression test and update generated action documentation. Fixes #270
This commit is contained in:
6 files changed
+131
-10
No files matched your search
@@ -27,30 +27,30 @@ export interface GroupAlbumListRequestWireOracle {
|
|||||||
extMap?: pb_repeated<10, GroupAlbumListExtWireOracle>;
|
extMap?: pb_repeated<10, GroupAlbumListExtWireOracle>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GroupAlbumCoverUrlWireOracle {
|
interface GroupAlbumUrlInfoWireOracle {
|
||||||
url?: pb<1, string>;
|
url?: pb<1, string>;
|
||||||
width?: pb<2, uint_32>;
|
width?: pb<2, uint_32>;
|
||||||
height?: pb<3, uint_32>;
|
height?: pb<3, uint_32>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GroupAlbumCoverPhotoUrlWireOracle {
|
interface GroupAlbumPhotoUrlWireOracle {
|
||||||
spec?: pb<1, uint_32>;
|
spec?: pb<1, uint_32>;
|
||||||
url?: pb<2, GroupAlbumCoverUrlWireOracle>;
|
url?: pb<2, GroupAlbumUrlInfoWireOracle>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GroupAlbumCoverImageWireOracle {
|
interface GroupAlbumImageWireOracle {
|
||||||
name?: pb<1, string>;
|
name?: pb<1, string>;
|
||||||
sloc?: pb<2, string>;
|
sloc?: pb<2, string>;
|
||||||
lloc?: pb<3, string>;
|
lloc?: pb<3, string>;
|
||||||
photoUrls?: pb_repeated<4, GroupAlbumCoverPhotoUrlWireOracle>;
|
photoUrls?: pb_repeated<4, GroupAlbumPhotoUrlWireOracle>;
|
||||||
defaultUrl?: pb<5, GroupAlbumCoverUrlWireOracle>;
|
defaultUrl?: pb<5, GroupAlbumUrlInfoWireOracle>;
|
||||||
isGif?: pb<6, bool>;
|
isGif?: pb<6, bool>;
|
||||||
hasRaw?: pb<7, bool>;
|
hasRaw?: pb<7, bool>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GroupAlbumCoverWireOracle {
|
interface GroupAlbumCoverWireOracle {
|
||||||
type?: pb<1, uint_32>;
|
type?: pb<1, uint_32>;
|
||||||
image?: pb<2, GroupAlbumCoverImageWireOracle>;
|
image?: pb<2, GroupAlbumImageWireOracle>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GroupAlbumListItemWireOracle {
|
interface GroupAlbumListItemWireOracle {
|
||||||
@@ -81,3 +81,32 @@ interface GroupAlbumMediaListReqInfoWireOracle {
|
|||||||
export interface GroupAlbumMediaListRequestWireOracle {
|
export interface GroupAlbumMediaListRequestWireOracle {
|
||||||
reqInfo?: pb<4, GroupAlbumMediaListReqInfoWireOracle>;
|
reqInfo?: pb<4, GroupAlbumMediaListReqInfoWireOracle>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface GroupAlbumVideoWireOracle {
|
||||||
|
id?: pb<1, string>;
|
||||||
|
url?: pb<2, string>;
|
||||||
|
cover?: pb<3, GroupAlbumImageWireOracle>;
|
||||||
|
width?: pb<4, uint_32>;
|
||||||
|
height?: pb<5, uint_32>;
|
||||||
|
videoTime?: pb<6, uint_64>;
|
||||||
|
videoUrl?: pb_repeated<7, GroupAlbumPhotoUrlWireOracle>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GroupAlbumMediaWireOracle {
|
||||||
|
type?: pb<1, uint_32>;
|
||||||
|
image?: pb<2, GroupAlbumImageWireOracle>;
|
||||||
|
video?: pb<3, GroupAlbumVideoWireOracle>;
|
||||||
|
uploader?: pb<6, string>;
|
||||||
|
batchId?: pb<7, uint_64>;
|
||||||
|
uploadTime?: pb<8, uint_64>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GroupAlbumMediaListResponseDataWireOracle {
|
||||||
|
mediaList?: pb_repeated<3, GroupAlbumMediaWireOracle>;
|
||||||
|
nextAttachInfo?: pb<5, string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GroupAlbumMediaListResponseWireOracle {
|
||||||
|
result?: pb<1, int_32>;
|
||||||
|
data?: pb<4, GroupAlbumMediaListResponseDataWireOracle>;
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ import type {
|
|||||||
GroupAlbumListRequestWireOracle,
|
GroupAlbumListRequestWireOracle,
|
||||||
GroupAlbumListResponseWireOracle,
|
GroupAlbumListResponseWireOracle,
|
||||||
GroupAlbumMediaListRequestWireOracle,
|
GroupAlbumMediaListRequestWireOracle,
|
||||||
|
GroupAlbumMediaListResponseWireOracle,
|
||||||
} from './group-album-wire-fixture';
|
} from './group-album-wire-fixture';
|
||||||
|
|
||||||
function albumListResponseWithCover(): Uint8Array {
|
function albumListResponseWithCover(): Uint8Array {
|
||||||
@@ -256,6 +257,7 @@ describe('apis/group-album', () => {
|
|||||||
mediaList: [{
|
mediaList: [{
|
||||||
type: 1,
|
type: 1,
|
||||||
image: null,
|
image: null,
|
||||||
|
video: null,
|
||||||
uploader: '10001',
|
uploader: '10001',
|
||||||
batchId: '123',
|
batchId: '123',
|
||||||
uploadTime: '456',
|
uploadTime: '456',
|
||||||
@@ -263,4 +265,84 @@ describe('apis/group-album', () => {
|
|||||||
nextAttachInfo: 'next-page',
|
nextAttachInfo: 'next-page',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns video metadata from the group album media list', async () => {
|
||||||
|
const bridge = mockBridge();
|
||||||
|
bridge.sendRawPacket.mockResolvedValueOnce({
|
||||||
|
success: true,
|
||||||
|
gotResponse: true,
|
||||||
|
errorCode: 0,
|
||||||
|
errorMessage: '',
|
||||||
|
responseData: Buffer.from(protobuf_encode<GroupAlbumMediaListResponseWireOracle>({
|
||||||
|
data: {
|
||||||
|
mediaList: [{
|
||||||
|
type: 2,
|
||||||
|
video: {
|
||||||
|
id: 'video-id',
|
||||||
|
url: 'https://example.test/video.mp4',
|
||||||
|
cover: {
|
||||||
|
name: 'cover.jpg',
|
||||||
|
sloc: 'cover-small',
|
||||||
|
lloc: 'cover-large',
|
||||||
|
photoUrls: [{
|
||||||
|
spec: 3,
|
||||||
|
url: { url: 'https://example.test/cover-320.jpg', width: 320, height: 180 },
|
||||||
|
}],
|
||||||
|
defaultUrl: { url: 'https://example.test/cover.jpg', width: 1920, height: 1080 },
|
||||||
|
isGif: true,
|
||||||
|
hasRaw: true,
|
||||||
|
},
|
||||||
|
width: 1920,
|
||||||
|
height: 1080,
|
||||||
|
videoTime: 15n,
|
||||||
|
videoUrl: [{
|
||||||
|
spec: 1,
|
||||||
|
url: { url: 'https://example.test/video-720p.mp4', width: 1280, height: 720 },
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
uploader: '10001',
|
||||||
|
batchId: 123n,
|
||||||
|
uploadTime: 456n,
|
||||||
|
}],
|
||||||
|
nextAttachInfo: 'next-video-page',
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await new GroupAlbumApi(bridge as never).getMediaList(12345, 'album-id');
|
||||||
|
|
||||||
|
expect(result).toEqual({
|
||||||
|
mediaList: [{
|
||||||
|
type: 2,
|
||||||
|
image: null,
|
||||||
|
video: {
|
||||||
|
id: 'video-id',
|
||||||
|
url: 'https://example.test/video.mp4',
|
||||||
|
cover: {
|
||||||
|
name: 'cover.jpg',
|
||||||
|
sloc: 'cover-small',
|
||||||
|
lloc: 'cover-large',
|
||||||
|
photoUrls: [{
|
||||||
|
spec: 3,
|
||||||
|
url: { url: 'https://example.test/cover-320.jpg', width: 320, height: 180 },
|
||||||
|
}],
|
||||||
|
defaultUrl: { url: 'https://example.test/cover.jpg', width: 1920, height: 1080 },
|
||||||
|
isGif: true,
|
||||||
|
hasRaw: true,
|
||||||
|
},
|
||||||
|
width: 1920,
|
||||||
|
height: 1080,
|
||||||
|
videoTime: '15',
|
||||||
|
videoUrl: [{
|
||||||
|
spec: 1,
|
||||||
|
url: { url: 'https://example.test/video-720p.mp4', width: 1280, height: 720 },
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
uploader: '10001',
|
||||||
|
batchId: '123',
|
||||||
|
uploadTime: '456',
|
||||||
|
}],
|
||||||
|
nextAttachInfo: 'next-video-page',
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
@@ -3617,7 +3617,7 @@
|
|||||||
{
|
{
|
||||||
"name": "get_group_album_media_list",
|
"name": "get_group_album_media_list",
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"returns": "相册媒体列表及下一页分页游标:{mediaList, nextAttachInfo}。",
|
"returns": "相册图片/视频列表及下一页分页游标;视频项包含 id、url、cover、尺寸、时长和多规格地址。",
|
||||||
"returnsSchema": {
|
"returnsSchema": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@@ -3620,7 +3620,7 @@ export const ACTIONS: CatalogAction[] = [
|
|||||||
{
|
{
|
||||||
"name": "get_group_album_media_list",
|
"name": "get_group_album_media_list",
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"returns": "相册媒体列表及下一页分页游标:{mediaList, nextAttachInfo}。",
|
"returns": "相册图片/视频列表及下一页分页游标;视频项包含 id、url、cover、尺寸、时长和多规格地址。",
|
||||||
"returnsSchema": {
|
"returnsSchema": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ export const actions = [
|
|||||||
groupAction({
|
groupAction({
|
||||||
name: 'get_group_album_media_list',
|
name: 'get_group_album_media_list',
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
returns: '相册媒体列表及下一页分页游标:{mediaList, nextAttachInfo}。',
|
returns: '相册图片/视频列表及下一页分页游标;视频项包含 id、url、cover、尺寸、时长和多规格地址。',
|
||||||
returnsSchema: {
|
returnsSchema: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
|
|||||||
@@ -106,9 +106,19 @@ export interface ImageInfo {
|
|||||||
isGif?: pb<6, bool>;
|
isGif?: pb<6, bool>;
|
||||||
hasRaw?: pb<7, bool>;
|
hasRaw?: pb<7, bool>;
|
||||||
}
|
}
|
||||||
|
export interface VideoInfo {
|
||||||
|
id?: pb<1, string>;
|
||||||
|
url?: pb<2, string>;
|
||||||
|
cover?: pb<3, ImageInfo>;
|
||||||
|
width?: pb<4, uint_32>;
|
||||||
|
height?: pb<5, uint_32>;
|
||||||
|
videoTime?: pb<6, uint_64>;
|
||||||
|
videoUrl?: pb_repeated<7, PhotoUrl>;
|
||||||
|
}
|
||||||
export interface MediaInfo {
|
export interface MediaInfo {
|
||||||
type?: pb<1, uint_32>;
|
type?: pb<1, uint_32>;
|
||||||
image?: pb<2, ImageInfo>;
|
image?: pb<2, ImageInfo>;
|
||||||
|
video?: pb<3, VideoInfo>;
|
||||||
uploader?: pb<6, string>;
|
uploader?: pb<6, string>;
|
||||||
batchId?: pb<7, uint_64>;
|
batchId?: pb<7, uint_64>;
|
||||||
uploadTime?: pb<8, uint_64>;
|
uploadTime?: pb<8, uint_64>;
|
||||||
|
|||||||
Reference in new issue
Block a user