mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-18 19:28:29 +00:00
tiktok: improve web-app parsing error handling
This commit is contained in:
parent
97850e08af
commit
6e8af30227
@ -38,11 +38,17 @@ export default async function(obj) {
|
|||||||
updateCookie(cookie, res.headers)
|
updateCookie(cookie, res.headers)
|
||||||
|
|
||||||
const html = await res.text()
|
const html = await res.text()
|
||||||
|
|
||||||
|
let detail
|
||||||
|
try {
|
||||||
const json = html
|
const json = html
|
||||||
.split('<script id="__UNIVERSAL_DATA_FOR_REHYDRATION__" type="application/json">')[1]
|
.split('<script id="__UNIVERSAL_DATA_FOR_REHYDRATION__" type="application/json">')[1]
|
||||||
.split('</script>')[0]
|
.split('</script>')[0]
|
||||||
const data = JSON.parse(json)
|
const data = JSON.parse(json)
|
||||||
const detail = data["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"]
|
detail = data["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"]
|
||||||
|
} catch {
|
||||||
|
return { error: 'ErrorCouldntFetch' };
|
||||||
|
}
|
||||||
|
|
||||||
let video, videoFilename, audioFilename, audio, images,
|
let video, videoFilename, audioFilename, audio, images,
|
||||||
filenameBase = `tiktok_${detail.author.uniqueId}_${postId}`,
|
filenameBase = `tiktok_${detail.author.uniqueId}_${postId}`,
|
||||||
|
Loading…
Reference in New Issue
Block a user