n0l3r / tiktok-downloader

tiktok downloader is a tool to download video from tiktok with watermark or without watermark. There are two features that is, mass download (by username/urls) and single download (by url).
MIT License
319 stars 130 forks source link

Error: SyntaxError: Unexpected end of JSON input #50

Open tbm opened 3 months ago

tbm commented 3 months ago

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?

DD7-13 commented 3 months ago

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};

tbm commented 3 months ago

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).

jgore077 commented 3 months ago

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

DD7-13 commented 3 months ago

@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

timmbobb commented 3 months ago

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

jgore077 commented 3 months ago

@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?

timmbobb commented 3 months ago

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: @.***>

iddogino commented 3 months ago

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

jgore077 commented 3 months ago

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

ronildodev commented 3 months ago

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

jgore077 commented 3 months ago

@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.

ronildodev commented 3 months ago

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

jgore077 commented 3 months ago

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

sarevok89 commented 3 months ago

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?

timmbobb commented 3 months ago

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.

Pinaka1289 commented 3 months ago

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

ronildodev commented 3 months ago

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

ronildodev commented 3 months ago

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

Laiteux commented 3 months ago

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
Sunda001 commented 3 months ago

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

timmbobb commented 3 months ago

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???

jgore077 commented 3 months ago

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.

timmbobb commented 3 months ago

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.

jgore077 commented 3 months ago

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?

timmbobb commented 3 months ago

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.

n0l3r commented 3 months ago

check latest version please