Giter Site home page Giter Site logo

KeyError about tiktok-uploader HOT 9 OPEN

miniglome avatar miniglome commented on July 17, 2024
KeyError

from tiktok-uploader.

Comments (9)

liyouyoumao avatar liyouyoumao commented on July 17, 2024 1
	#x_csrf_token = r.headers["X-Ware-Csrf-Token"].split(',')[1]

	params = {
		"video_id":video_id,
		"visibility_type":"0",
		"poster_delay":"0",
		"text":text,
		"text_extra":json.dumps(text_extra),
		"allow_comment":"1",
		"allow_duet":"0",
		"allow_stitch":"0",
		"sound_exemption":"0",
		"aid":"1988",
	}
	if schedule_time:
		params["schedule_time"] = schedule_time
	#headers = {"X-Secsdk-Csrf-Token": x_csrf_token}

You need to remove this line of code

from tiktok-uploader.

thiago28x avatar thiago28x commented on July 17, 2024

same here. got this from chatgpt:

The error you're encountering is a KeyError raised at the line x_csrf_token = r.headers["X-Ware-Csrf-Token"].split(',')[1] in the uploadVideo function. This error occurs because the "X-Ware-Csrf-Token" header is not present in the response returned by the TikTok server, and the code is trying to access it.

The "X-Ware-Csrf-Token" header is typically used for CSRF (Cross-Site Request Forgery) protection. If the TikTok server has changed its response structure or if there is an issue with the request or authentication, this header might not be included in the response.

To fix this issue, you can add a check to ensure that the "X-Ware-Csrf-Token" header is present before accessing it. Modify the line as follows:

python
Copy code
x_csrf_token = r.headers.get("X-Ware-Csrf-Token", "").split(',')[1]
By using the get() method of the headers dictionary, you can provide a default value (in this case, an empty string) if the header is not found. This way, if the header is missing, x_csrf_token will be an empty string, and the code will continue to execute without raising a KeyError. However, you should make sure to handle the case when the CSRF token is missing appropriately in your code.

After making this change, try running your code again, and see if the issue is resolved. If there are other issues or errors, further debugging might be necessary to identify and address them.

from tiktok-uploader.

KundKMC avatar KundKMC commented on July 17, 2024

I think this is not going to work because the header field seems not to be present anymore. Were you successful on reactivating the script?

from tiktok-uploader.

Dwilem avatar Dwilem commented on July 17, 2024

Just tested this and sadly it is not working.

from tiktok-uploader.

Dwilem avatar Dwilem commented on July 17, 2024

Is there any other fix?

from tiktok-uploader.

zat2pil avatar zat2pil commented on July 17, 2024
	#x_csrf_token = r.headers["X-Ware-Csrf-Token"].split(',')[1]

	params = {
		"video_id":video_id,
		"visibility_type":"0",
		"poster_delay":"0",
		"text":text,
		"text_extra":json.dumps(text_extra),
		"allow_comment":"1",
		"allow_duet":"0",
		"allow_stitch":"0",
		"sound_exemption":"0",
		"aid":"1988",
	}
	if schedule_time:
		params["schedule_time"] = schedule_time
	#headers = {"X-Secsdk-Csrf-Token": x_csrf_token}

You need to remove this line of code

It works, but when file is uploaded to tiktok, then it doesn't has any audio

from tiktok-uploader.

zat2pil avatar zat2pil commented on July 17, 2024
	#x_csrf_token = r.headers["X-Ware-Csrf-Token"].split(',')[1]

	params = {
		"video_id":video_id,
		"visibility_type":"0",
		"poster_delay":"0",
		"text":text,
		"text_extra":json.dumps(text_extra),
		"allow_comment":"1",
		"allow_duet":"0",
		"allow_stitch":"0",
		"sound_exemption":"0",
		"aid":"1988",
	}
	if schedule_time:
		params["schedule_time"] = schedule_time
	#headers = {"X-Secsdk-Csrf-Token": x_csrf_token}

You need to remove this line of code

It works, but when file is uploaded to tiktok, then it doesn't has any audio

In browser it shows that video is uploaded, but without sound, but from other devices you can't see this video

from tiktok-uploader.

liyouyoumao avatar liyouyoumao commented on July 17, 2024
	#x_csrf_token = r.headers["X-Ware-Csrf-Token"].split(',')[1]

	params = {
		"video_id":video_id,
		"visibility_type":"0",
		"poster_delay":"0",
		"text":text,
		"text_extra":json.dumps(text_extra),
		"allow_comment":"1",
		"allow_duet":"0",
		"allow_stitch":"0",
		"sound_exemption":"0",
		"aid":"1988",
	}
	if schedule_time:
		params["schedule_time"] = schedule_time
	#headers = {"X-Secsdk-Csrf-Token": x_csrf_token}

You need to remove this line of code

It works, but when file is uploaded to tiktok, then it doesn't has any audio

In browser it shows that video is uploaded, but without sound, but from other devices you can't see this video

I uploaded successfully and it is with sound, I can only log in to tiktok through the browser no other device

from tiktok-uploader.

KundKMC avatar KundKMC commented on July 17, 2024

But you didn't add a pull request, here ;( I'm gonna do a retest and then create a pull request. Maybe we get this thing back on track.

from tiktok-uploader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.