wkaisertexas / tiktok-uploader

Automatically ⬆️ upload TikTok videos
https://pypi.org/project/tiktok-uploader/
MIT License
397 stars 90 forks source link

NOT WORK #159

Closed MarcoLavoro closed 1 month ago

MarcoLavoro commented 5 months ago

If I try the bot I get this

`C:\OFFLINEPROJECTS\BOTS\TikTokUploader3\tiktok-uploader>python main.py [14:26:36] ←[92mAuthenticating browser with cookies←[0m [14:26:36] Create a chrome browser instance

DevTools listening on ws://127.0.0.1:54709/devtools/browser/9ad784ab-ac0b-4c0a-b14a-5d935226e733 [14:26:39] Authenticating browser with cookies [18508:11892:0613/142641.430:ERROR:ssl_client_socket_impl.cc(879)] handshake failed; returned -1, SSL error code 1, net_error -100 [18508:11892:0613/142641.441:ERROR:ssl_client_socket_impl.cc(879)] handshake failed; returned -1, SSL error code 1, net_error -100 [18508:11892:0613/142641.446:ERROR:ssl_client_socket_impl.cc(879)] handshake failed; returned -1, SSL error code 1, net_error -100 [18508:11892:0613/142641.559:ERROR:ssl_client_socket_impl.cc(879)] handshake failed; returned -1, SSL error code 1, net_error -107 [18508:11892:0613/142644.331:ERROR:socket_manager.cc(141)] Failed to resolve address for stun.l.google.com., errorcode: -105 [14:26:44] Posting video.mp4 with description: this is my description [14:26:44] Navigating to upload page [18508:11892:0613/142644.653:ERROR:socket_manager.cc(141)] Failed to resolve address for stun.l.google.com., errorcode: -105 [18508:11892:0613/142646.391:ERROR:socket_manager.cc(141)] Failed to resolve address for stun.l.google.com., errorcode: -105 [18508:11892:0613/142648.184:ERROR:socket_manager.cc(141)] Failed to resolve address for stun.l.google.com., errorcode: -105 [18508:11892:0613/142648.356:ERROR:socket_manager.cc(141)] Failed to resolve address for stun.l.google.com., errorcode: -105 [18508:11892:0613/142648.357:ERROR:socket_manager.cc(141)] Failed to resolve address for stun.l.google.com., errorcode: -105 [18508:11892:0613/142651.351:ERROR:ssl_client_socket_impl.cc(879)] handshake failed; returned -1, SSL error code 1, net_error -100 [18508:11892:0613/142652.673:ERROR:ssl_client_socket_impl.cc(879)] handshake failed; returned -1, SSL error code 1, net_error -100 Created TensorFlow Lite XNNPACK delegate for CPU. [18508:11892:0613/142702.904:ERROR:ssl_client_socket_impl.cc(879)] handshake failed; returned -1, SSL error code 1, net_error -100 [18508:11892:0613/142702.904:ERROR:ssl_client_socket_impl.cc(879)] handshake failed; returned -1, SSL error code 1, net_error -100 [14:27:47] Failed to upload C:\OFFLINEPROJECTS\BOTS\TikTokUploader3\tiktok-uploader\video.mp4 [14:27:47] Message: Stacktrace: GetHandleVerifier [0x00F0B8E3+45827] (No symbol) [0x00E9DCC4] (No symbol) [0x00D9150F] (No symbol) [0x00DD20BC] (No symbol) [0x00DD216B] (No symbol) [0x00E0E0F2] (No symbol) [0x00DF2E44] (No symbol) [0x00E0C034] (No symbol) [0x00DF2B96] (No symbol) [0x00DC6998] (No symbol) [0x00DC751D] GetHandleVerifier [0x011C4513+2899763] GetHandleVerifier [0x0121793D+3240797] GetHandleVerifier [0x00F913B4+593364] GetHandleVerifier [0x00F982DC+621820] (No symbol) [0x00EA70A4] (No symbol) [0x00EA37A8] (No symbol) [0x00EA3947] (No symbol) [0x00E959FE] BaseThreadInitThunk [0x75FFFCC9+25] RtlGetAppContainerNamedObjectPath [0x770E7CBE+286] RtlGetAppContainerNamedObjectPath [0x770E7C8E+238]`

    there is a way to solve this or this just do not work anymore????
Anerikc commented 5 months ago

Same here, not working since yesterday. I don't know why, maybe because Google Chrome got updated "Version 126.0.6478.57"

Julien-paulet commented 5 months ago

Hey, ran into the same issue with a fork I made on this repo ; For me, removing the switch to Iframe (right before uploading the video) worked

cateyelow commented 5 months ago

@Julien-paulet that makes sense. tiktok removed iframe

MarcoLavoro commented 5 months ago

Hey, ran into the same issue with a fork I made on this repo ; For me, removing the switch to Iframe (right before uploading the video) worked

thank you for the feedback, can you share with us in what point of the code we have to change to fix it?

cateyelow commented 5 months ago

@MarcoLavoro I fixed the issue and posted pull request. see this #160

MarcoLavoro commented 5 months ago

@MarcoLavoro I fixed the issue and posted pull request. see this #160

Ok thank you!!

I see other people have problem with the schedule, did you solved that too?

cateyelow commented 5 months ago

@MarcoLavoro you're welcome. be happy day

I don't solve the issue because i don't need the function

MarcoLavoro commented 5 months ago

Ok thank you!!

I see other people have problem with the schedule, did you solved that too?

Thank you! I tried your pull request and it work fine! But if I try to schedule the video now I get:

[11:45:35] Failed to set schedule: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='tux-1']"}

Is that normal?

cateyelow commented 5 months ago

@MarcoLavoro I don't know detailed because i had never used the function. but as the logs you write, maybe the issue can be solved by editing config.toml because of xpath.

cateyelow commented 5 months ago

@MarcoLavoro if you can analyze the xpath using dev console in the chrome, you can solve easily

MarcoLavoro commented 5 months ago

@MarcoLavoro I don't know detailed because i had never used the function. but as the logs you write, maybe the issue can be solved by editing config.toml because of xpath.

Yes at the beginning I) thought that and I changed in the config switch = "//[@id='tux-1']" to switch = "//[@id=':r19:']"

but thenk I get the error:
[11:54:04] Failed to set schedule: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id=':r19:']"}

so maybe I am missin something   :(
cateyelow commented 5 months ago

wait for a moment. I'll check it

cateyelow commented 5 months ago

@MarcoLavoro the main issue related all xpaths of schdule button, date picker, time picker. So, it should takes few hours to fully fix

Additional, switch = "//[@id=':r19:']" this not working becuase the id name be dynamic

MarcoLavoro commented 5 months ago

@MarcoLavoro the main issue related all xpaths of schdule button, date picker, time picker. So, it should takes few hours to fully fix

Additional, switch = "//[@id=':r19:']" this not working becuase the id name be dynamic

thank you for the info!!! Did you find a way to solve that and the schedule?

btw thanks for all your replies!!

cateyelow commented 5 months ago

@MarcoLavoro You're welcome. Actually I fixed 90% except time picker. however I had other schedule so i already went to other country. so, i have no time. Can you solve remains if i give you uncompleted codes?

joaovit1 commented 5 months ago

I am interested in fixing the schedule function as well, willing to help too if you give the uncompleted code, @cateyelow!

cateyelow commented 5 months ago

@joaovit1 Here it is bro~ I fixed until time_picker_containers, so start from timepicker_hours.

[config.toml]

[selectors.schedule]
switch = "//input[@name='postSchedule' and @value='schedule']"

date_picker = "(//div[contains(@class, 'TUXTextInput')]/div/div/input[@type='text'])[2]"
calendar = "//div[contains(@class, 'calendar-wrapper')]"
calendar_month = "//span[contains(@class, 'month-title')]"
calendar_valid_days = "//div[contains(@class, 'days-wrapper')]//span[contains(@class, 'day') and contains(@class, 'valid')]"
calendar_arrows = "//span[contains(@class, 'arrow')]"                                                                            # first last, second next

time_picker = "(//div[contains(@class, 'TUXTextInput')]/div/div/input[@type='text'])[1]"
time_picker_text = "(//div[contains(@class, 'TUXTextInput')]/div/div/input[@type='text'])[1]"
time_picker_container = "//div[@class='tiktok-timepicker-time-picker-container']"
timepicker_hours = "//span[contains(@class, 'tiktok-timepicker-left')]"
timepicker_minutes = "//span[contains(@class, 'tiktok-timepicker-right')]"

[upload.py]

def _set_schedule_video(driver, schedule: datetime.datetime) -> None:
    """
    Sets the schedule of the video

    Parameters
    ----------
    driver : selenium.webdriver
    schedule : datetime.datetime
        The datetime to set
    """

    logger.debug(green('Setting schedule'))

    driver_timezone = __get_driver_timezone(driver)
    schedule = schedule.astimezone(driver_timezone)

    month = schedule.month
    day = schedule.day
    hour = schedule.hour
    minute = schedule.minute

    try:
        switch = driver.find_element(By.XPATH, config['selectors']['schedule']['switch'])
        print(f"Schedule Switch: {switch}")
        switch.click()
        __date_picker(driver, month, day)
        __time_picker(driver, hour, minute)
    except Exception as e:
        msg = f'Failed to set schedule: {e}'
        logger.error(red(msg))
        raise FailedToUpload()

def __date_picker(driver, month: int, day: int) -> None:
    logger.debug(green('Picking date'))

    condition = EC.presence_of_element_located(
        (By.XPATH, config['selectors']['schedule']['date_picker'])
        )
    date_picker = WebDriverWait(driver, config['implicit_wait']).until(condition)
    date_picker.click()

    print("Date Picker Clicked")

    condition = EC.presence_of_element_located(
        (By.XPATH, config['selectors']['schedule']['calendar'])
    )
    calendar = WebDriverWait(driver, config['implicit_wait']).until(condition)

    calendar_month = driver.find_element(By.XPATH, config['selectors']['schedule']['calendar_month']).text
    n_calendar_month = datetime.datetime.strptime(calendar_month, '%B').month
    if n_calendar_month != month:  # Max can be a month before or after
        if n_calendar_month < month:
            arrow = driver.find_elements(By.XPATH, config['selectors']['schedule']['calendar_arrows'])[-1]
        else:
            arrow = driver.find_elements(By.XPATH, config['selectors']['schedule']['calendar_arrows'])[0]
        arrow.click()
    valid_days = driver.find_elements(By.XPATH, config['selectors']['schedule']['calendar_valid_days'])

    day_to_click = None
    for day_option in valid_days:
        if int(day_option.text) == day:
            day_to_click = day_option
            break
    if day_to_click:
        day_to_click.click()
    else:
        raise Exception('Day not found in calendar')
    __verify_date_picked_is_correct(driver, month, day)

def __verify_date_picked_is_correct(driver, month: int, day: int):
    date_selected = driver.find_element(By.XPATH, config['selectors']['schedule']['date_picker']).get_attribute('value')
    date_selected_month = int(date_selected.split('-')[1])
    date_selected_day = int(date_selected.split('-')[2])

    if date_selected_month == month and date_selected_day == day:
        logger.debug(green('Date picked correctly'))
    else:
        msg = f'Something went wrong with the date picker, expected {month}-{day} but got {date_selected_month}-{date_selected_day}'
        logger.error(msg)
        raise Exception(msg)

def __time_picker(driver, hour: int, minute: int) -> None:
    logger.debug(green('Picking time'))

    condition = EC.presence_of_element_located(
        (By.XPATH, config['selectors']['schedule']['time_picker'])
        )
    time_picker = WebDriverWait(driver, config['implicit_wait']).until(condition)
    time_picker.click()

    condition = EC.presence_of_element_located(
        (By.XPATH, config['selectors']['schedule']['time_picker_container'])
    )
    time_picker_container = WebDriverWait(driver, config['implicit_wait']).until(condition)

    # 00 = 0, 01 = 1, 02 = 2, 03 = 3, 04 = 4, 05 = 5, 06 = 6, 07 = 7, 08 = 8, 09 = 9, 10 = 10, 11 = 11, 12 = 12,
    # 13 = 13, 14 = 14, 15 = 15, 16 = 16, 17 = 17, 18 = 18, 19 = 19, 20 = 20, 21 = 21, 22 = 22, 23 = 23
    hour_options = driver.find_elements(By.XPATH, config['selectors']['schedule']['timepicker_hours'])
    # 00 == 0, 05 == 1, 10 == 2, 15 == 3, 20 == 4, 25 == 5, 30 == 6, 35 == 7, 40 == 8, 45 == 9, 50 == 10, 55 == 11
    minute_options = driver.find_elements(By.XPATH, config['selectors']['schedule']['timepicker_minutes'])

    hour_to_click = hour_options[hour]
    minute_option_correct_index = int(minute / 5)
    minute_to_click = minute_options[minute_option_correct_index]

    print(f"Hour to click: {hour_to_click}")
    print(f"Minute to click: {minute_to_click}")

    time.sleep(1) # temporay fix => might be better to use an explicit wait
    driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'nearest'});", hour_to_click)
    time.sleep(1) # temporay fix => might be better to use an explicit wait
    hour_to_click.click()

    driver.execute_script("arguments[0].scrollIntoView({block: 'center', inline: 'nearest'});", minute_to_click)
    time.sleep(2) # temporary fixed => Might be better to use an explicit wait
    minute_to_click.click()

    # click somewhere else to close the time picker
    # time_picker.click()

    time.sleep(.5)  # wait for the DOM change
    __verify_time_picked_is_correct(driver, hour, minute)

def __verify_time_picked_is_correct(driver, hour: int, minute: int):
    time_selected = driver.find_element(By.XPATH, config['selectors']['schedule']['time_picker_text']).get_attribute('value')
    time_selected_hour = int(time_selected.split(':')[0])
    time_selected_minute = int(time_selected.split(':')[1])

    if time_selected_hour == hour and time_selected_minute == minute:
        logger.debug(green('Time picked correctly'))
    else:
        msg = f'Something went wrong with the time picker, ' \
              f'expected {hour:02d}:{minute:02d} ' \
              f'but got {time_selected_hour:02d}:{time_selected_minute:02d}'
        raise Exception(msg)
MarcoLavoro commented 5 months ago

@joaovit1 Here it is bro~ I fixed until time_picker_containers, so start from timepicker_hours.

[selectors.schedule]
switch = "//input[@name='postSchedule' and @value='schedule']"

date_picker = "(//div[contains(@class, 'TUXTextInput')]/div/div/input[@type='text'])[2]"
calendar = "//div[contains(@class, 'calendar-wrapper')]"
calendar_month = "//span[contains(@class, 'month-title')]"
calendar_valid_days = "//div[@class='jsx-4172176419 days-wrapper']//span[contains(@class, 'day') and contains(@class, 'valid')]"
calendar_arrows = "//span[contains(@class, 'arrow')]"                                                                            # first last, second next

time_picker = "(//div[contains(@class, 'TUXTextInput')]/div/div/input[@type='text'])[1]"
time_picker_text = "(//div[contains(@class, 'TUXTextInput')]/div/div/input[@type='text'])[1]"
time_picker_container = "//div[@class='tiktok-timepicker-time-picker-container']"
timepicker_hours = "//span[contains(@class, 'tiktok-timepicker-left')]"
timepicker_minutes = "//span[contains(@class, 'tiktok-timepicker-right')]"

thank you! I am noob but I will see what I can do!

cateyelow commented 5 months ago

@MarcoLavoro I edited because reminded there's an issue on verifiy_time and verify_date Good luck bro

quyetbg commented 5 months ago

change xpath switch = driver.find_element( By.XPATH, "//input[@value='schedule']" ) will work

jbosolutions commented 4 months ago

hello! im getting some errors:

C:\Users\jbbag\OneDrive\Escritorio\otro tik>tiktok-uploader -v video.mp4 -d "this is my escaped \"description\"" -c cookies.txt [02:23:33] Authenticating browser with cookies [02:23:33] Create a firefox browser instance in headless mode [02:23:44] Authenticating browser with cookies [02:23:47] Posting video.mp4 with description: this is my escaped "description" [02:23:47] Navigating to upload page [02:23:50] Uploading video file [02:23:53] Video should be uploading [02:23:53] Video should be uploaded Message: Stacktrace: RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8 WebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:193:5 NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:511:5 dom.find/</<@chrome://remote/content/shared/DOM.sys.mjs:136:16

[02:24:54] Failed to upload C:\Users\jbbag\OneDrive\Escritorio\otro tik\video.mp4 [02:24:54] A video failed to upload


Error while uploading video

may you help me?

jbosolutions commented 4 months ago

Hey, ran into the same issue with a fork I made on this repo ; For me, removing the switch to Iframe (right before uploading the video) worked

hey how?

Julien-paulet commented 4 months ago

Hey, ran into the same issue with a fork I made on this repo ; For me, removing the switch to Iframe (right before uploading the video) worked

hey how?

I did not read the full conversation here but from what I saw the problem is fixed, maybe try updating the lib to its last version ? Otherwise, from memory there is a function "switch_to_iframe" in the function "_go_to_upload" that you need to comment

My fork differs quite a lot from the main repo, so I will not be able to help you more than this :/