mirror of
https://github.com/wukko/cobalt.git
synced 2025-02-19 01:18:54 +01:00
api/xiaohongshu: use shortlink resolver
This commit is contained in:
parent
6e8b4f30c1
commit
9e6582b76c
1 changed files with 4 additions and 11 deletions
|
@ -1,7 +1,6 @@
|
||||||
import { extract, normalizeURL } from "../url.js";
|
import { resolveRedirectingURL } from "../url.js";
|
||||||
import { genericUserAgent } from "../../config.js";
|
import { genericUserAgent } from "../../config.js";
|
||||||
import { createStream } from "../../stream/manage.js";
|
import { createStream } from "../../stream/manage.js";
|
||||||
import { getRedirectingURL } from "../../misc/utils.js";
|
|
||||||
|
|
||||||
const https = (url) => {
|
const https = (url) => {
|
||||||
return url.replace(/^http:/i, 'https:');
|
return url.replace(/^http:/i, 'https:');
|
||||||
|
@ -12,19 +11,13 @@ export default async function ({ id, token, shareId, h265, isAudioOnly, dispatch
|
||||||
let xsecToken = token;
|
let xsecToken = token;
|
||||||
|
|
||||||
if (!noteId) {
|
if (!noteId) {
|
||||||
const extractedURL = await getRedirectingURL(
|
const patternMatch = await resolveRedirectingURL(
|
||||||
`https://xhslink.com/a/${shareId}`,
|
`https://xhslink.com/a/${shareId}`,
|
||||||
dispatcher
|
dispatcher
|
||||||
);
|
);
|
||||||
|
|
||||||
if (extractedURL) {
|
noteId = patternMatch?.id;
|
||||||
const { patternMatch } = extract(normalizeURL(extractedURL));
|
xsecToken = patternMatch?.token;
|
||||||
|
|
||||||
if (patternMatch) {
|
|
||||||
noteId = patternMatch.id;
|
|
||||||
xsecToken = patternMatch.token;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!noteId || !xsecToken) return { error: "fetch.short_link" };
|
if (!noteId || !xsecToken) return { error: "fetch.short_link" };
|
||||||
|
|
Loading…
Reference in a new issue