Skip to content

best way to save what you love

tiktok: fix photo link parsing

wukkoc9947fc75de3
diff --git a/src/modules/processing/services/tiktok.js b/src/modules/processing/services/tiktok.js
index 0da62a1e..4743667a 100644
--- a/src/modules/processing/services/tiktok.js
+++ b/src/modules/processing/services/tiktok.js
@@ -35,10 +35,11 @@ export default async function(obj) {
redirect: "manual",
headers: { "user-agent": userAgent }
}).then((r) => { return r.text() }).catch(() => { return false });
+
if (!html) return { error: 'ErrorCouldntFetch' };
- if (html.slice(0, 17) === '<a href="https://' && html.includes('/video/')) {
- postId = html.split('/video/')[1].split('?')[0].replace("/", '')
+ if (html.slice(0, 17) === '<a href="https://') {
+ postId = html.split('<a href="https://')[1].split('?')[0].split('/')[3]
} else if (html.slice(0, 32) === '<a href="https://m.tiktok.com/v/' && html.includes('/v/')) {
postId = html.split('/v/')[1].split('.html')[0].replace("/", '')
}
diff --git a/src/modules/processing/servicesConfig.json b/src/modules/processing/servicesConfig.json
index 9d903fcb..804f5978 100644
--- a/src/modules/processing/servicesConfig.json
+++ b/src/modules/processing/servicesConfig.json
@@ -49,7 +49,7 @@
},
"tiktok": {
"alias": "tiktok videos, photos & audio",
- "patterns": [":user/video/:postId", ":id", "t/:id"],
+ "patterns": [":user/video/:postId", ":id", "t/:id", ":user/photo/:postId"],
"subdomains": ["vt", "vm"],
"audioFormats": ["best", "m4a", "mp3"],
"enabled": true