miniglome / tiktok-uploader Goto Github PK
View Code? Open in Web Editor NEWPython3 script to upload and schedule TikTok videos
Python3 script to upload and schedule TikTok videos
Hello @MiniGlome @KundKMC ,
I am using the Tiktok-uploader library to post videos on TikTok. The videos appear to be successfully published and are set to "public," but they are only visible when I am logged into my TikTok account. Other users cannot see the videos posted via the library, even though they can see videos that I post manually through the TikTok app.
Details:
Library: Tiktok-uploader
TikTok Account: [optionaouoptionb]
Video Status: Public
Visibility: The video is only visible to the user's account, even when set to "public."
Error/Logs: No error is returned, and the logs show no issues.
Propagation Delay: I have waited for 24 hours to see if the video becomes visible to others, but to no avail.
Checks Performed:
The video status is indeed "public."
There are no restrictions on my TikTok account.
The publication settings are correctly configured to make the video "public."
Other users have confirmed that they cannot see the video.
The library documentation has been consulted to troubleshoot the issue.
Questions:
Are there additional configurations or settings that need to be set to make videos visible to all users?
Are there any known restrictions or limitations of the TikTok API that could be causing this issue?
Are there any planned updates to the library that could address this issue?
Conclusion:
I would appreciate any assistance in resolving this issue or any additional information on how to make videos visible to all TikTok users. Thank you very much for your time and assistance.
When I ever I run the script I get the error:
[-] An error occured while reaching https://www.tiktok.com/api/v1/item/create/ r = <Response [200]> r.content = b'{"log_pb":{"impr_id":"2024010521193547FF7F4B5768DB8AFE8C"},"status_code":5,"status_msg":"Invalid parameters"}'
I am using the normal:
# Publish the video uploadVideo(session_id, file, title, tags, verbose=True)
import subprocess
import time
import os
def upload_video():
# Change the current working directory to the Tiktok-uploader directory
os.chdir('C:\Users\example\Tiktok-uploader')
# Execute the Tiktok uploader command change values
command = 'python3 Tiktok_uploader.py -i 7a9f3c5d8f6e4b2a1c9d8e7f6a5b4c3d -p my_video.mp4 -t "MY SUPER TITLE" --tags Funny Joke Fyp'
subprocess.run(command, shell=True)
def run_upload_scheduler(interval):
while True:
upload_video()
time.sleep(interval)
if name == 'main':
interval_seconds = 10 # change value
run_upload_scheduler(interval_seconds)
Used the correct session_id, even with a new updated one however it still gives 403 content error
[-] An error occured while reaching https://www.tiktok.com/upload/
r = <Response [403]>
r.content = b''
from Tiktok_uploader import uploadVideo
session_id = "sessionid"
file = "path/to/video.mp4"
title = "video title"
tags = ["foryoupage", "foryou", "fyp"]
# Publish the video
uploadVideo(session_id, file, title, tags, verbose=True)
As shown on https://www.tiktok.com/@multiversedreaming
All of the uploads have no cover photo, so they look broken in a gallery view until the video starts. Any way to assign an image?
After running the script, I received the message '[+] Video upload uploaded successfully.' However, despite this message, the videos did not upload to the accounts. I've attempted on multiple accounts.
_TikTok.py", line 20
canonical_headers = '\n'.join([f"{h[0]}:{h[1]}" for h in headers.items()]) + '\n' ^
SyntaxError: invalid syntax
Any way to upload a collection of images?
The issue I experienced is that when exporting the file in Spanish, for some reason, the filename still contained the characters "¿" and "?" which prevented me from creating the file.
The solution I applied to this was to change the following code in "final_video.py":
ffmpeg_extract_subclip(
f"assets/temp/{reddit_id}/temp.mp4",
0,
length,
targetname=f"results/{subreddit}/{filename}.mp4",
to:
ffmpeg_extract_subclip(
f"assets/temp/{reddit_id}/temp.mp4",
0,
length,
targetname=f"results/{subreddit}/{name_normalize(filename)}.mp4"
This change removes the mentioned punctuation marks from the filename, allowing me to name the file without any issues.
hi I have zero knowledge in code or any programming can you make a video about this I was so confuse. I am stuck at USAGE and all bellow instructions.
is this can upload multiple video with schedule?
thanks
I was looking at the code and I see it uploads all the info to what looks like an AWS instance of some kind? Relevant code is here https://github.com/MiniGlome/Tiktok-uploader/blob/main/Tiktok_uploader.py#L87
I'm confused as to what this is. Can you explain it? I can't see any reference to it in the README and, as such, I personally would definitely remove it before I used this code.
Hello when i try to upload a video i've got this error can you help me ?
Traceback (most recent call last):
File "e:\Téléchargements\Tiktok-uploader-main\Tiktok-uploader-main\main.py", line 9, in
uploadVideo(session_id, file, title, tags, verbose=True)
File "e:\Téléchargements\Tiktok-uploader-main\Tiktok-uploader-main\Tiktok_uploader.py", line 200, in uploadVideo
x_csrf_token = r.headers["X-Ware-Csrf-Token"].split(',')[1]
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Zeffu\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\structures.py", line 54, in getitem
return self._store[key.lower()][1]
~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'x-ware-csrf-token'
python3 Tiktok_uploader.py -i df81bc671227de3971387910249c4XXX -p ./download/a.mp4 -t "MY SUPER TITLE" --tags Funny Joke Fyp
[-] An error occured while reaching https://www.tiktok.com/upload/
r = <Response [403]>
r.content = b''
Full response data: {'status_msg': 'Login expired', 'log_pb': {'impr_id': '202305151959173XXXXA9382831805D925'}, 'status_code': 8}
I`ve also changed from us.tiktok to www.tiktok - as it was suggested and did not solve the issue.
I`ve also rechecked that I am operating with correct session_id.
UploadTest.py
VVV
`from TiktokUploader import uploadVideo
session_id = "my session id"
file = "video_output.mp4"
title = "My Video"
tags = ["fyp", "viral"]
uploadVideo(session_id, file, title, tags, verbose=True)`
Error:
File "TiktokUploader.py", line 200, in uploadVideo x_crsf_toke = r.headers["X-Ware-Csrf-Token"].split(',')[1] File ".local/lib/python3.7/site-packages/requests/structures.py", line 52, in __getitem__ return self._store[key.lower()][1] KeyError: 'x-ware'csrf-token'
All other errors I've had have been because of connection timeouts, but I have yet to try to fix those.
def uploadVideo(session_id, video, title, tags, schedule_time=0, verbose=True):
if schedule_time - datetime.datetime.now().timestamp() > 864000: # 864000s = 10 days
print("[-] Can not schedule video in more than 10 days")
return False
if verbose:
print("Uploading video...", end='\r')
session = requests.Session()
session.cookies.set("sessionid", session_id, domain=".tiktok.com")
# Initial requests to obtain necessary tokens
url = "https://www.tiktok.com/upload/"
r = session.get(url)
if not assertSuccess(url, r):
return False
url = "https://www.tiktok.com/passport/web/account/info/"
r = session.get(url)
if not assertSuccess(url, r):
return False
user_id = r.json()["data"]["user_id_str"]
url = "https://www.tiktok.com/api/v1/video/upload/auth/"
r = session.get(url)
if not assertSuccess(url, r):
return False
# Print the JSON response for debugging
print("Video upload auth response:", r.json())
# Extract the necessary keys and tokens
video_token = r.json().get("video_token_v5", {})
access_key = video_token.get("access_key_id")
secret_key = video_token.get("secret_acess_key")
session_token = video_token.get("session_token")
# Verify that all keys are retrieved correctly
if not access_key or not secret_key or not session_token:
print("[-] Missing one or more tokens: access_key, secret_key, session_token")
return False
with open(video, "rb") as f:
video_content = f.read()
file_size = len(video_content)
url = "https://vod-us-east-1.bytevcloudapi.com/"
request_parameters = f'Action=ApplyUploadInner&FileSize={file_size}&FileType=video&IsInner=1&SpaceName=tiktok&Version=2020-11-19&s=zdxefu8qvq8'
t = datetime.datetime.utcnow()
amzdate = t.strftime('%Y%m%dT%H%M%SZ')
datestamp = t.strftime('%Y%m%d')
headers = { # Must be in alphabetical order, keys in lower case
"x-amz-date": amzdate,
"x-amz-security-token": session_token
}
signature = AWSsignature(access_key, secret_key, request_parameters, headers)
authorization = f"AWS4-HMAC-SHA256 Credential={access_key}/{datestamp}/us-east-1/vod/aws4_request, SignedHeaders=x-amz-date;x-amz-security-token, Signature={signature}"
headers["authorization"] = authorization
r = session.get(f"{url}?{request_parameters}", headers=headers)
# Print the JSON response for debugging
print("ApplyUploadInner response:", r.json())
if not assertSuccess(url, r):
return False
if 'Result' not in r.json():
print("[-] 'Result' key not found in response")
return False
upload_node = r.json()["Result"]["InnerUploadAddress"]["UploadNodes"][0]
video_id = upload_node["Vid"]
store_uri = upload_node["StoreInfos"][0]["StoreUri"]
video_auth = upload_node["StoreInfos"][0]["Auth"]
upload_host = upload_node["UploadHost"]
session_key = upload_node["SessionKey"]
Console response:
Video upload auth response: {'ak': 'b', 'audio_token_v5': {'access_key_id': 'a', 'current_time': '2024-06-17T14:44:54Z', 'expired_time': '2024-06-26T08:44:54Z', 'secret_acess_key': 'a', 'session_token': 'b=', 'space_name': 'tt_audio_mode'}, 'auth': 'd', 'extra': {'fatal_item_ids': [], 'logid': 'v', 'now': 1718635494000}, 'log_pb': {'impr_id': 'e'}, 'status_code': 0, 'status_msg': '', 'store_region': 'FR', 'video_token_v5': {'access_key_id': 'f', 'current_time': '2024-06-17T14:44:54Z', 'expired_time': '2024-07-17T14:44:54Z', 'secret_acess_key': 'g', 'session_token': 't=', 'space_name': 'tiktok'}}
ApplyUploadInner response: {'ResponseMetadata': {'RequestId': 'g', 'Action': 'ApplyUploadInner', 'Version': '2020-11-19', 'Service': 'vod', 'Region': 'us-east-1', 'Error': {'CodeN': 100026, 'Code': 'InvalidSecretToken', 'Message': 'Invalid secret token, msg: %s.'}}}
[-] 'Result' key not found in response
"Invalid secret token" while I put the correct sessionid from tiktok;
Discord: Vindyz
Telegram: @vindyz
Dm me pls
[-] An error occured while reaching https://www.tiktok.com/api/v1/item/create/
r = <Response [200]>
r.content = b'{"log_pb":{"impr_id":"2023090403330851D36B74213DF2003840"},"status_code":5,"status_msg":"Invalid parameters"}'
error when upload with schedule
thanks
Hi, Thank you for the script!
sometime I faced this error message, the title and tags are short and simple, no special characters. The SID is working with other videos.
This error video is short video (27 Seconds, 5MB, food video, no sexual, porn...)
log: {"log_pb":{"impr_id":"202302020524372DF0B8EE9477F......"},"status_code":5,"status_msg":"Invalid parameters"}
Could you please help me resolve this issue?
Thank you!
[-] An error occured while reaching https://www.tiktok.com/api/v1/item/create/
r = <Response [200]>
r.content = b'{"log_pb":{"impr_id":"20231117145132E5991D4B11738B32EFBF"},"status_code":-4,"status_msg":"Server is currently unavailable. Please try again later."}'
II get this error:
line 102, in uploadVideo
upload_node = r.json()["Result"]["InnerUploadAddress"]["UploadNodes"][0]
KeyError: 'Result'
there is any way to fix it?
[-] An error occured while reaching https://www.tiktok.com/api/v1/item/create/
r = <Response [200]>
r.content = b'{"log_pb":{"impr_id":"20231221171107DCD8961611C0881005BB"},"status_code":5,"status_msg":"Invalid parameters"}'
I don't understand what this site request is about, but is producing an error:
r = session.get(f"{url}?{request_parameters}", headers=headers)
at line 99 returns:
'{"ResponseMetadata":{"RequestId":"20240220172844394A19BBCB0FF49D19D6",
"Action":"ApplyUploadInner","Version":"2020-11-19","Service":"vod","Region":"us-east-1","Error":{"CodeN":100026,"Code":"InvalidSecretToken","Message":"Invalid secret token, msg: %s."}}}'
Anyone else having this issue? Can I get any help?
is it possible to add TikTok music in the video?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.