Skip to content

best way to save what you love

api/tiktok: fix url patterns

wukko6ad838b6498d
diff --git a/api/src/processing/match.js b/api/src/processing/match.js
index ffb92c23..b0022d08 100644
--- a/api/src/processing/match.js
+++ b/api/src/processing/match.js
@@ -127,7 +127,7 @@ export default async function({ host, patternMatch, params }) {
case "tiktok":
r = await tiktok({
postId: patternMatch.postId,
- id: patternMatch.id,
+ shortLink: patternMatch.shortLink,
fullAudio: params.tiktokFullAudio,
isAudioOnly,
h265: params.tiktokH265,
diff --git a/api/src/processing/service-config.js b/api/src/processing/service-config.js
index 8d8bf4ac..a2136ad0 100644
--- a/api/src/processing/service-config.js
+++ b/api/src/processing/service-config.js
@@ -111,10 +111,10 @@ export const services = {
tiktok: {
patterns: [
":user/video/:postId",
- ":id",
- "t/:id",
+ ":shortLink",
+ "t/:shortLink",
":user/photo/:postId",
- "v/:id.html"
+ "v/:postId.html"
],
subdomains: ["vt", "vm", "m"],
},
diff --git a/api/src/processing/services/tiktok.js b/api/src/processing/services/tiktok.js
index 3c70e033..e205ce54 100644
--- a/api/src/processing/services/tiktok.js
+++ b/api/src/processing/services/tiktok.js
@@ -12,7 +12,7 @@ export default async function(obj) {
let postId = obj.postId;
if (!postId) {
- let html = await fetch(`${shortDomain}${obj.id}`, {
+ let html = await fetch(`${shortDomain}${obj.shortLink}`, {
redirect: "manual",
headers: {
"user-agent": genericUserAgent.split(' Chrome/1')[0]
@@ -24,7 +24,7 @@ export default async function(obj) {
if (html.startsWith('<a href="https://')) {
const extractedURL = html.split('<a href="')[1].split('?')[0];
const { patternMatch } = extract(extractedURL);
- postId = patternMatch.postId
+ postId = patternMatch.postId;
}
}
if (!postId) return { error: "fetch.short_link" };