LocalsUpload: ;------------------------------------------------ CurrentSite := "Locals" SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile") ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") IniRead, LocalsPostPageURL, %SettingsIniFilepath%, General, LocalsPostPageURL, %A_Space% if(LocalsPostPageURL = ""){ Message = LocalsURL is blank.`nPlease add Locals URL to Settings.ini file under:`n`n[General]`nLocalsPostPageURL= SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") Return } if(!InStr(LocalsPostPageURL, "/share/post")){ LocalsPostPageURL .= "/share/post" } ; replace any double slashes that migth have come from the combining ; LocalsPostPageURL := StrReplace(LocalsPostPageURL, "//", "/") Status := NavigateFromBaseURLTo(LocalsPostPageURL) if(Status) Return /* if(DevMode){ MsgBox 0x4, DevMode Skip, Skip uploading section and skip straight to grab URL? IfMsgBox Yes, { goto, Devmodeskip } Else IfMsgBox No, { } } */ Message = Waiting for Page to fully load SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") Xpath = //textarea[@id='body'] Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) if(Status){ Message = Page did not load after 10 seconds. Force stopping refresh and trying to continue SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") send, {Escape} ; Temporary workaround, as Page seems to endlessly load for Stef Xpath = //textarea[@id='body'] Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) if(Status){ SaveOrPostProgress(Message:="Post Failed: Check Login Status, or Website is Down",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") Return } } Message = Inputting Title SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") Xpath = //input[@id='title'] Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=VideoTitle) if(Status){ Message = Failed to input Title SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") } sleep, 1000 /*Xpath = //textarea[@id='body'] Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=VideoDescription) if(Status){ Message = Failed to input Body SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") } */ ; Input Description TooltipThis("Inputting Description") Loop, 5 { ; Attempt to input video description a couple of times if(A_index = 5){ Clipboard := VideoDescription Message = Unable to Input Video Description`nDescription copied to clipboard, please paste it in at your earliest convenience. SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") Return } js = document.getElementsByName('body')[0].value = "%JSVideoDescription%"; ; Send content through javascript (Great for getting around emoji chrome limitaitons) try driver.executeScript(js) ;Executes a Javascript on the webpage, mostly used for buttons. ; msgbox try driver.findElementsByName("body").item[1].SendKeys(driver.Keys.SPACE) ; driver.findElementsByID("ELEMENTID").item[1].SendKeys(driver.Keys.ENTER) ; msgbox jsCheck = return document.getElementsByName('body')[0].value; ; Send content through javascript (Great for getting around emoji chrome limitaitons) try Description := driver.executeScript(jsCheck) ;Executes a Javascript on the webpage, mostly used for buttons. ; try Description := driver.findElementsByName("body").item[1].Attribute("value") ;XPath: ID=site-title & span tag if(Description != "") Break sleep, 2000 } SaveOrPostProgress(Message:="Waiting Video to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") Message = Uploading Video File SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") Xpath = //div[@class='uploadvideo-wrapper']//input[@name='Filedata'] Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoFilepath) if(Status){ Message = Failed to Upload Video SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") Return } ; check if the "Auto Submit Post" checkbox is checked, and if not check it js = return document.querySelector("#autosubmit_enabled").checked; try AutoSubmitstatus := driver.executeScript(js) ; DevModeMsgBox(status) ; message = AutoSubmitstatus: %AutoSubmitstatus% ; DevModeMsgBox(message) if(AutoSubmitstatus = "0"){ js = document.querySelector("li[id='autosubmit_container'] small").click() ; ; CHECK YES try driver.executeScript(js) ; DevModeMsgBox(status) ; double check that it got selected js = return document.querySelector("#autosubmit_enabled").checked; try AutoSubmitstatus := driver.executeScript(js) Message = AutoSubmitstatus after clicking checkbox: %AutoSubmitstatus% DevModeMsgBox(message) if(AutoSubmitstatus != "-1"){ Message = Failed to check Auto-Submit Post checkbox SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveDriverURLOFErrorPage() Return ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") } } DevModeMsgBox("autosubmit status -1 string here") ; msgbox % AutoSubmitstatus = "-1" if(AutoSubmitstatus = "-1"){ ; if checked YES ; check that there are no error messages js = return document.querySelector("div[class='form-error']").textContent; try status := driver.executeScript(js) ; DevModeMsgBox(status) if(status){ ;if element contains error text Message = Auto Publish failed: %status% SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveDriverURLOFErrorPage() Return } if(VideoThumbFilepath){ Message = Uploading Thumbnail SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") Xpath = //div[contains(@class,'post-video-attachments post-video-attachments_upd')]//div[contains(@class,'uploadfile-wrapper')]//input[contains(@name,'Filedata')] Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoThumbFilepath) if(Status){ Message = Failed to Attach Thumbnail SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") Return } } ; otherwise everything is good and we can move on to the next site and come back to grab the URL later ; LocalsURL := "UploadedButNeedToGrabLink" ; Return Message = Upload Started Successfully SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") LocalsURL := "LocalsUploadStartedNeedToGrabURL" ; Msgbox % "LocalsURL: " LocalsURL IniWrite, %LocalsURL%, %VideoLinksIniFile%, URLs, LocalsURL AddToTotalVideosUploadedCount() ; Msgbox % "LocalsURL: " LocalsURL ; Msgbox % "VideoLinksIniFile: " VideoLinksIniFile ; ; FileRead, inicontents, %VideoLinksIniFile% ; , Filename ; Msgbox % "inicontents: " inicontents ; IniWrite, Value, Filename, Section, Key ; LocalsTabURL := SaveDriverURL() Return } Return ;--------------\Locals---------------------------------- ;--------------LocalsGrabURL---------------------------------- LocalsGrabURL: CurrentSite := Locals SaveOrPostProgress(Message:="Navigating to Locals Feed to grab URL",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") IniRead, LocalsPostPageURL, %SettingsIniFilepath%, General, LocalsPostPageURL, %A_Space% if(LocalsPostPageURL = ""){ Message = LocalsURL is blank.`nPlease add Locals URL to Settings.ini file under:`n`n[General]`nLocalsPostPageURL= SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") Return } if(InStr(LocalsPostPageURL, "/share/post")){ LocalsFeedPageURL := StrReplace(LocalsPostPageURL, "/share/post", "") } Status := ActivateChromeTab(LocalsPostPageURL) if(Status = "Failed"){ Message = Failed to Activate Locals Tab. Please grab URL manually SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") Return } ; Msgbox % "Status: " Status try currentpageURL := driver.url if(InStr(currentpageURL,"share/post")){ ; we're still on create new post page Message = Locals is still on the Create New Post page. Please double check if post was published successfully. SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveDriverURLOFErrorPage() Return } ; otherwise we should be on locals.com home feed page ; check for "Retrieve Draft button" js = return document.querySelector("a[class='btn']").innerText; try, status := driver.executeScript(js) if(status){ Message = Video was uploaded but Locals saved it as a draft instead of instantly publishing it. Please go to the Locals Page and Retrieve Draft and manually Publish it. SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveDriverURLOFErrorPage() Return } ; Get word that's longer than 4 characters in video title VideoTitleArray := StrSplit(VideoTitle, " ") ; Iterate from 1 to the end of the array: Loop % VideoTitleArray.Length(){ VideoTitleFirstWord := VideoTitleArray[A_Index] VideoTitleFirstWord := StrReplace(VideoTitleFirstWord, "_","-") if(StrLen(VideoTitleFirstWord) > 4) Break ; MsgBox % VideoTitleArray[A_Index] } loop, 7 { ElementIndexNum := A_index - 1 Message = ElementIndexNum: %ElementIndexNum% DevModeMsgBox(Message) ; Msgbox % "ElementIndexNum: " ElementIndexNum jscheck = return document.getElementsByClassName('post-bottom')[%ElementIndexNum%].outerHTML; try outerHTML := driver.executeScript(jsCheck) if(DevMode){ Message = Looking for VideoTitleFirstWord: %VideoTitleFirstWord% `nwithin outerHTML DevModeMsgBox(message) Clipboard := outerHTML DevModeMsgBox(outerHTML) } ; msgbox % "outerHTML: " . outerHTML if(InStr(OuterHTML,VideoTitleFirstWord)){ ; @todo replace with regex Message = %VideoTitleFirstWord% is in`n`n %OuterHTML% DevModeMsgBox(Message) Message = Found at at index: %A_index% DevModeMsgBox(message) ; MsgBox, found match at %A_index% DevModeMsgBox("Pulling out url from outerhtml") ShareLink := StrSplit(OuterHTML, "data-url=") ShareLink := ShareLink[2] DevModeMsgBox(ShareLink) ; Msgbox % "ShareLink: " ShareLink URLEndString = "> ShareLink := StrSplit(ShareLink, URLEndString) ShareLink := ShareLink[1] DevModeMsgBox(ShareLink) QuotationMark = " ShareLink := StrReplace(ShareLink,QuotationMark, "") DevModeMsgBox(ShareLink) Break } ShareLink := } DevModeMsgBox(ShareLink) ; ShareLink := "Successful" Message = Upload Complete: %ShareLink% SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") IniWrite, %ShareLink%, %VideoLinksIniFile%, URLs, LocalsURL AddToTotalVideosUploadedCount() SaveDriverURL() Return ;--------------/LocalsGrabURL---------------------------------- ; GetLocals ; Xpath = //div[@class='uppy-StatusBar-statusPrimary'] ; sleep, 30000 ; wait 30 seconds ; sleep, 2000 /*; Attach Custom Thumbnail if(VideoThumbFilepath != ""){ Message = Attaching Custom Thumbnail SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") Xpath = //div[@class='custom-thumb-uploader']//input[@name='Filedata'] Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoThumbFilepath) if(Status){ Message = Failed to Attach Custom Thumbnail SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") } } */ sleep, 10000 Loop, %Number_of_loops_to_Check_Upload_status% { sleep, %Time_Between_Loops_Upload_Status% jscheck = return document.getElementsByClassName('uppy-StatusBar-statusPrimary')[0].textContent; try UploadStatus := driver.executeScript(jsCheck) ; UploadStatus := StrSplit(UploadStatus, ": ") ; UploadStatus := UploadStatus[2] ; message = Waiting for Video To Finish Uploading. `nCurrent Status: %UploadStatus% ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") ; Clipboard := jsCheck ; msgbox % "textContent: " . textContent /* try UploadStatus := driver.findelementbyxpath(Xpath).Attribute("innerText") ; Grabb innertext catch e { if(A_index = 1){ Message = Unable to find Progress Upload Percentage. Upload Most Likely Failed. SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") } else, Break } */ if(InStr(UploadStatus, "100%")){ Message = Video Upload Complete. Waiting 20 seconds for Video to finalize before submitting. sleep, 20000 break } ; if(UploadStatus != ""){ ; Message = ; sleep, 30000 ; 30 seconds ; Continue ; } if(UploadStatus = "" and A_index = 1){ Message = Upload Failed. Unable to Grab Upload Status SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveDriverURLOFErrorPage() Return } ; if(UploadStatus = ""){ ; Break ; } Status := Check_For_Stuck_Video_Upload(A_index, UploadStatus) if(Status = "Failed") Return } /*; attach custom thumbnail xpath = //label[normalize-space()='Upload Custom Video Thumbnail'] Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoThumbFilepath) if(Status){ Message = Failed to Attach Thumbnail SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") ; SaveDriverURLOFErrorPage() ; Return } Status := InputFilePathIntoOpenWindow(VideoThumbFilepath) */ ; DevModeMsgBox("pause") ; Click the publish button js = document.getElementsByName('submitPost')[0].click(); try driver.executeScript(js) Message = Waiting 5 seconds for Video to Get Processed SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") sleep, 5000 try currentpage := driver.url if(CUrrentpage = LocalsPostPageURL){ Message = Final page is same as post page. Please double check if post was published successfully. SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") Return } ; sleep, 500 ; ToolTip ; AddToTotalPostsPostedCount() Devmodeskip: Message = Trying to Grab Share Link SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") ; refresh page try driver.executeScript("history.go(0)") try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding ; check for "Retrieve Draft button" js = return document.querySelector("a[class='btn']").innerText; try, status := driver.executeScript(js) if(status = "Retrieve Draft"){ Message = Video was uploaded but Locals saved it as a draft instead of instantly publishing it. Please go to the Locals Page and Retrieve Draft and manually Publish it. SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveDriverURLOFErrorPage() Return } ; Get word that's longer than 4 characters in video title VideoTitleArray := StrSplit(VideoTitle, " ") ; Iterate from 1 to the end of the array: Loop % VideoTitleArray.Length(){ VideoTitleFirstWord := VideoTitleArray[A_Index] VideoTitleFirstWord := StrReplace(VideoTitleFirstWord, "_","-") if(StrLen(VideoTitleFirstWord) > 4) Break ; MsgBox % VideoTitleArray[A_Index] } ; DevModeMsgBox(VideoTitleFirstWord) ; Message = VideoTitleFirstWord: %VideoTitleFirstWord% ; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") ; VideoTitleFirstWord := VideoTitleFirstWord[1] ; Msgbox % "VideoTitleFirstWord: " VideoTitleFirstWord /* ; Format the post title to remove all spaces and special characters to match with Locals Post ShareLinkFormatted := StrReplace(VideoTitle, " ", "-") ShareLinkFormatted := StrReplace(ShareLinkFormatted, "?", "") ShareLinkFormatted := StrReplace(ShareLinkFormatted, "!", "") ShareLinkFormatted := StrReplace(ShareLinkFormatted, ".", "") ShareLinkFormatted := StrReplace(ShareLinkFormatted, "", "") ShareLinkFormattedFirst5Chars := SubStr(ShareLinkFormatted, 1, 5) */ LocalsBaseURL := StrReplace(LocalsURL, "/share/post", "") ; Msgbox % "LocalsPostPageURL: " LocalsPostPageURL ; Msgbox % "LocalsURL: " LocalsURL ; Msgbox % "LocalsBaseURL: " LocalsBaseURL loop, 5 { ElementIndexNum := A_index - 1 DevModeMsgBox(ElementIndexNum) ; Msgbox % "ElementIndexNum: " ElementIndexNum jscheck = return document.getElementsByClassName('post-bottom')[%ElementIndexNum%].outerHTML; try outerHTML := driver.executeScript(jsCheck) ; Clipboard := outerHTML ; DevModeMsgBox(outerHTML) ; msgbox % "outerHTML: " . outerHTML if(InStr(OuterHTML,VideoTitleFirstWord)){ Message = %VideoTitleFirstWord% is in %OuterHTML% ; DevModeMsgBox(Message) ; MsgBox, found match at %A_index% ShareLink := StrSplit(OuterHTML, "data-url=") ShareLink := ShareLink[2] ; DevModeMsgBox(ShareLink) ; Msgbox % "ShareLink: " ShareLink URLEndString = "> ShareLink := StrSplit(ShareLink, URLEndString) ; ShareLink := ShareLink[1] QuotationMark = " ShareLink := StrReplace(ShareLink,QuotationMark, "") Break } ShareLink := } DevModeMsgBox(ShareLink) ; ShareLink := "Successful" Message = Upload Complete: %ShareLink% SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") IniWrite, %ShareLink%, %VideoLinksIniFile%, URLs, LocalsURL AddToTotalVideosUploadedCount() SaveDriverURL() Return ; ;------------------/Locals------------------------------