feat: supports using "eid" to retrieve feed details

This commit is contained in:
ltaoo committed 2026-03-03 00:50:19 +08:00
1 parent de5b261666
commit 9c64ec7fb8
4 files changed
+49 -32

No files matched your search

+6 -4
View File
@@ -194,7 +194,8 @@ func (c *APIClient) handleFetchFeedProfile(ctx *gin.Context) {
oid := ctx.Query("oid")
uid := ctx.Query("nid")
url := ctx.Query("url")
resp, err := c.channels.FetchChannelsFeedProfile(oid, uid, url)
eid := ctx.Query("eid")
resp, err := c.channels.FetchChannelsFeedProfile(oid, uid, url, eid)
if err != nil {
result.Err(ctx, 400, err.Error())
return
@@ -553,7 +554,8 @@ func buildBatchCreateTask(c *APIClient, existing_task_map map[string]int, feeds
func (c *APIClient) handleCreateChannelsTask(ctx *gin.Context) {
var body struct {
Oid string `json:"oid"`
Nid string `json:"Nid"`
Nid string `json:"nid"`
Eid string `json:"eid"`
URL string `json:"url"`
MP3 bool `json:"mp3"` // 是否下载为 mp3
Cover bool `json:"cover"` // 是否下载封面
@@ -562,11 +564,11 @@ func (c *APIClient) handleCreateChannelsTask(ctx *gin.Context) {
result.Err(ctx, 400, "不合法的参数")
return
}
if body.Oid == "" && body.Nid == "" && body.URL == "" {
if body.Oid == "" && body.Nid == "" && body.URL == "" && body.Eid == "" {
result.Err(ctx, 400, "缺少参数")
return
}
r, err := c.channels.FetchChannelsFeedProfile(body.Oid, body.Nid, body.URL)
r, err := c.channels.FetchChannelsFeedProfile(body.Oid, body.Nid, body.URL, body.Eid)
if err != nil {
result.Err(ctx, 500, "获取详情失败: "+err.Error())
return
+4 -3
View File
@@ -291,9 +291,10 @@ type ChannelsInteractionedFeedListBody struct {
NextMarker string `json:"next_marker"`
}
type ChannelsFeedProfileBody struct {
URL string `json:"url"`
ObjectId string `json:"oid"`
NonceId string `json:"nid"`
URL string `json:"url"`
ObjectId string `json:"oid"`
NonceId string `json:"nid"`
EncryptedObjectId string `json:"eid"`
}
type ChannelsFeedList struct {
List []ChannelsFeedProfile `json:"list"`
+3 -3
View File
@@ -276,16 +276,16 @@ func (c *ChannelsClient) FetchChannelsInteractionedFeedList(flag, next_marker st
return &r, nil
}
func (c *ChannelsClient) FetchChannelsFeedProfile(oid, uid, url string) (*types.ChannelsFeedProfileResp, error) {
func (c *ChannelsClient) FetchChannelsFeedProfile(oid, uid, url, eid string) (*types.ChannelsFeedProfileResp, error) {
// fmt.Println("[API]fetch feed profile", oid, uid)
kk := fmt.Sprintf("%s:%s:%s", oid, uid, url)
kk := fmt.Sprintf("%s:%s:%s:%s", oid, uid, url, eid)
cache_key := "channels:feed_profile:" + kk
if val, found := c.cache.Get(cache_key); found {
if resp, ok := val.(*types.ChannelsFeedProfileResp); ok {
return resp, nil
}
}
resp, err := c.RequestFrontend("key:channels:feed_profile", types.ChannelsFeedProfileBody{ObjectId: oid, NonceId: uid, URL: url}, 10*time.Second)
resp, err := c.RequestFrontend("key:channels:feed_profile", types.ChannelsFeedProfileBody{ObjectId: oid, NonceId: uid, URL: url, EncryptedObjectId: eid}, 10*time.Second)
if err != nil {
return nil, err
}
+36 -22
View File
@@ -34,6 +34,27 @@ var isWin = /Windows|Win/i.test(ua);
})(),
});
}
function connect_local_ws() {
const protocol = "wss://";
const ws = new WebSocket(
protocol + FakeLocalAPIServerAddr + "/ws/channels",
);
ws.onclose = () => {
WXU.error({ msg: "本地ws连接已关闭" });
};
ws.onerror = (e) => {
WXU.error({ msg: "本地ws连接发生错误" });
};
ws.onmessage = (ev) => {
const [err, msg] = WXU.parseJSON(ev.data);
if (err) {
return;
}
if (msg.type === "api_call") {
__wx_handle_api_call(msg.data, ws);
}
};
}
function connect(selector) {
console.log(
"[]download connect websocket",
@@ -118,24 +139,7 @@ var isWin = /Windows|Win/i.test(ua);
};
if (WXU.config.remoteServerEnabled) {
// 额外再连接本地ws用于API调用
const lws = new WebSocket(
protocol + FakeLocalAPIServerAddr + "/ws/channels",
);
lws.onclose = () => {
WXU.error({ msg: "本地ws连接已关闭" });
};
lws.onerror = (e) => {
WXU.error({ msg: "本地ws连接发生错误" });
};
lws.onmessage = (ev) => {
const [err, msg] = WXU.parseJSON(ev.data);
if (err) {
return;
}
if (msg.type === "api_call") {
__wx_handle_api_call(msg.data, lws);
}
};
connect_local_ws();
}
});
}
@@ -346,6 +350,10 @@ var isWin = /Windows|Win/i.test(ua);
WXU.observe_node(".home-header", () => {
insert_downloader();
});
// console.log("[]check is wxwork", window.ua.includes("wxwork"), window.ua);
if (window.ua.includes("wxwork")) {
connect_local_ws();
}
// document.addEventListener(
// "scroll",
@@ -451,7 +459,7 @@ async function __wx_handle_api_call(msg, socket) {
return;
}
if (key === "key:channels:feed_profile") {
console.log("before finderGetCommentProfile", data.oid, data.nid);
console.log("before finderGetCommentProfile", data.oid, data.nid, data.eid);
try {
if (data.url) {
var u = new URL(decodeURIComponent(data.url));
@@ -465,19 +473,25 @@ async function __wx_handle_api_call(msg, socket) {
var payload = {
needObject: 1,
lastBuffer: "",
scene: 146,
scene: data.eid ? 141 : 146,
direction: 2,
identityScene: 2,
pullScene: 6,
objectid: (() => {
if (data.eid) {
return undefined;
}
if (data.oid.includes("_")) {
return data.oid.split("_")[0];
}
return data.oid;
})(),
objectNonceId: data.nid,
encrypted_objectid: "",
objectNonceId: data.eid ? undefined : data.nid,
encrypted_objectid: data.eid || "",
};
if (data.eid) {
payload.traceBuffer = undefined;
}
var r = await WXU.API.finderGetCommentDetail(payload);
/** @type {MediaProfileResp} */
var { object } = r.data;