tiktok-downloader icon indicating copy to clipboard operation
tiktok-downloader copied to clipboard

Error: SyntaxError: Unexpected end of JSON input

Open tbm opened this issue 11 months ago • 26 comments

Describe the bug I get an error when downloading a single video.

[*] URL: https://www.tiktok.com/@.....
Error: SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at getVideo (/home/tbm/src/tiktok-downloader/index.js:126:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/tbm/src/tiktok-downloader/index.js:320:20
Response body: 
/home/tbm/src/tiktok-downloader/index.js:133
    if (res.aweme_list[0].aweme_id != idVideo) {
            ^

TypeError: Cannot read properties of undefined (reading 'aweme_list')
    at getVideo (/home/tbm/src/tiktok-downloader/index.js:133:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /home/tbm/src/tiktok-downloader/index.js:320:20

Node.js v18.19.0

I get this error when downloading a video: Single download, without watermark.

It happens on every single video I tried. It was working fine a few days ago.

Can you reproduce this issue?

tbm avatar Mar 14 '24 06:03 tbm

Seems like a server error, so the easy fix for me is to change useast1a to useast2a here: const API_URL = https://api16-normal-c-useast1a.tiktokv.com/aweme/v1/feed/?aweme_id=${idVideo};

DD7-13 avatar Mar 14 '24 12:03 DD7-13

I can confirm that this change makes it work for me.

Would be good if the tool would print a clearer error (and maybe fall back to another host).

tbm avatar Mar 14 '24 13:03 tbm

@DD7-13 This fix worked but how did you know to change that line?

jgore077 avatar Mar 14 '24 21:03 jgore077

@DD7-13 This fix worked but how did you know to change that line?

I don't know, actually. I just tried to change the server name and it worked. After that I tried a few other possible names, but no luck

DD7-13 avatar Mar 14 '24 21:03 DD7-13

So does this repo work then? and any beginner info in how to get it setup?

timmbobb avatar Mar 17 '24 19:03 timmbobb

@timmbobb Are you talking in very general terms, do you know git clone and npm i or are you referring to how certain parts of the repo are broken when you first clone it?

jgore077 avatar Mar 17 '24 21:03 jgore077

I actually figured it out. Got the part where the server wasn't working or region or whatever.

On Sun, Mar 17, 2024 at 4:46 PM James Gore @.***> wrote:

@timmbobb https://github.com/timmbobb Are you talking in very general terms, do you know git clone and npm i or are you referring to how certain parts of the repo are broken when you first clone it?

— Reply to this email directly, view it on GitHub https://github.com/n0l3r/tiktok-downloader/issues/50#issuecomment-2002627811, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM3WGSIBXWL22MKTBWFZ5OTYYYFKJAVCNFSM6AAAAABEVPJVUOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBSGYZDOOBRGE . You are receiving this because you were mentioned.Message ID: @.***>

timmbobb avatar Mar 17 '24 21:03 timmbobb

Getting the same issue now... Tried switching between a handful of server URLs (useast1a, useast2a, useast5) with no luck... Anyone ran into this before?

iddogino avatar Mar 21 '24 16:03 iddogino

Its changing frequently now with the U.S tiktok ban but even yt-dlp doesnt have the new url yet.

jgore077 avatar Mar 21 '24 21:03 jgore077

I used api31-normal-probe-useast2a.tiktokv.com it's works for me

ronildodev avatar Mar 22 '24 01:03 ronildodev

@tdevly Can you show how the url is formed on line 124 because I replaced my url to

const API_URL = `https:/api31-normal-probe-useast2a.tiktokv.com/aweme/v1/feed/?aweme_id=${idVideo}`;

but I am still getting the error that @tbm had.

jgore077 avatar Mar 22 '24 01:03 jgore077

@jgore077 It worked this time through the terminal, but it stopped working again Terminal

ronildodev avatar Mar 22 '24 01:03 ronildodev

@tdevly I can confirm that this doesnt work as a replacement but what method did you obtain this api endpoint?

jgore077 avatar Mar 22 '24 04:03 jgore077

I have exactly the same issue as you guys. I tried checking multiple combinations of API numbers and regions using a for loop but none of them worked. Did you find any working API URL?

sarevok89 avatar Mar 22 '24 11:03 sarevok89

I think we should at least add some error handling here so that it's more understandable what's going on when this happens. A "Incorrect API endpoint" error would be much more helpful, and more accurate then what is currently displayed when this happens.

timmbobb avatar Mar 22 '24 16:03 timmbobb

I tried all the above suggestions still no luck.. having the same issue

Pinaka1289 avatar Mar 22 '24 18:03 Pinaka1289

@jgore077 I have tried each url in this list https://gist.github.com/RupGautam/e6953b6e0a68ece63e6721309135190f

ronildodev avatar Mar 22 '24 20:03 ronildodev

To download the video, I used this: https://www.tikwm.com/video/media/play/${videoID}.mp4

ronildodev avatar Mar 22 '24 20:03 ronildodev

Did the job for everyone here and tried bruteforcing every domain in that list. Found some that worked but upon sending a second request they stop returning JSON.

Not sure if it's just random (probably) or anything, but it definitely seems like no matter the "working domain" you'll find, the /aweme/v1/feed endpoint is being deprecated by TikTok and will stop working anyway.

Seems like a whole new solution is required. Some downloader bots still seem to work, not sure what's their approach.

RIP /aweme/v1/feed.

image image

Laiteux avatar Mar 22 '24 22:03 Laiteux

Did the job for everyone here and tried bruteforcing every domain in that list. Found some that worked but upon sending a second request they stop returning JSON.

Not sure if it's just random (probably) or anything, but it definitely seems like no matter the "working domain" you'll find, the /aweme/v1/feed endpoint is being deprecated by TikTok and will stop working anyway.

Seems like a whole new solution is required. Some downloader bots still seem to work, not sure what's their approach.

RIP /aweme/v1/feed.

image image

they use mobile private API which requires special headers

Sunda001 avatar Mar 24 '24 20:03 Sunda001

Did the job for everyone here and tried bruteforcing every domain in that list. Found some that worked but upon sending a second request they stop returning JSON. Not sure if it's just random (probably) or anything, but it definitely seems like no matter the "working domain" you'll find, the /aweme/v1/feed endpoint is being deprecated by TikTok and will stop working anyway. Seems like a whole new solution is required. Some downloader bots still seem to work, not sure what's their approach. RIP /aweme/v1/feed. image image

they use mobile private API which requires special headers

Do you have any idea on how to implement this???

timmbobb avatar Mar 25 '24 02:03 timmbobb

I found a working repo here . This is the endpoint its using "https://api22-normal-c-alisg.tiktokv.com/". This didnt work as a drop in replacement unfortunately.

jgore077 avatar Mar 25 '24 21:03 jgore077

Well, I have a pull request waiting to be accepted that allows people to deploy this to google cloud, and it works currently. Pull request just needs to be accepted. It's also a little bit more of an involved setup than just using the command line though. Still free which is nice.

timmbobb avatar Mar 26 '24 15:03 timmbobb

Well, I have a pull request waiting to be accepted that allows people to deploy this to google cloud, and it works currently. Pull request just needs to be accepted. It's also a little bit more of an involved setup than just using the command line though. Still free which is nice.

It looks your using the old api endpoint, is this right?

jgore077 avatar Mar 26 '24 18:03 jgore077

Well, I have a pull request waiting to be accepted that allows people to deploy this to google cloud, and it works currently. Pull request just needs to be accepted. It's also a little bit more of an involved setup than just using the command line though. Still free which is nice.

It looks your using the old api endpoint, is this right?

Not using any of our endpoints at all. Look in the server.js of the pull request.

timmbobb avatar Mar 27 '24 19:03 timmbobb

check latest version please

n0l3r avatar Mar 31 '24 14:03 n0l3r