546200350 / TikTokUploder

Upload video to Tik Tok by sessionId
MIT License
163 stars 27 forks source link

issue with function calling #46

Closed davidliaos closed 1 year ago

davidliaos commented 1 year ago
[-] An error occured while reaching https://www.tiktok.com/api/v1/web/project/create/?creation_id=qUfHZlRlWa9RLVQae6TN0&type=1&aid=1988
[-] Please try to change the --url_server argument to the adapted prefix for your account
Traceback (most recent call last):
  File "/Users/davidliao/Documents/main/main.py", line 139, in <module>
    uploadVideo(SESSION_ID, file, TITLE, TAGS, USERS)
  File "/Users/davidliao/Documents/main/uploader.py", line 32, in uploadVideo
    creationID = tempInfo["creationID"]
UnboundLocalError: local variable 'tempInfo' referenced before assignment

tried 'us' for --url_server but same issue. also tried putting "url_prefix = "www" into the function call but getting same issue, same with function definition in uploader.py i am not on a proxy/vpn should not be a serverside issue.

546200350 commented 1 year ago

mybe you need debuge here for more detail log

davidliaos commented 1 year ago

what info do you need? i am using the most up to date version, just updated it with new uploader.py, still same issue. i am just calling it from my script after importing with "uploadVideo(SESSION_ID, file, TITLE, TAGS, USERS,)". it iterates through an array containing filenames. i am using macOS Ventura 13.4 python 3.10.4 in a venv. will attempt to run this on my windows computer

davidliaos commented 1 year ago

same issue on windows with python 3.9. does calling it as a function work for you?

546200350 commented 1 year ago

the keywords is local variable 'tempInfo' referenced before assignment

davidliaos commented 1 year ago

after updating the file that error doesnt exist anymore, i am only getting


[-] An error occured while reaching https://us.tiktok.com/api/v1/web/project/create/?creation_id=oZ07hgeywDRboF4dzXYWI&type=1&aid=1988
[-] Please try to change the --url_server argument to the adapted prefix for your account

i have tried both us, and www, and renewed the session_id, still same issue.

XavierZambrano commented 1 year ago
try:
    tempInfo = r.json()['project']
except KeyError:
    print(f"[-] An error occured while reaching {url}")
    print("[-] Please try to change the --url_server argument to the adapted prefix for your account")
    return False

Add a print()

try:
    tempInfo = r.json()['project']
except KeyError:
    print(r.json())
    print(f"[-] An error occured while reaching {url}")
    print("[-] Please try to change the --url_server argument to the adapted prefix for your account")
    return False

Share the error message, with it we can know what data is in the response of TikTok

XavierZambrano commented 1 year ago

what info do you need? i am using the most up to date version, just updated it with new uploader.py, still same issue. i am just calling it from my script after importing with "uploadVideo(SESSION_ID, file, TITLE, TAGS, USERS,)". it iterates through an array containing filenames. i am using macOS Ventura 13.4 python 3.10.4 in a venv. will attempt to run this on my windows computer

You are iterating, ¿the error happens every time or sometimes?

If the error happens sometimes and not every time add a sleep between each iteration, it can help

davidliaos commented 1 year ago

added the print statement and it say it "uploads successfully" now for some reason, but not seeing it on page and its exiting after first iteration


============Start uploading video===========
[13:39:59] WARNING  /Users/davidliao/Documents/main/venv/lib/python3.10/site-packages/urllib3/connectionpool.py:10 warnings.py:109
                    56: InsecureRequestWarning: Unverified HTTPS request is being made to host 'tos-awsuseast.tiktokcdn.com'. Adding                
                    certificate verification is strongly advised. See:                                                                              
                    https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings                                                       
                      warnings.warn(                                                                                                                

============Video uploaded successfully===========
Traceback (most recent call last):
  File "/Users/davidliao/Documents/main/main.py", line 138, in <module>
    uploadVideo(SESSION_ID, file, TITLE, TAGS, USERS,)
  File "/Users/davidliao/Documents/main/uploader.py", line 105, in uploadVideo
    response = subprocess.check_output(command, encoding='utf-8').strip()[2:]
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 420, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 501, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 966, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py", line 1842, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'node'
davidliaos commented 1 year ago

fixed by exiting virtual enviroment and running

npm install jsdom
546200350 commented 1 year ago

the lates scripts remove node envirenment

KalvinThien commented 4 months ago

@546200350 @XavierZambrano ,I got the same error, tried using www and us both , here is the error message :

[-] An error occured while reaching https://www.tiktok.com/api/v1/web/project/create/?creation_id=MtEwosT4eMYB6vG49YnRi&type=1&aid=1988
[-] Please try to change the --url_server argument to the adapted prefix for your account
MoreiraTv commented 3 months ago

Me too