feat: 完善视频任务与 KOC 资源库
This commit is contained in:
@@ -1,22 +1,31 @@
|
||||
import { hashText } from "./mvp-db";
|
||||
import {
|
||||
extractPublishUrl,
|
||||
extractXhsPublishUrl,
|
||||
platformFromPublishUrl,
|
||||
safeHttpUrl,
|
||||
type SupportedPlatform,
|
||||
} from "./publish-url";
|
||||
|
||||
export { extractXhsPublishUrl } from "./publish-url";
|
||||
|
||||
export function accountFromPublishLink(input: string) {
|
||||
const url = safeHttpUrl(extractXhsPublishUrl(input));
|
||||
export function accountFromPublishLink(
|
||||
input: string,
|
||||
expectedPlatform?: SupportedPlatform,
|
||||
) {
|
||||
const extracted = expectedPlatform
|
||||
? extractPublishUrl(input, expectedPlatform)
|
||||
: extractXhsPublishUrl(input) || extractPublishUrl(input, "抖音");
|
||||
const url = safeHttpUrl(extracted);
|
||||
if (!url) return null;
|
||||
const platform =
|
||||
url.hostname.includes("xiaohongshu") || url.hostname.includes("xhslink")
|
||||
? "小红书"
|
||||
: "其他平台";
|
||||
const platform = platformFromPublishUrl(url.toString());
|
||||
if (!platform || (expectedPlatform && platform !== expectedPlatform)) return null;
|
||||
const noteId =
|
||||
url.pathname.match(
|
||||
/\/(?:discovery\/item|explore)\/([A-Za-z0-9_-]{8,80})/,
|
||||
)?.[1] ?? "";
|
||||
platform === "抖音"
|
||||
? url.pathname.match(/\/(?:video|note)\/([A-Za-z0-9_-]{8,80})/)?.[1] ?? ""
|
||||
: url.pathname.match(
|
||||
/\/(?:discovery\/item|explore)\/([A-Za-z0-9_-]{8,80})/,
|
||||
)?.[1] ?? "";
|
||||
const platformUid = `pending-${hashText(
|
||||
noteId || `${url.origin}${url.pathname}`,
|
||||
)}`;
|
||||
|
||||
Reference in New Issue
Block a user