mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-18 03:08:30 +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)
|
||||
|
||||
const html = await res.text()
|
||||
const json = html
|
||||
.split('<script id="__UNIVERSAL_DATA_FOR_REHYDRATION__" type="application/json">')[1]
|
||||
.split('</script>')[0]
|
||||
const data = JSON.parse(json)
|
||||
const detail = data["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"]
|
||||
|
||||
let detail
|
||||
try {
|
||||
const json = html
|
||||
.split('<script id="__UNIVERSAL_DATA_FOR_REHYDRATION__" type="application/json">')[1]
|
||||
.split('</script>')[0]
|
||||
const data = JSON.parse(json)
|
||||
detail = data["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"]
|
||||
} catch {
|
||||
return { error: 'ErrorCouldntFetch' };
|
||||
}
|
||||
|
||||
let video, videoFilename, audioFilename, audio, images,
|
||||
filenameBase = `tiktok_${detail.author.uniqueId}_${postId}`,
|
||||
|
Loading…
Reference in New Issue
Block a user