tiktokautouploader 2.91__py2.py3-none-any.whl → 2.98__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,17 +9,28 @@ from PIL import Image
9
9
  import sys
10
10
  import os
11
11
  import warnings
12
- warnings.filterwarnings("ignore")
12
+ warnings.simplefilter("ignore")
13
13
 
14
- def login_warning():
15
- print("NO COOKIES FILE FOUND, PLEASE LOG-IN WHEN PROMPTED")
14
+
15
+ def check_for_updates():
16
+ current_version = pkg_resources.get_distribution("tiktokautouploader").version
17
+ response = requests.get("https://pypi.org/pypi/tiktokautouploader/json")
18
+
19
+ if response.status_code == 200:
20
+ latest_version = response.json()["info"]["version"]
21
+ if current_version != latest_version:
22
+ print(f"WARNING: You are using version {current_version} of tiktokautouploader, "
23
+ f"PLEASE UPDATE TO LATEST VERSION {latest_version} FOR BEST EXPERIENCE.")
24
+
25
+ def login_warning(accountname):
26
+ print(f"NO COOKIES FILE FOUND FOR ACCOUNT {accountname}, PLEASE LOG-IN TO {accountname} WHEN PROMPTED")
16
27
 
17
28
  def save_cookies(cookies):
18
29
  with open('TK_cookies.json', 'w') as file:
19
30
  json.dump(cookies, file, indent=4)
20
31
 
21
- def check_expiry():
22
- with open('TK_cookies.json', 'r') as file:
32
+ def check_expiry(accountname):
33
+ with open(f'TK_cookies_{accountname}.json', 'r') as file:
23
34
  cookies = json.load(file)
24
35
 
25
36
  current_time = int(time.time())
@@ -38,6 +49,7 @@ def check_expiry():
38
49
  def run_javascript():
39
50
  js_file_path = pkg_resources.resource_filename(__name__, 'Js_assets/login.js')
40
51
  result = subprocess.run(['node', js_file_path], capture_output=True, text=True)
52
+ return result
41
53
 
42
54
  def install_js_dependencies():
43
55
  js_dir = pkg_resources.resource_filename(__name__, 'Js_assets')
@@ -46,6 +58,7 @@ def install_js_dependencies():
46
58
  if not os.path.exists(node_modules_path):
47
59
  print("JavaScript dependencies not found. Installing...")
48
60
  subprocess.run(['npm', 'install', 'playwright', 'playwright-extra', 'puppeteer-extra-plugin-stealth', '--silent'], cwd=js_dir, check=True)
61
+ subprocess.run(['npx', 'playwright', 'install', 'chromium'], cwd=js_dir, check=True)
49
62
  else:
50
63
  time.sleep(0.1)
51
64
 
@@ -86,11 +99,24 @@ def understood_Qs(question):
86
99
  'has strings': 'guitar',
87
100
  'oval and inflatable': 'football',
88
101
  'strumming': 'guitar',
89
- 'bounces on courts': 'basketball',
102
+ 'bounces': 'basketball',
90
103
  'musical instrument': 'guitar',
91
104
  'laces': 'football',
92
105
  'bands': 'guitar',
93
- 'leather': 'football'
106
+ 'leather': 'football',
107
+ 'leaves':'tree',
108
+ 'pages': 'book',
109
+ 'throwing': 'football',
110
+ 'tossed in a spiral': 'football',
111
+ 'spiky crown': 'pineapple',
112
+ 'pigskin': 'football',
113
+ 'photography': 'camera',
114
+ 'lens': 'camera',
115
+ 'grow': 'tree',
116
+ 'captures images': 'camera',
117
+ 'keeps doctors': 'apple',
118
+ 'crown': 'pineapple',
119
+ 'driven': 'car',
94
120
  }
95
121
 
96
122
  for key in understood_terms.keys():
@@ -116,8 +142,7 @@ def download_image(image_url):
116
142
 
117
143
  def run_inference_on_image_tougher(image_path, object):
118
144
 
119
- found_proper = False
120
- model = inference.get_model("captcha-2-6ehbe/1")
145
+ model = inference.get_model("captcha-2-6ehbe/2")
121
146
  results = model.infer(image=image_path)
122
147
 
123
148
  class_names = []
@@ -137,12 +162,9 @@ def run_inference_on_image_tougher(image_path, object):
137
162
  if classes == class_to_click:
138
163
  bounding_box.append(bounding_boxes[i])
139
164
 
140
- if len(bounding_box) == 2:
141
- found_proper = True
142
165
 
143
- found_proper = True
144
166
 
145
- return bounding_box, found_proper
167
+ return bounding_box
146
168
 
147
169
  def run_inference_on_image(image_path):
148
170
 
@@ -201,7 +223,7 @@ def click_on_objects(page, object_coords):
201
223
 
202
224
 
203
225
 
204
- def upload_tiktok(video, description, hashtags=None, sound_name=None, sound_aud_vol='mix', schedule=None, day=None, copyrightcheck=False, suppressprint=False):
226
+ def upload_tiktok(video, description, accountname, hashtags=None, sound_name=None, sound_aud_vol='mix', schedule=None, day=None, copyrightcheck=False, suppressprint=False):
205
227
 
206
228
  """
207
229
  UPLOADS VIDEO TO TIKTOK
@@ -217,28 +239,37 @@ def upload_tiktok(video, description, hashtags=None, sound_name=None, sound_aud_
217
239
  suppressprint (bool) -> True means function doesnt print anything to provide updates on progress
218
240
  --------------------------------------------------------------------------------------------------------------------------------------------
219
241
  """
242
+ try:
243
+ check_for_updates()
244
+ except:
245
+ time.sleep(0.1)
220
246
 
221
247
  retries = 0
222
248
  cookie_read = False
223
- install_js_dependencies()
249
+ oldQ = 'N.A'
250
+
251
+ if accountname == None:
252
+ sys.exit("PLEASE ENTER NAME OF ACCOUNT TO POST ON, READ DOCUMENTATION FOR MORE INFO")
224
253
 
225
- if os.path.exists('TK_cookies.json'):
226
- cookies, cookie_read = read_cookies(cookies_path='TK_cookies.json')
227
- expired = check_expiry()
254
+ if os.path.exists(f'TK_cookies_{accountname}.json'):
255
+ cookies, cookie_read = read_cookies(cookies_path=f'TK_cookies_{accountname}.json')
256
+ expired = check_expiry(accountname=accountname)
228
257
  if expired == True:
229
- os.remove('TK_cookies.json')
230
- print("COOKIES EXPIRED, PLEASE LOG-IN AGAIN")
258
+ os.remove(f'TK_cookies_{accountname}.json')
259
+ print(f"COOKIES EXPIRED FOR ACCOUNT {accountname}, PLEASE LOG-IN AGAIN")
231
260
  cookie_read = False
232
261
 
233
262
  if cookie_read == False:
234
- login_warning()
235
- run_javascript()
263
+ install_js_dependencies()
264
+ login_warning(accountname=accountname)
265
+ result = run_javascript()
266
+ os.rename('TK_cookies.json', f'TK_cookies_{accountname}.json')
236
267
 
237
- cookies, cookie_read = read_cookies("TK_cookies.json")
268
+ cookies, cookie_read = read_cookies(f"TK_cookies_{accountname}.json")
238
269
  if cookie_read == False:
239
270
  sys.exit("ERROR READING COOKIES")
240
271
 
241
-
272
+
242
273
  with sync_playwright() as p:
243
274
 
244
275
  browser = p.firefox.launch(headless=True)
@@ -247,7 +278,9 @@ def upload_tiktok(video, description, hashtags=None, sound_name=None, sound_aud_
247
278
  context.add_cookies(cookies)
248
279
  page = context.new_page()
249
280
  url = 'https://www.tiktok.com/tiktokstudio/upload?from=upload&lang=en'
250
- url2 = 'https://www.tiktok.com/tiktokstudio/content?tab=draft'
281
+
282
+ if suppressprint == False:
283
+ print(f"Uploading to account '{accountname}'")
251
284
 
252
285
  while retries < 2:
253
286
  try:
@@ -279,24 +312,28 @@ def upload_tiktok(video, description, hashtags=None, sound_name=None, sound_aud_
279
312
  print("CAPTCHA DETECTED, Attempting to solve")
280
313
  solved = False
281
314
  attempts = 0
315
+ question = page.locator('div.VerifyBar___StyledDiv-sc-12zaxoy-0.hRJhHT').text_content()
282
316
  while solved == False:
283
317
  attempts += 1
284
- question = page.locator('div.VerifyBar___StyledDiv-sc-12zaxoy-0.hRJhHT').text_content()
285
- if 'Select 2 objects that are the same' in question:
318
+ start_time = time.time()
319
+ while question == oldQ:
320
+ question = page.locator('div.VerifyBar___StyledDiv-sc-12zaxoy-0.hRJhHT').text_content()
321
+ if time.time() - start_time > 2:
322
+ break
323
+ if 'Select 2 objects that are the same' in question or 'Select two objects that are the same' in question:
286
324
  found = False
287
325
  while found == False:
288
326
  page.click('span.secsdk_captcha_refresh--text')
289
- time.sleep(0.5)
290
327
  image = get_image_src(page)
291
328
  img_path = download_image(image)
292
329
  b_box, found = run_inference_on_image(image_path=img_path)
293
330
 
294
331
  with Image.open(img_path) as img:
295
332
  image_size = img.size
296
-
297
- image = page.locator('#captcha-verify-image')
298
- image.wait_for()
299
- box = image.bounding_box()
333
+
334
+ imageweb = page.locator('#captcha-verify-image')
335
+ imageweb.wait_for()
336
+ box = imageweb.bounding_box()
300
337
  image_x = box['x']
301
338
  image_y = box['y']
302
339
  image_height_web = box['height']
@@ -304,40 +341,47 @@ def upload_tiktok(video, description, hashtags=None, sound_name=None, sound_aud_
304
341
  image_width_real, image_height_real = image_size
305
342
 
306
343
  webpage_coords = convert_to_webpage_coordinates(b_box, image_x, image_y, image_height_web, image_width_web, image_height_real, image_width_real)
344
+ if not webpage_coords:
345
+ webpage_coords.append((image_x + 50, image_y + 50))
307
346
  click_on_objects(page, webpage_coords)
347
+ page.click("div.verify-captcha-submit-button")
308
348
  time.sleep(0.5)
309
349
  if attempts > 5:
310
350
  sys.exit("FAILED TO SOLVE CAPTCHA")
311
- try:
312
- page.wait_for_selector('.upload-text-container', timeout=5000)
313
- os.remove('captcha_image.jpg')
314
- if suppressprint == False:
315
- print("Captcha Solved")
316
- solved = True
317
- except:
318
- continue
351
+ while showedup == False:
352
+ if page.locator("div.captcha_verify_message.captcha_verify_message-pass").is_visible():
353
+ solved = True
354
+ showedup = True
355
+ os.remove('captcha_image.jpg')
356
+ if page.locator("div.captcha_verify_message.captcha_verify_message-fail").is_visible():
357
+ showedup = True
358
+ oldQ = question
359
+ page.click('span.secsdk_captcha_refresh--text')
319
360
  else:
320
- found_prop = False
321
- while found_prop == False:
361
+ objectclick = understood_Qs(question)
362
+ while objectclick == 'N.A':
363
+ oldQ = question
322
364
  page.click('span.secsdk_captcha_refresh--text')
323
- time.sleep(0.5)
324
- question = page.locator('div.VerifyBar___StyledDiv-sc-12zaxoy-0.hRJhHT').text_content()
325
- objectclick = understood_Qs(question)
326
- while objectclick == 'N.A':
327
- page.click('span.secsdk_captcha_refresh--text')
328
- page.wait_for_selector('div.VerifyBar___StyledDiv-sc-12zaxoy-0.hRJhHT')
365
+ start_time = time.time()
366
+ runs = 0
367
+ while question == oldQ:
368
+ runs += 1
329
369
  question = page.locator('div.VerifyBar___StyledDiv-sc-12zaxoy-0.hRJhHT').text_content()
330
- objectclick = understood_Qs(question)
331
- image = get_image_src(page)
332
- img_path = download_image(image)
333
- b_box, found_prop = run_inference_on_image_tougher(image_path=img_path, object=objectclick)
334
-
370
+ if runs > 1:
371
+ time.sleep(1)
372
+ if time.time() - start_time > 2:
373
+ break
374
+ objectclick = understood_Qs(question)
375
+ image = get_image_src(page)
376
+ img_path = download_image(image)
377
+ b_box = run_inference_on_image_tougher(image_path=img_path, object=objectclick)
378
+
335
379
  with Image.open(img_path) as img:
336
380
  image_size = img.size
337
-
338
- image = page.locator('#captcha-verify-image')
339
- image.wait_for()
340
- box = image.bounding_box()
381
+
382
+ imageweb = page.locator('#captcha-verify-image')
383
+ imageweb.wait_for()
384
+ box = imageweb.bounding_box()
341
385
  image_x = box['x']
342
386
  image_y = box['y']
343
387
  image_height_web = box['height']
@@ -345,21 +389,25 @@ def upload_tiktok(video, description, hashtags=None, sound_name=None, sound_aud_
345
389
  image_width_real, image_height_real = image_size
346
390
 
347
391
  webpage_coords = convert_to_webpage_coordinates(b_box, image_x, image_y, image_height_web, image_width_web, image_height_real, image_width_real)
348
-
349
-
392
+ if not webpage_coords:
393
+ webpage_coords.append((image_x + 50, image_y + 50))
350
394
  click_on_objects(page, webpage_coords)
351
- time.sleep(0.5)
352
395
  page.click("div.verify-captcha-submit-button")
353
- if attempts > 10:
396
+ time.sleep(1)
397
+ if attempts > 20:
354
398
  sys.exit("FAILED TO SOLVE CAPTCHA")
355
- try:
356
- page.wait_for_selector('.upload-text-container', timeout=5000)
357
- solved = True
358
- os.remove('captcha_image.jpg')
359
- if suppressprint == False:
360
- print("Captcha Solved")
361
- except:
362
- continue
399
+ showedup = False
400
+ while showedup == False:
401
+ if page.locator("div.captcha_verify_message.captcha_verify_message-pass").is_visible():
402
+ solved = True
403
+ showedup = True
404
+ os.remove('captcha_image.jpg')
405
+ if suppressprint == False:
406
+ print("CAPTCHA SOLVED")
407
+ if page.locator("div.captcha_verify_message.captcha_verify_message-fail").is_visible():
408
+ showedup = True
409
+ oldQ = question
410
+ page.click('span.secsdk_captcha_refresh--text')
363
411
 
364
412
 
365
413
  try:
@@ -418,7 +466,7 @@ def upload_tiktok(video, description, hashtags=None, sound_name=None, sound_aud_
418
466
  time.sleep(0.2)
419
467
  if suppressprint == False:
420
468
  print("Tik tok done loading file onto servers")
421
-
469
+
422
470
  if schedule != None:
423
471
  try:
424
472
  hour = schedule[0:2]
@@ -465,7 +513,6 @@ def upload_tiktok(video, description, hashtags=None, sound_name=None, sound_aud_
465
513
  if (schedule == None) and (day != None):
466
514
  sys.exit("ERROR: CANT SCHEDULE FOR ANOTHER DAY USING 'day' WITHOUT ALSO INCLUDING TIME OF UPLOAD WITH 'schedule'; PLEASE ALSO INCLUDE TIME WITH 'schedule' PARAMETER")
467
515
 
468
-
469
516
  if(sound_name == None):
470
517
  if copyrightcheck == True:
471
518
  page.locator(".TUXSwitch-input").nth(0).click()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: tiktokautouploader
3
- Version: 2.91
3
+ Version: 2.98
4
4
  Summary: Upload or schedule videos to TikTok with viral TikTok sounds and hashtags.
5
5
  Project-URL: Homepage, https://github.com/haziq-exe/TikTokAutoUploader
6
6
  Author-email: HAZIQ <haziqmk123@gmail.com>
@@ -31,16 +31,17 @@ Description-Content-Type: text/markdown
31
31
 
32
32
 
33
33
  <p align="center">
34
- <img src="READMEimage/Image.png" alt="" width="400"/>
34
+ <img src="READMEimage/READMEvid.gif" alt="" width="900"/>
35
35
  </p>
36
36
 
37
37
  ## 🚀 Features
38
38
 
39
- - **🔐 Bypass/Auto Solve Captchas:** No more manual captcha solving; fully automated process!
40
- - **🎵 Use TikTok Sounds:** Seamlessly add popular TikTok sounds to your videos.
39
+ - **🔐 Bypass/Auto Solve Captchas:** No need to worry about any captchas interrupting the process, they'll be solved!
40
+ - **🎵 Use TikTok Sounds:** Go viral by seamlessly adding popular TikTok sounds to your videos.
41
41
  - **🗓 Schedule Uploads:** Upload videos at specific times or upto 10 days in advance with our scheduling feature.
42
42
  - **🔍 Copyright Check:** Ensure your video is safe from copyright claims before uploading.
43
43
  - **🏷 Add Working Hashtags:** Increase your reach by adding effective hashtags that actually work.
44
+ - **⏰ Cutdown on upload time:** Upload to TikTok with way less hassle and much more speed using our library
44
45
 
45
46
 
46
47
  ## 📦 Installation
@@ -51,6 +52,8 @@ Description-Content-Type: text/markdown
51
52
  pip install tiktokautouploader
52
53
  ```
53
54
 
55
+ **NOTE:** IF YOU HAVE INSTALLED BEFORE, PLEASE MAKE SURE YOU HAVE LATEST VERSION INSTALLED OR ELSE YOU MIGHT FACE BUGS
56
+
54
57
  ---
55
58
 
56
59
  ## ⚙️ Pre-requisites
@@ -60,23 +63,24 @@ pip install tiktokautouploader
60
63
  - **Note:** The necessary JavaScript dependencies (`playwright`,`playwright-extra`, `puppeteer-extra-plugin-stealth`) will be AUTOMATICALLY installed the first time you run the function, so you don't need to install them manually. Make sure that `npm` (Node.js package manager) is available in your system's PATH.
61
64
 
62
65
 
63
- 2. **Browser Binaries:** If you don't have them already, you'll need to install the chromium browser binary for `playwright`.
66
+ 2. **Browser Binaries:** If you don't have them already, you'll need to install the browser binaries for `playwright`. This library uses chromium and firefox.
64
67
 
65
- To do so, just run the following command AFTER installing the package:
68
+ to do so, just run the following command AFTER installing the package:
69
+
70
+ ```bash
71
+ python -m playwright install
72
+ ```
66
73
 
67
- ```bash
68
- python -m playwright install chromium
69
- ```
74
+ **NOTE:** If you want to add sounds to your TikTok, you MUST have the ability to save drafts. If you don't want to add sounds then you don't need this feature.
70
75
 
71
76
 
72
77
  ## 📝 Quick-Start
73
78
 
74
- Here's how to upload a video to TikTok with hashtags using `tiktokautouploader`:
75
-
76
- NOTE: It is highly recommended you read DOCUMENTATION.md before using the library.
77
-
79
+ **NOTE:** It is highly recommended you read DOCUMENTATION.md before using the library.
78
80
  The first time you run the code, you will be prompted to log-in, this will only occur the first time the function is used. Check documentation for more info.
79
81
 
82
+ ## Upload with hashtags
83
+
80
84
  ```python
81
85
  from tiktokautouploader import upload_tiktok
82
86
 
@@ -116,6 +120,7 @@ upload_tiktok(video=video_path, description=description, hashtags=hashtags, copy
116
120
  - **Maximize your reach:** Add popular sounds and effective hashtags that work to boost visibility.
117
121
  - **Stay compliant:** Built-in copyright checks to avoid unforeseen takedowns.
118
122
  - **Convenient scheduling:** Post at the right time, even when you're away.
123
+ - **Much faster than manually uploading:** Drastically reduce the time you need to upload videos, just click one button and be done much quicker!
119
124
 
120
125
  ## 🛠 Dependencies
121
126
 
@@ -131,7 +136,7 @@ These will be automatically installed when you install the package.
131
136
 
132
137
  ## 👤 Author
133
138
 
134
- Created by **Haziq Khalid**. Feel free to reach out at [haziqmk123@gmail.com](mailto:haziqmk123@gmail.com) or my LinkedIn.
139
+ Created by **Haziq**. Feel free to reach out at [haziqmk123@gmail.com](mailto:haziqmk123@gmail.com)
135
140
 
136
141
  ## 📄 License
137
142
 
@@ -0,0 +1,7 @@
1
+ tiktokautouploader/__init__.py,sha256=u7OWCK_u68ST8dfrkSF4Yw44CJOzV9NXI6ASRuoDfmE,64
2
+ tiktokautouploader/function.py,sha256=wUI4r8dPIj6eSyi2WvBFJHb3zYyNAPonw_xrrMtJvBQ,35203
3
+ tiktokautouploader/Js_assets/login.js,sha256=SLhtPYo8ZfTRUnbR7Xqp084lSuAOqIWUxi75FlFH3vs,966
4
+ tiktokautouploader-2.98.dist-info/METADATA,sha256=NXjc7EasXewxxIrnTJSb295_-UD9Q4-AcA5aKy5Jt98,5464
5
+ tiktokautouploader-2.98.dist-info/WHEEL,sha256=fl6v0VwpzfGBVsGtkAkhILUlJxROXbA3HvRL6Fe3140,105
6
+ tiktokautouploader-2.98.dist-info/licenses/LICENSE.md,sha256=hYds_VJIpnS5gC73WhuWk2IY_e9BWjuEJthQCb9ThyU,1073
7
+ tiktokautouploader-2.98.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- tiktokautouploader/__init__.py,sha256=u7OWCK_u68ST8dfrkSF4Yw44CJOzV9NXI6ASRuoDfmE,64
2
- tiktokautouploader/function.py,sha256=xH9h_yIxwuUo-CfvR1NpHDyGBhrS-6n-enNMx1l2Dqw,32635
3
- tiktokautouploader/Js_assets/login.js,sha256=SLhtPYo8ZfTRUnbR7Xqp084lSuAOqIWUxi75FlFH3vs,966
4
- tiktokautouploader-2.91.dist-info/METADATA,sha256=ZoRMgMxspM1jBl-keLV6Y8JspObu8dUiahKYyFaY0KQ,4912
5
- tiktokautouploader-2.91.dist-info/WHEEL,sha256=fl6v0VwpzfGBVsGtkAkhILUlJxROXbA3HvRL6Fe3140,105
6
- tiktokautouploader-2.91.dist-info/licenses/LICENSE.md,sha256=hYds_VJIpnS5gC73WhuWk2IY_e9BWjuEJthQCb9ThyU,1073
7
- tiktokautouploader-2.91.dist-info/RECORD,,