Closed romanrsr closed 8 months ago
can you just use the selenium version https://github.com/wanghaisheng/tiktoka-studio-uploader/tree/master/upgenius/tiktok/selenium
since many reported sessionid way does not work, I am currently working on a new mobile way
can you just use the selenium version https://github.com/wanghaisheng/tiktoka-studio-uploader/tree/master/upgenius/tiktok/selenium
since many reported sessionid way does not work, I am currently working on a new mobile way
Selenium for tiktok doesn't work, it seems there is an error in the code:
C:\Users\Administrator\Desktop\tiktoka-studio-uploader>python examples/onefile-example_tiktok_selenium.py hi Traceback (most recent call last): File "C:\Users\Administrator\Desktop\tiktoka-studio-uploader\examples\onefile-example_tiktok_selenium.py", line 39, in <module> auth = AuthBackend(cookies="cookies.json") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\upgenius-0.1.16-py3.11.egg\upgenius\tiktok\selenium\auth.py", line 36, in __init__ self.cookies = self.get_cookies(path=cookies) if cookies else [] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\upgenius-0.1.16-py3.11.egg\upgenius\tiktok\selenium\auth.py", line 123, in get_cookies for line in lines: ^^^^^ UnboundLocalError: cannot access local variable 'lines' where it is not associated with a value
@romanrsr have a quick fix ,can you test
Now I get the following error:
Traceback (most recent call last): File "C:\Users\Administrator\Desktop\tiktoka-studio-uploader\examples\onefile-example_tiktok_selenium.py", line 39, in <module> auth = AuthBackend(cookies="cookies.json") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\upgenius-0.1.16-py3.11.egg\upgenius\tiktok\selenium\auth.py", line 37, in __init__ self.cookies = self.get_cookies(path=cookies) if cookies else [] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\upgenius-0.1.16-py3.11.egg\upgenius\tiktok\selenium\auth.py", line 114, in get_cookies return load_json_cookie_file(path) ^^^^^^^^^^^^^^^^^^^^^ NameError: name 'load_json_cookie_file' is not defined
this should work now
how-to-upload-tiktok.md @romanrsr
I have already managed to get this to load the cookies thanks to the new manual, but now I receive the following error:
(.venv) C:\Users\romanrsr\Desktop\tiktoka>python examples/onefile-example_tiktok_selenium.py Traceback (most recent call last): File "C:\Users\romanrsr\Desktop\tiktoka\examples\onefile-example_tiktok_selenium.py", line 58, in <module> auth = AuthBackend(cookies="tests/achievemorenow_-cookie.json") File "C:\Users\romanrsr\Desktop\tiktoka\.venv\lib\site-packages\upgenius-0.1.16-py3.9.egg\upgenius\tiktok\selenium\auth.py", line 38, in __init__ self.cookies = self.get_cookies(path=cookies) if cookies else [] File "C:\Users\romanrsr\Desktop\tiktoka\.venv\lib\site-packages\upgenius-0.1.16-py3.9.egg\upgenius\tiktok\selenium\auth.py", line 116, in get_cookies return self.load_json_cookie_file(path) File "C:\Users\romanrsr\Desktop\tiktoka\.venv\lib\site-packages\upgenius-0.1.16-py3.9.egg\upgenius\tiktok\selenium\auth.py", line 93, in load_json_cookie_file cookie["sameSite"] != "no_restriction" TypeError: string indices must be integers
would you mind post cookie file there is incompatible issue with cookie.json format from what i know
Yes, attached. Thanks!
fix this @romanrsr
Thank you! The cookies thing has been solved, now the error is the following:
Traceback (most recent call last): File "C:\Users\romanrsr\Desktop\tiktoka\examples\onefile-example_tiktok_selenium.py", line 64, in <module> upload_videos(morevideos, File "C:\Users\romanrsr\Desktop\tiktoka\.venv\lib\site-packages\upgenius-0.1.16-py3.9.egg\upgenius\tiktok\selenium\uploader.py", line 103, in upload_videos driver = get_browser(name=browser, headless=headless, proxy=proxy, *args, **kwargs) File "C:\Users\romanrsr\Desktop\tiktoka\.venv\lib\site-packages\upgenius-0.1.16-py3.9.egg\upgenius\tiktok\selenium\browsers.py", line 34, in get_browser service = get_service(name=name) File "C:\Users\romanrsr\Desktop\tiktoka\.venv\lib\site-packages\upgenius-0.1.16-py3.9.egg\upgenius\tiktok\selenium\browsers.py", line 62, in get_service return services[name]() File "C:\Users\romanrsr\Desktop\tiktoka\.venv\lib\site-packages\upgenius-0.1.16-py3.9.egg\upgenius\tiktok\selenium\browsers.py", line 199, in <lambda> 'chrome': lambda : ChromeService(ChromeDriverManager().install()), File "C:\Users\romanrsr\Desktop\tiktoka\.venv\lib\site-packages\webdriver_manager\chrome.py", line 40, in install driver_path = self._get_driver_binary_path(self.driver) File "C:\Users\romanrsr\Desktop\tiktoka\.venv\lib\site-packages\webdriver_manager\core\manager.py", line 40, in _get_driver_binary_path file = self._download_manager.download_file(driver.get_driver_download_url(os_type)) File "C:\Users\romanrsr\Desktop\tiktoka\.venv\lib\site-packages\webdriver_manager\drivers\chrome.py", line 32, in get_driver_download_url driver_version_to_download = self.get_driver_version_to_download() File "C:\Users\romanrsr\Desktop\tiktoka\.venv\lib\site-packages\webdriver_manager\core\driver.py", line 48, in get_driver_version_to_download return self.get_latest_release_version() File "C:\Users\romanrsr\Desktop\tiktoka\.venv\lib\site-packages\webdriver_manager\drivers\chrome.py", line 64, in get_latest_release_version determined_browser_version = ".".join(determined_browser_version.split(".")[:3]) AttributeError: 'NoneType' object has no attribute 'split'
@romanrsr I have make a update with new seleniumbase instead of old ways,can you just test this
Thanks! now the error is the following:
`13:43:32] Authenticating browser with cookies Traceback (most recent call last): File "C:\Users\Administrator\Desktop\tiktok\tiktoka-studio-uploader.venv\Lib\site-packages\urllib3\connection.py", line 203, in _new_conn sock = connection.create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\Desktop\tiktok\tiktoka-studio-uploader.venv\Lib\site-packages\urllib3\util\connection.py", line 85, in create_connection raise err File "C:\Users\Administrator\Desktop\tiktok\tiktoka-studio-uploader.venv\Lib\site-packages\urllib3\util\connection.py", line 73, in create_connection sock.connect(sa) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "C:\Users\Administrator\Desktop\tiktok\tiktoka-studio-uploader.venv\Lib\site-packages\urllib3\connectionpool.py", line 790, in urlopen response = self._make_request( ^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\Desktop\tiktok\tiktoka-studio-uploader.venv\Lib\site-packages\urllib3\connectionpool.py", line 496, in _make_request conn.request( File "C:\Users\Administrator\Desktop\tiktok\tiktoka-studio-uploader.venv\Lib\site-packages\urllib3\connection.py", line 395, in request self.endheaders() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 1289, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 1048, in _send_output self.send(msg) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 986, in send self.connect() File "C:\Users\Administrator\Desktop\tiktok\tiktoka-studio-uploader.venv\Lib\site-packages\urllib3\connection.py", line 243, in connect self.sock = self._new_conn() ^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\Desktop\tiktok\tiktoka-studio-uploader.venv\Lib\site-packages\urllib3\connection.py", line 218, in _new_conn raise NewConnectionError( urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x00000170ECE66990>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\tiktok\tiktoka-studio-uploader\examples\onefile-example_tiktok_selenium.py", line 64, in
can you do this git clone this to another fresh folder eg 'test' cd to test run the following
pip uninstall -y upgenius python3 -m venv .venv
source .venv/Scripts/activate py -m pip install -r requirements.txt python setup.py install
PWDEBUG=0 HOME=/root python examples/onefile-example_tiktok_selenium.py
I have tried everything exactly as you tell me, (I have even tried it from a new VM), but the error is always the same:
File "C:\Users\Administrator\Desktop\test\tiktoka-studio-uploader\.venv\Lib\site-packages\urllib3\util\retry.py", line 515, in increment raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=57758): Max retries exceeded with url: /session/6cebb1f9ba86dde3bad0080683696fb8/url (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002C8A68F6AD0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))
can you give me your full log
Using d:\workspace\tiktoka\tiktoka-studio-uploader\.venv\lib\site-packages
Searching for typing-extensions==4.9.0
Best match: typing-extensions 4.9.0
Adding typing-extensions 4.9.0 to easy-install.pth file
Using d:\workspace\tiktoka\tiktoka-studio-uploader\.venv\lib\site-packages
Finished processing dependencies for upgenius==0.1.16
<class 'dict'>
<class 'dict'> {'name': 'msToken', 'value': 'ROYH71wUIvgSpjprmC-r778GFRJJqf0X9qWaM43bFvXJdiTG_YgEhhzjh3uEhZGpsanTVT4-JyWmdzAXKE_5NKoMhYflv_6ZNtV4dncZxmjGUVzyafZTONJR-3D_PB_aV-o=', 'domain': '.tiktokw.us', 'path': '/', 'expires': 1704682141, 'httpOnly': False, 'secure': True, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'tt_csrf_token', 'value': 'KLcvyiaV-4boujZJv6YAnXmo9UBmhxlBYApM', 'domain': '.tiktok.com', 'path': '/', 'expires': -1, 'httpOnly': True, 'secure': True, 'sameSite': 'Lax'} -------------
<class 'dict'> {'name': 'passport_csrf_token', 'value': '45575b210a6d37563accf5a960318d95', 'domain': '.tiktok.com', 'path': '/', 'expires': 1709002069, 'httpOnly': False, 'secure': True, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'passport_csrf_token_default', 'value': '45575b210a6d37563accf5a960318d95', 'domain': '.tiktok.com', 'path': '/', 'expires': 1709002069, 'httpOnly': False, 'secure': False, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 's_v_web_id', 'value': 'verify_lqq1asdr_eoceH1b3_Aozk_4YsW_B6RP_UTBVsyvNVQho', 'domain': '.tiktok.com', 'path': '/', 'expires': -1, 'httpOnly': False, 'secure': True, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'multi_sids', 'value': '7274351387383039018%3A4df6118cd0cda04ee6617401137efcc4', 'domain': '.tiktok.com', 'path': '/', 'expires': 1709002112, 'httpOnly': True, 'secure': True, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'cmpl_token', 'value': 'AgQQAPNSF-RO0rTNXqw4ZN0T_--qdj4H_4SWYNLVXA', 'domain': '.tiktok.com', 'path': '/', 'expires': 1709002112, 'httpOnly': True, 'secure': True, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'uid_tt', 'value': '047878eddd4ac70e80d54e6803d02afa850bdad1575ee7cf6d98a381534c5c03', 'domain': '.tiktok.com', 'path': '/', 'expires': 1719370112, 'httpOnly': True, 'secure': True, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'uid_tt_ss', 'value': '047878eddd4ac70e80d54e6803d02afa850bdad1575ee7cf6d98a381534c5c03', 'domain': '.tiktok.com', 'path': '/', 'expires': 1719370112, 'httpOnly': True, 'secure': True, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'sid_tt', 'value': '4df6118cd0cda04ee6617401137efcc4', 'domain': '.tiktok.com', 'path': '/', 'expires': 1719370112, 'httpOnly': True, 'secure': True, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'sessionid', 'value': '4df6118cd0cda04ee6617401137efcc4', 'domain': '.tiktok.com', 'path': '/', 'expires': 1719370112, 'httpOnly': True, 'secure': True, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'sessionid_ss', 'value': '4df6118cd0cda04ee6617401137efcc4', 'domain': '.tiktok.com', 'path': '/', 'expires': 1719370112, 'httpOnly': True, 'secure': True, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'tt-target-idc-sign', 'value': '1D-pZzy3ltYwZLUBJce0u9hrpli2LZYuSeva6WvXhk2bXTx--DbTMzxjPc8MRCrBZdzssLl1a-p1w-LxscMxJIZe9guqUo6_NRRcmGhZ_m74mX6yb1b0530zLazmzBObtjGjkPBQRNNieSuEjAMPHxOAM96D7iTgqVT4fNIJjCoPAVi20ZKnNkSK2ao3ZAdUWdqVWIB82k1y7TyZ7urw9bSLJUX8p_VhYUullugoE1DLVmg33muVkXS1NJRui6_lEc4Rx242-J1a48qIGp4MGp62Mm65zxUxCOES_QbyfDaGxa43R7-Uoip24CwcGGAKgb_ZdVRrLeZsCIIYrtyYYo7iZAfZbOhrZ9kzKIw6jsBlOmnIfAgA0bfE6mFPl4nP-pgu4QhGq7OIB8bwgKs7MdxYdvuCcjhjFYAEKqdFH9qpGImPPMKULOFnacbBEX-BG8nQ9M2izv2zAt91lavLHcBAlCH25t7IN-a8x4-arSiI8-fgU8iuq3cl930rULM5', 'domain': '.tiktok.com', 'path': '/', 'expires': 1735354113, 'httpOnly': True, 'secure': False, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'tt_chain_token', 'value': 'TGAj9LzDFfK6Cxfh0BrYHQ==', 'domain': '.tiktok.com', 'path': '/', 'expires': 1719370114, 'httpOnly': True, 'secure': True, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'tiktok_webapp_theme', 'value': 'dark', 'domain': '.www.tiktok.com', 'path': '/', 'expires': 1729738123, 'httpOnly': False, 'secure': True, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'ttwid', 'value': '1%7CgFDb2M77VLH-I4wT0JtJ87tPWWPmSoCzlMGPlQVU5I0%7C1703818124%7C1dc66835e0582dad68032949636ff59b5fc9f7ed033f1dc077ea5219f4307efd', 'domain': '.tiktok.com', 'path': '/', 'expires': 1735354124, 'httpOnly': True, 'secure': True, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'sid_guard', 'value': '4df6118cd0cda04ee6617401137efcc4%7C1703818124%7C15551988%7CWed%2C+26-Jun-2024+02%3A48%3A32+GMT', 'domain': '.tiktok.com', 'path': '/', 'expires': 1734922124, 'httpOnly': True, 'secure': True, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'sid_ucp_v1', 'value': '1.0.0-KDlmZmVkNGI0ZDczODJlYzRkN2NlNjAzNzQxNjRkYmM4OGIwMWRlODEKGAiqiNiCu4Hs-WQQjOe4rAYYsws4BEDqBxAEGgd1c2Vhc3Q1IiA0ZGY2MTE4Y2QwY2RhMDRlZTY2MTc0MDExMzdlZmNjNA', 'domain': '.tiktok.com', 'path': '/', 'expires': 1719370112, 'httpOnly': True, 'secure': True, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'ssid_ucp_v1', 'value': '1.0.0-KDlmZmVkNGI0ZDczODJlYzRkN2NlNjAzNzQxNjRkYmM4OGIwMWRlODEKGAiqiNiCu4Hs-WQQjOe4rAYYsws4BEDqBxAEGgd1c2Vhc3Q1IiA0ZGY2MTE4Y2QwY2RhMDRlZTY2MTc0MDExMzdlZmNjNA', 'domain': '.tiktok.com', 'path': '/', 'expires': 1719370112, 'httpOnly': True, 'secure': True, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'store-idc', 'value': 'useast5', 'domain': '.tiktok.com', 'path': '/', 'expires': 1719370112, 'httpOnly': True, 'secure': False, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'store-country-code', 'value': 'us', 'domain': '.tiktok.com', 'path': '/', 'expires': 1719370112, 'httpOnly': True, 'secure': False, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'store-country-code-src', 'value': 'uid', 'domain': '.tiktok.com', 'path': '/', 'expires': 1719370112, 'httpOnly': True, 'secure': False, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'tt-target-idc', 'value': 'useast5', 'domain': '.tiktok.com', 'path': '/', 'expires': 1719370112, 'httpOnly': True, 'secure': False, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'perf_feed_cache', 'value': '{%22expireTimestamp%22:1703988000000%2C%22itemIds%22:[%227307048995459812639%22%2C%227308865362924276998%22%2C%227316664378319736107%22]}', 'domain': '.www.tiktok.com', 'path': '/', 'expires': 1704250128, 'httpOnly': False, 'secure': True, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'csrf_session_id', 'value': '88586ee758542b016db2aa32b5f38a81', 'domain': 'webcast.us.tiktok.com', 'path': '/', 'expires': -1, 'httpOnly': False, 'secure': True, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'msToken', 'value': 'MU5YrY_z6huyjeuduwduKKxe_YY-Mtv8WaBUVdQQc6rtKilDfTnZ9ZI_UPe89ts6iFAD5unAAGpymlMoOUVdFbhwNig1zVooI9FHAN2lbdUu39SN3mFi6ZGqwrf4vz478PM=', 'domain': '.tiktok.com', 'path': '/', 'expires': 1704682128, 'httpOnly': False, 'secure': True, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'msToken', 'value': 'ROYH71wUIvgSpjprmC-r778GFRJJqf0X9qWaM43bFvXJdiTG_YgEhhzjh3uEhZGpsanTVT4-JyWmdzAXKE_5NKoMhYflv_6ZNtV4dncZxmjGUVzyafZTONJR-3D_PB_aV-o=', 'domain': 'www.tiktok.com', 'path': '/', 'expires': 1711594141, 'httpOnly': False, 'secure': False, 'sameSite': 'None'} -------------
<class 'dict'> {'name': 'passport_fe_beating_status', 'value': 'false', 'domain': '.www.tiktok.com', 'path': '/', 'expires': -1, 'httpOnly': False, 'secure': False, 'sameSite': 'None'} -------------
[13:23:11] Authenticating browser with cookies
[13:23:11] Uploading 2 videos
[13:23:11] Create a chrome browser instance in headless mode
================================== {onefile-example_tiktok_selenium.py:64:SB} starts ===================================
DevTools listening on ws://127.0.0.1:31631/devtools/browser/655578ad-81f2-4055-8d21-d4a89fbd977e
============================= {onefile-example_tiktok_selenium.py:64:SB} passed in 17.14s ==============================
URL format does not match the pattern
[13:23:28] Proxy is not working
Traceback (most recent call last):
File "D:\workspace\tiktoka\tiktoka-studio-uploader\examples\onefile-example_tiktok_selenium.py", line 64, in <module>
upload_videos(morevideos,
File "D:\workspace\tiktoka\tiktoka-studio-uploader\.venv\Lib\site-packages\upgenius-0.1.16-py3.12.egg\upgenius\tiktok\selenium\uploader.py", line 134, in upload_videos
raise Exception('Proxy is not working')
Exception: Proxy is not working
$ pip show urllib3 DEPRECATION: Loading egg at d:\workspace\tiktoka\tiktoka-studio-uploader.venv\lib\site-packages\upgenius-0.1.16-py3.12.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation.. Discussion can be found at https://github.com/pypa/pip/issues/12330 Name: urllib3 Version: 2.1.0 Summary: HTTP library with thread-safe connection pooling, file post, and more. Home-page: Author: Author-email: Andrey Petrov andrey.petrov@shazow.net License: Location: D:\workspace\tiktoka\tiktoka-studio-uploader.venv\Lib\site-packages Requires: Required-by: requests, selenium, seleniumbase
I disbale my proxy, and reproduce your error code
@romanrsr finally
Checklist
Description
Since December 18, for some reason Tiktok videos are not published on any of my 4 accounts. As you can see in the snapshot, although it says "Published Succefully", when I go to the Tiktok account the video does not appear published. Is there a way to leave a log, to understand what may be happening?![Sin título](https://github.com/wanghaisheng/tiktoka-studio-uploader/assets/36116699/96243077-0238-4e61-a8c2-5d46a8878d48)
Upvote & Fund