From 2eb5f5abade3c394d303ee94488110b4ef89b58e Mon Sep 17 00:00:00 2001 From: yuriy Date: Wed, 15 Feb 2023 18:20:05 -0500 Subject: [PATCH] Reworked Dailymotion description inputting --- Freedomain Video Uploader.ahk | 59 +++++++++++++++++------------------ 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/Freedomain Video Uploader.ahk b/Freedomain Video Uploader.ahk index 4ee756a..55df43a 100644 --- a/Freedomain Video Uploader.ahk +++ b/Freedomain Video Uploader.ahk @@ -3061,7 +3061,6 @@ if(InStr(CurrentTab, "login")) ; we're logged out Xpath = //div[@class='overlay__close inside'] Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=100) - ; Try clicking the login button, sometimes this will auto log you back in without having to input credentials xpath = //a[normalize-space()='Log In'] Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=100) @@ -3690,45 +3689,45 @@ if(StrLen(DailyMotionJSDescription) > 3000){ Message = Inputting Video Description SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") -Loop, 15 { ; make a couple attempts to input description - Message = Video Description Input Attempt Number: %A_index% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") +Loop, 5 { ; make a couple attempts to input description + + if(A_index = 5){ + Message = Failed to input Description after %A_index% attempts. + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + ; Return + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } - ; TooltipThis("Inputting Video Description") - try driver.findElementsByName("description").item[1].SendKeys(driver.Keys.Space) ; send an ENTER keystroke to make it register that data has been input and refresh - sleep, 500 - ; Clear any text from a previous loop - try driver.findElementsByName("description").item[1].clear() + ; click into element + Xpath = //textarea[@placeholder='Enter a description'] + driver.FindElementByXPath(Xpath).click() - ; try driver.findElementsByName("description").item[1].SendKeys(driver.Keys.SPACE) ;;Clicks Item based on the Element Name - - js = document.querySelector("textarea[placeholder='Enter a description']").value = "%JSVideoDescription%"; + ; inut description with javascript + js = document.querySelector("textarea[placeholder='Enter a description']").value = "%JSVideoDescription%"; try driver.executeScript(js) - ; try driver.findElementsByName("description").item[1].SendKeys(driver.Keys.Space) ; send an ENTER keystroke to make it register that data has been input and refresh + sleep, 1000 - sleep, 15000 ; Description dissapears for some reason instantly after inputting sometimes - try Description := driver.findElementsByName("description").item[1].Attribute("value") - if(strlen(Description) 10){ - try driver.findElementsByName("description").item[1].SendKeys(driver.Keys.Space) ; send an ENTER keystroke to make it register that data has been input and refresh - Break ; break out of the loop - } + ; send a space and then backspace so element registers the input + Xpath = //textarea[@placeholder='Enter a description'] + try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.SPACE) + + try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.BackSpace) - if(A_index = 10){ - ; Clipboard := VideoDescription - Message = Upload Failed (E#7899): Failed to Input video description - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return ; Kick out of the gosub - } + js = return document.querySelector("textarea[placeholder='Enter a description']").textContent; + try, InputDescription := driver.executeScript(js) - try Description := driver.findElementsByName("description").item[1].Attribute("value") - if(StrLen(Description) > 10){ - SaveOrPostProgress(Message:="Description was input successfully",PostType:="Tooltip") - Break ; break out of the loop + ; if input description is less than 15 chars, try again + if(StrLen(InputDescription)<15){ + Continue } + + + } ; DevModeMsgBox("done")