mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-01-17 05:40:35 +00:00
Add NTQQ album list API and update related logic
Introduces getAlbumListByNTQQ to NTQQWebApi for retrieving group album lists via NTQQ. Updates NodeIKernelAlbumService interface for typed getAlbumList parameters and response. Refactors GetQunAlbumList action to use the new NTQQ API and return the correct album list format. Also fixes cookie and bkn usage in album-related methods for consistency.
This commit is contained in:
parent
a64779684e
commit
9d22d6e3a0
@ -323,25 +323,50 @@ export class NTQQWebApi {
|
|||||||
}
|
}
|
||||||
return (hash & 0x7FFFFFFF).toString();
|
return (hash & 0x7FFFFFFF).toString();
|
||||||
}
|
}
|
||||||
|
async getAlbumListByNTQQ(gc: string) {
|
||||||
|
return await this.context.session.getAlbumService().getAlbumList({
|
||||||
|
qun_id: gc,
|
||||||
|
attach_info: '',
|
||||||
|
seq: 3331,
|
||||||
|
request_time_line: {
|
||||||
|
request_invoke_time: "0"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
async getAlbumList(gc: string) {
|
async getAlbumList(gc: string) {
|
||||||
const skey = await this.core.apis.UserApi.getSKey() || '';
|
const skey = await this.core.apis.UserApi.getSKey() || '';
|
||||||
const pskey = (await this.core.apis.UserApi.getPSkey(['qzone.qq.com'])).domainPskeyMap.get('qzone.qq.com') || '';
|
const pskey = (await this.core.apis.UserApi.getPSkey(['qzone.qq.com'])).domainPskeyMap.get('qzone.qq.com') || '';
|
||||||
const bkn = this.getBknFromSKey(pskey);
|
const bkn = this.getBknFromSKey(skey);
|
||||||
const uin = this.core.selfInfo.uin || '10001';
|
const uin = this.core.selfInfo.uin || '10001';
|
||||||
const cookies = `p_uin=${this.core.selfInfo.uin}; p_skey=${pskey}; skey=${skey}; uin=${uin}`;
|
const cookies = `p_uin=o${this.core.selfInfo.uin}; p_skey=${pskey}; skey=${skey}; uin=o${uin} `;
|
||||||
const api = `https://h5.qzone.qq.com/proxy/domain/u.photo.qzone.qq.com/cgi-bin/upp/qun_list_album_v2?random=7570&g_tk=${bkn}&format=json&inCharset=utf-8&outCharset=utf-8&qua=V1_IPH_SQ_6.2.0_0_HDBM_T&cmd=qunGetAlbumList&qunId=${gc}&start=0&num=1000&uin=${uin}&getMemberRole=0`;
|
const api = `https://h5.qzone.qq.com/proxy/domain/u.photo.qzone.qq.com/cgi-bin/upp/qun_list_album_v2?`;
|
||||||
const response = await RequestUtil.HttpGetJson<{ data: { album: Array<{ id: string, title: string }> } }>(api, 'GET', '', {
|
const params = new URLSearchParams({
|
||||||
|
random: '7570',
|
||||||
|
g_tk: bkn,
|
||||||
|
format: 'json',
|
||||||
|
inCharset: 'utf-8',
|
||||||
|
outCharset: 'utf-8',
|
||||||
|
qua: 'V1_IPH_SQ_6.2.0_0_HDBM_T',
|
||||||
|
cmd: 'qunGetAlbumList',
|
||||||
|
qunId: gc,
|
||||||
|
qunid: gc,
|
||||||
|
start: '0',
|
||||||
|
num: '1000',
|
||||||
|
uin: uin,
|
||||||
|
getMemberRole: '0'
|
||||||
|
});
|
||||||
|
const response = await RequestUtil.HttpGetJson<{ data: { album: Array<{ id: string, title: string }> } }>(api + params.toString(), 'GET', '', {
|
||||||
'Cookie': cookies
|
'Cookie': cookies
|
||||||
});
|
});
|
||||||
return response.data.album;
|
return response.data.album;
|
||||||
}
|
}
|
||||||
|
|
||||||
async createQunAlbumSession(gc: string, sAlbumID: string, sAlbumName: string, path: string, skey: string, pskey: string, img_md5: string, uin: string) {
|
async createQunAlbumSession(gc: string, sAlbumID: string, sAlbumName: string, path: string, skey: string, pskey: string, img_md5: string, uin: string) {
|
||||||
const img = readFileSync(path);
|
const img = readFileSync(path);
|
||||||
const img_size = img.length;
|
const img_size = img.length;
|
||||||
const img_name = basename(path);
|
const img_name = basename(path);
|
||||||
const GTK = this.getBknFromSKey(pskey);
|
const GTK = this.getBknFromSKey(skey);
|
||||||
const cookie = `p_uin=${uin}; p_skey=${pskey}; skey=${skey}; uin=${uin}`;
|
const cookie = `p_uin=o${uin}; p_skey=${pskey}; skey=${skey}; uin=o${uin}`;
|
||||||
const body = qunAlbumControl({
|
const body = qunAlbumControl({
|
||||||
uin,
|
uin,
|
||||||
group_id: gc,
|
group_id: gc,
|
||||||
@ -364,8 +389,8 @@ export class NTQQWebApi {
|
|||||||
const img_size = statSync(path).size;
|
const img_size = statSync(path).size;
|
||||||
let seq = 0;
|
let seq = 0;
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
const GTK = this.getBknFromSKey(pskey);
|
const GTK = this.getBknFromSKey(skey);
|
||||||
const cookie = `p_uin=${uin}; p_skey=${pskey}; skey=${skey}; uin=${uin}`;
|
const cookie = `p_uin=o${uin}; p_skey=${pskey}; skey=${skey}; uin=o${uin}`;
|
||||||
|
|
||||||
const stream = createReadStream(path, { highWaterMark: slice_size });
|
const stream = createReadStream(path, { highWaterMark: slice_size });
|
||||||
|
|
||||||
|
|||||||
@ -4,8 +4,28 @@ export interface NodeIKernelAlbumService {
|
|||||||
|
|
||||||
getMainPage(...args: unknown[]): unknown;// needs 2 arguments
|
getMainPage(...args: unknown[]): unknown;// needs 2 arguments
|
||||||
|
|
||||||
getAlbumList(...args: unknown[]): unknown;// needs 1 arguments
|
getAlbumList(params: {
|
||||||
|
qun_id: string,
|
||||||
|
attach_info: string,
|
||||||
|
seq: number,
|
||||||
|
request_time_line: {
|
||||||
|
request_invoke_time: string
|
||||||
|
}
|
||||||
|
}): Promise<{
|
||||||
|
response: {
|
||||||
|
seq: number,
|
||||||
|
result: number,
|
||||||
|
errMs: string,//没错就是errMs不是errMsg
|
||||||
|
trace_id: string,
|
||||||
|
is_from_cache: boolean,
|
||||||
|
request_time_line: unknown,
|
||||||
|
album_list: Array<unknown>,
|
||||||
|
attach_info: string,
|
||||||
|
has_more: boolean,
|
||||||
|
right: unknown,
|
||||||
|
banner: unknown
|
||||||
|
}
|
||||||
|
}>
|
||||||
getAlbumInfo(...args: unknown[]): unknown;// needs 1 arguments
|
getAlbumInfo(...args: unknown[]): unknown;// needs 1 arguments
|
||||||
|
|
||||||
deleteAlbum(...args: unknown[]): unknown;// needs 3 arguments
|
deleteAlbum(...args: unknown[]): unknown;// needs 3 arguments
|
||||||
|
|||||||
@ -9,11 +9,11 @@ const SchemaData = Type.Object({
|
|||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
export class GetQunAlbumList extends OneBotAction<Payload,Awaited<ReturnType<NTQQWebApi['getAlbumList']>>> {
|
export class GetQunAlbumList extends OneBotAction<Payload,Awaited<ReturnType<NTQQWebApi['getAlbumListByNTQQ']>>['response']['album_list']> {
|
||||||
override actionName = ActionName.GetQunAlbumList;
|
override actionName = ActionName.GetQunAlbumList;
|
||||||
override payloadSchema = SchemaData;
|
override payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
return await this.core.apis.WebApi.getAlbumList(payload.group_id);
|
return (await this.core.apis.WebApi.getAlbumListByNTQQ(payload.group_id)).response.album_list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user