feat: Add platform adapters for various content publishing platforms
- Implemented Dongchedi adapter for user detection and publishing. - Implemented Jianshu adapter for user detection and publishing. - Implemented Juejin adapter for user detection and publishing. - Implemented Qiehao adapter for user detection and publishing. - Implemented Smzdm adapter for user detection and publishing. - Implemented Sohuhao adapter for user detection and publishing. - Implemented Toutiaohao adapter for user detection and publishing. - Implemented Wangyihao adapter for user detection and publishing. - Implemented Weixin Gzh adapter for user detection and publishing. - Implemented Zol adapter for user detection and publishing. - Added documentation for manual testing of media publishing.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import type { StoredPlatformState } from "../platforms";
|
||||
|
||||
import { connectedPlatform, disconnectedPlatform, fetchJson, unsupportedPublishResult } from "./common";
|
||||
import type { AdapterContext, PlatformAdapter, PlatformPublishResult } from "./types";
|
||||
|
||||
type ZolUserInfoResponse = {
|
||||
data?: {
|
||||
userId?: string | number;
|
||||
nickName?: string;
|
||||
photo?: string;
|
||||
};
|
||||
};
|
||||
|
||||
async function detectZol(platform: StoredPlatformState): Promise<StoredPlatformState> {
|
||||
try {
|
||||
const response = await fetchJson<ZolUserInfoResponse>("https://open-api.zol.com.cn/api/v1/creator.user.getinfo", {
|
||||
headers: {
|
||||
accept: "application/json, text/plain, */*",
|
||||
},
|
||||
}).catch(() => null);
|
||||
|
||||
const user = response?.data;
|
||||
const uid = user?.userId != null ? String(user.userId) : "";
|
||||
if (!uid || !user?.nickName) {
|
||||
return disconnectedPlatform(platform, "未检测到中关村在线登录态");
|
||||
}
|
||||
return connectedPlatform(platform, uid, user.nickName, user.photo ?? null);
|
||||
} catch (error) {
|
||||
return disconnectedPlatform(platform, error instanceof Error ? error.message : "中关村在线登录检测失败");
|
||||
}
|
||||
}
|
||||
|
||||
async function publishZol(): Promise<PlatformPublishResult> {
|
||||
return unsupportedPublishResult("中关村在线");
|
||||
}
|
||||
|
||||
export const zolAdapter: PlatformAdapter = {
|
||||
platformId: "zol",
|
||||
detect: detectZol,
|
||||
publish: (_context: AdapterContext) => publishZol(),
|
||||
};
|
||||
Reference in New Issue
Block a user