From 1f9ce32649f2b921765cddbfe885568e87acdca2 Mon Sep 17 00:00:00 2001 From: yuriy Date: Sat, 25 Feb 2023 00:35:40 -0500 Subject: [PATCH] commented out devmsgboxes that are no longer needed, added some extra error status messages --- Freedomain Video Uploader.ahk | 178 +++++++++++++++++----------------- 1 file changed, 89 insertions(+), 89 deletions(-) diff --git a/Freedomain Video Uploader.ahk b/Freedomain Video Uploader.ahk index 3a636e8..24dd45b 100644 --- a/Freedomain Video Uploader.ahk +++ b/Freedomain Video Uploader.ahk @@ -2959,6 +2959,7 @@ Loop, %Number_of_loops_to_Check_Upload_status% { } + CheckForAlerts() Message = Inputting Title SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") @@ -2983,6 +2984,10 @@ Loop, %Number_of_loops_to_Check_Upload_status% { } + + Message = Inputting Description + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + ; trim description if it's too long BitchuteDescription := VideoDescription if(StrLen(BitchuteDescription) > 2995){ @@ -2992,8 +2997,6 @@ Loop, %Number_of_loops_to_Check_Upload_status% { else, JSBitchuteDescription := FormatTextToJSText(BitchuteDescription) - Message = Inputting Description - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") Loop, 10 { ; Attempt to input video description a couple of times Message = Inputting Description. Attempt #%A_index% SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") @@ -3260,7 +3263,7 @@ Loop, %Number_of_loops_to_Check_Upload_status% { if(InStr(CurrentTab, "login")) ; we're logged out { - Message = Closing out of any popups that might appear on loin page + Message = Currently Logged Out`nClosing out of any popups that might appear before clicking Login button SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") Xpath = //body/div[@id='__next']/div[@id='modal-root']/div[2]/div[1]/div[1]//*[local-name()='svg'] @@ -3276,7 +3279,7 @@ Loop, %Number_of_loops_to_Check_Upload_status% { ; 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) - DevModeMsgBox(Status) + ; DevModeMsgBox(Status) Message = Checking Login Status @@ -3318,6 +3321,9 @@ Loop, %Number_of_loops_to_Check_Upload_status% { +Message = Navigating to Upload Page +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + ; Navigate to Upload Page try driver.executeScript("window.location = 'https://www.brighteon.com/dashboard/video-upload'") ;navigate using javascript @@ -3327,6 +3333,11 @@ try driver.executeScript("return document.readyState").equals("complete") Xpath = //body/div[@id='__next']/div[@id='modal-root']/div/div/div[1]//*[local-name()='svg'] try driver.FindElementByXPath(Xpath).click() + +CheckForAlerts() + +Message = Uploading Video +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") ; Upload Video Xpath = //input[@type='file'] Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoFilepath) @@ -3345,26 +3356,32 @@ loop, 3 { Return } + ; Input Title of the Video - Xpath = /html/body/div/section[2]/div[2]/div/form/div[1]/div[1]/div[2]/div[1]/div/input + Xpath = //input[@id='name'] try driver.FindElementByXPath(Xpath).SendKeys(VideoTitle) ;Sends Variable to an Xpath Item + ; click into keyword box to get focus away from title element and see if the video title registers with website + xpath = //input[@id='keywords'] + try driver.FindElementByXPath(Xpath).click() + + sleep, 500 + + ; check if title got input js = return document.querySelector("#name").value; try, status := driver.executeScript(js) + if(status = "") + continue - if(status = ""){ - Message = Failed to input Title - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - continue - } + js = return document.querySelector("#name").value; + try, status := driver.executeScript(js) Message = Title that got input: %status% SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") break } -; Msgbox % "status: " status TooltipThis("Inputting Video Description") @@ -3373,7 +3390,7 @@ TooltipThis("Inputting Video Description") ; Attempt to input video description a couple of times Loop, 10 { - Message = Inputting Description. `nAttempt Number: %A_index% + Message = Inputting Description. Attempt Number: %A_index% SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") ; SaveOrPostProgress(Message:=Message,PostType:="DiscordErrorLogging") @@ -3469,7 +3486,6 @@ Loop, 5 { ; double check on video description after inputting tags js = return document.querySelector("div[class='e-content e-lib e-keyboard'] p").innerText; try Input_Description := driver.executeScript(JS) ;Execute Javascript -DevModeMsgBox(Input_Description) ; if text in description box is longer than x chars, then description input worked if(StrLen(Input_Description) > 5){ @@ -3667,6 +3683,7 @@ try driver.executeScript("return document.readyState").equals("complete") ; wait sleep, 1500 + Message = Uploading Video SaveOrPostProgress(Message:=Message,PostType:="Tooltip") @@ -4810,111 +4827,94 @@ sleep, 5000 Return try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding -/* -; "Select Video to Upload" Button -Xpath = /html/body/main/div/div/div/section/form[1]/div/div[1] -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) -if(Status){ - Message =Upload Skipped (E#6044)`nLogin Cookies have expired. Please Re-login - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return -} - -Status := InputFilePathIntoOpenWindow(VideoFilepath) -if(Status) -{ - Message = Upload Failed:`nUnable to Find "Open File" window to input filepath into - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return -} + Message = Checking Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + CheckForAlerts() -*/ + try CurrentURL := driver.URL + if(InStr(CurrentURL, "/login.php")){ -Message = Checking Login Status -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") -try CurrentURL := driver.URL -if(InStr(CurrentURL, "/login.php")){ + ; AutoLogin := 1 + ; Msgbox % "AutoLogin: " AutoLogin + if(AutoLogin){ + Message = Logging in Automatically by clicking into the UN+PW fields for info to register + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - ; AutoLogin := 1 - ; Msgbox % "AutoLogin: " AutoLogin + ; have to click into username and password field for page to register that there's input + ; clicking with JS doesn't make it register, but with xpath selenium it does + Xpath = //input[@id='login-username'] + driver.FindElementByXPath(Xpath).click() - if(AutoLogin){ - Message = Logging in Automatically by clicking into the UN+PW fields for info to register - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + Xpath = //input[@id='login-password'] + driver.FindElementByXPath(Xpath).click() - ; have to click into username and password field for page to register that there's input - ; clicking with JS doesn't make it register, but with xpath selenium it does - Xpath = //input[@id='login-username'] - driver.FindElementByXPath(Xpath).click() - Xpath = //input[@id='login-password'] - driver.FindElementByXPath(Xpath).click() + js = document.querySelector("button[type='submit']").click(); + driver.executeScript(js) - js = document.querySelector("button[type='submit']").click(); - driver.executeScript(js) + ; Do a double check to make sure that login worked + Message = Checking Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + try CurrentURL := driver.URL - ; Do a double check to make sure that login worked - Message = Checking Login Status - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + if(!InStr(CurrentURL, "/upload")){ + Message = Failed to log back in. Please Log Back In Manually + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } - try CurrentURL := driver.URL - if(!InStr(CurrentURL, "/upload")){ - Message = Failed to log back in. Please Log Back In Manually + } + else, { ; notify user and return + Message = Login Expired. Please Log Back in SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveDriverURLOFErrorPage() Return } + Message = Waiting 5 seconds for page to fully load + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + sleep, 5000 + } + + CheckForAlerts() - } - else, { ; notify user and return - Message = Login Expired. Please Log Back in + Message = Uploading Video File + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + Xpath = //input[@id='Filedata'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoFilepath) + if(Status){ + Message = Failed to Upload Video File SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveDriverURLOFErrorPage() Return } - Message = Waiting 5 seconds for page to fully load - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 5000 -} + ; Input Title + try driver.findElementsByName("title").item[1].SendKeys(VideoTitle) ;selects element based on Name and sends variable to it. + catch e { + Message = Video Upload Failed, Please Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + ; Input Description + Loop, 5 { ; Attempt to input video description a couple of times + TooltipThis("Inputting Description `nAttempt Number: " A_index) -Message = Uploading Video File -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - -Xpath = //input[@id='Filedata'] -Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoFilepath) -if(Status){ - Message = Failed to Upload Video File - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return -} - - -; Input Title -try driver.findElementsByName("title").item[1].SendKeys(VideoTitle) ;selects element based on Name and sends variable to it. -catch e { - Message = Video Upload Failed, Please Check Login Status - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return -} -; Input Description -Loop, 5 { ; Attempt to input video description a couple of times - TooltipThis("Inputting Description `nAttempt Number: " A_index) - - status := js_SendAndCheckWithID(Element:="description",ValueToCheck:="value",SleepLength:=3000,JSStringText:=JSVideoDescription) - if(!Status) - Break + status := js_SendAndCheckWithID(Element:="description",ValueToCheck:="value",SleepLength:=3000,JSStringText:=JSVideoDescription) + if(!Status) + Break /* if(A_index = 5){ Clipboard := VideoDescription