fixed locals posting, errors if gitea is not reachable, results gui appearing at wrong position on screen
This commit is contained in:
@@ -57,7 +57,7 @@ if(DevMode){
|
||||
Return
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Message = Inputting Title
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
||||
|
||||
@@ -69,6 +69,45 @@ if(DevMode){
|
||||
}
|
||||
|
||||
sleep, 1000
|
||||
*/
|
||||
|
||||
|
||||
|
||||
TooltipThis("Inputting Title")
|
||||
Loop, 5 { ; Attempt to input video description a couple of times
|
||||
|
||||
|
||||
if(A_index = 5){
|
||||
; Clipboard := VideoDescription
|
||||
Message = Failed to input Video Title
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
Return
|
||||
}
|
||||
|
||||
js = document.querySelector("#title").value = "%JSVideoTitle%"; ; 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.querySelector("#title").value; ; Send content through javascript (Great for getting around emoji chrome limitaitons)
|
||||
try VideoTitle := 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(VideoTitle != "")
|
||||
Break
|
||||
sleep, 2000
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*Xpath = //textarea[@id='body']
|
||||
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=VideoDescription)
|
||||
@@ -108,7 +147,7 @@ Loop, 5 { ; Attempt to input video description a couple of times
|
||||
sleep, 2000
|
||||
}
|
||||
|
||||
SaveOrPostProgress(Message:="Waiting Video to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile")
|
||||
; 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']
|
||||
@@ -148,7 +187,7 @@ if(AutoSubmitstatus = "0"){
|
||||
}
|
||||
|
||||
|
||||
DevModeMsgBox("autosubmit status -1 string here")
|
||||
; DevModeMsgBox("autosubmit status -1 string here")
|
||||
; msgbox % AutoSubmitstatus = "-1"
|
||||
if(AutoSubmitstatus = "-1"){ ; if checked YES
|
||||
|
||||
@@ -254,28 +293,67 @@ Return
|
||||
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
|
||||
Message = Video is in Draft Mode. Publishing.
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,DiscordErrorLogging")
|
||||
|
||||
; video is in draft mode, we need to confirm the title and then publish it.
|
||||
|
||||
; click Retrieve draft button
|
||||
js = document.querySelector("a[class='btn']").click()
|
||||
try, driver.executeScript(js)
|
||||
|
||||
js = return document.querySelector("#title").value
|
||||
try LocalsDraftTitle := driver.executeScript(JS)
|
||||
|
||||
if(LocalsDraftTitle != VideoTitle){
|
||||
Message = Failed to Grab URL. Locals Draft Title does not Match video Title:`nVideo Title: %VideoTitle%`nLocals Draft Title: %LocalsDraftTitle%
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
SaveDriverURLOFErrorPage()
|
||||
Return
|
||||
}
|
||||
|
||||
; otherwise we are good to publish video
|
||||
Xpath = (//button[@name='submitPost'])[1]
|
||||
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
|
||||
if(Status){
|
||||
Message = Failed to click Publish button on saved Draft
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
SaveDriverURLOFErrorPage()
|
||||
Return
|
||||
}
|
||||
|
||||
sleep, 2000
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
; 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)
|
||||
LongestWordInVideoTitle := VideoTitleArray[A_Index]
|
||||
LongestWordInVideoTitle := StrReplace(LongestWordInVideoTitle, "_","-")
|
||||
if(StrLen(LongestWordInVideoTitle) > 4)
|
||||
Break
|
||||
|
||||
; MsgBox % VideoTitleArray[A_Index]
|
||||
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
; get longest word in video title to use for grabbing the share link from the raw page
|
||||
RegExMatch(VideoTitle, "ms)\b\S+(?CFindLongestWordInString)\b(?R)", m)
|
||||
LongestWordInVideoTitle := longestWord
|
||||
; Msgbox % "LongestWordInVideoTitle: " LongestWordInVideoTitle
|
||||
|
||||
; MsgBox, Longest word: %longestWord%`, #%wordLength%
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
loop, 7 {
|
||||
ElementIndexNum := A_index - 1
|
||||
Message = ElementIndexNum: %ElementIndexNum%
|
||||
@@ -287,18 +365,16 @@ loop, 7 {
|
||||
try outerHTML := driver.executeScript(jsCheck)
|
||||
|
||||
if(DevMode){
|
||||
Message = Looking for VideoTitleFirstWord: %VideoTitleFirstWord% `nwithin outerHTML
|
||||
Message = Looking for LongestWordInVideoTitle: %LongestWordInVideoTitle% `nwithin outerHTML: %outerHTML%
|
||||
DevModeMsgBox(message)
|
||||
Clipboard := outerHTML
|
||||
DevModeMsgBox(outerHTML)
|
||||
Clipboard := message
|
||||
; DevModeMsgBox(outerHTML)
|
||||
}
|
||||
|
||||
if(InStr(OuterHTML,LongestWordInVideoTitle)){
|
||||
|
||||
; msgbox % "outerHTML: " . outerHTML
|
||||
|
||||
if(InStr(OuterHTML,VideoTitleFirstWord)){
|
||||
; @todo replace with regex
|
||||
Message = %VideoTitleFirstWord% is in`n`n %OuterHTML%
|
||||
Message = %LongestWordInVideoTitle% is in`n`n %OuterHTML%
|
||||
DevModeMsgBox(Message)
|
||||
|
||||
Message = Found at at index: %A_index%
|
||||
@@ -328,19 +404,29 @@ loop, 7 {
|
||||
ShareLink :=
|
||||
}
|
||||
|
||||
DevModeMsgBox(ShareLink)
|
||||
if(ShareLink = ""){
|
||||
Message = Video was published succsessfully, but failed to grab Share Link.
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
SaveDriverURLOFErrorPage()
|
||||
Return
|
||||
}
|
||||
|
||||
; DevModeMsgBox(ShareLink)
|
||||
|
||||
; ShareLink := "Successful"
|
||||
|
||||
Message = Upload Complete: %ShareLink%
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||
|
||||
|
||||
DevModeMsgBox(ShareLink)
|
||||
IniWrite, %ShareLink%, %VideoLinksIniFile%, URLs, LocalsURL
|
||||
AddToTotalVideosUploadedCount()
|
||||
|
||||
SaveDriverURL()
|
||||
|
||||
; Set variable so that URL gets grabbed later in the upload
|
||||
LocalsGrabURL := 1
|
||||
|
||||
|
||||
Return
|
||||
|
||||
@@ -500,22 +586,22 @@ Loop, %Number_of_loops_to_Check_Upload_status% {
|
||||
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)
|
||||
LongestWordInVideoTitle := VideoTitleArray[A_Index]
|
||||
LongestWordInVideoTitle := StrReplace(LongestWordInVideoTitle, "_","-")
|
||||
if(StrLen(LongestWordInVideoTitle) > 4)
|
||||
Break
|
||||
|
||||
; MsgBox % VideoTitleArray[A_Index]
|
||||
|
||||
}
|
||||
|
||||
; DevModeMsgBox(VideoTitleFirstWord)
|
||||
; DevModeMsgBox(LongestWordInVideoTitle)
|
||||
|
||||
; Message = VideoTitleFirstWord: %VideoTitleFirstWord%
|
||||
; Message = LongestWordInVideoTitle: %LongestWordInVideoTitle%
|
||||
; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile")
|
||||
|
||||
; VideoTitleFirstWord := VideoTitleFirstWord[1]
|
||||
; Msgbox % "VideoTitleFirstWord: " VideoTitleFirstWord
|
||||
; LongestWordInVideoTitle := LongestWordInVideoTitle[1]
|
||||
; Msgbox % "LongestWordInVideoTitle: " LongestWordInVideoTitle
|
||||
|
||||
/* ; Format the post title to remove all spaces and special characters to match with Locals Post
|
||||
ShareLinkFormatted := StrReplace(VideoTitle, " ", "-")
|
||||
@@ -547,9 +633,9 @@ Loop, %Number_of_loops_to_Check_Upload_status% {
|
||||
|
||||
; msgbox % "outerHTML: " . outerHTML
|
||||
|
||||
if(InStr(OuterHTML,VideoTitleFirstWord)){
|
||||
if(InStr(OuterHTML,LongestWordInVideoTitle)){
|
||||
|
||||
Message = %VideoTitleFirstWord% is in %OuterHTML%
|
||||
Message = %LongestWordInVideoTitle% is in %OuterHTML%
|
||||
; DevModeMsgBox(Message)
|
||||
|
||||
; MsgBox, found match at %A_index%
|
||||
|
||||
@@ -234,4 +234,20 @@ Check_For_Stuck_Video_Upload(Index_Number, Upload_Status){
|
||||
}
|
||||
ProgressStatusArray.Push(Upload_Status) ; append current status to array
|
||||
}
|
||||
} ; end of func
|
||||
} ; end of func
|
||||
|
||||
|
||||
; Find the longest word in a string of words
|
||||
FindLongestWordInString(m, calloutNumber, pos, haystack, pattern){
|
||||
Global wordLength, longestWord
|
||||
|
||||
len := StrLen(m)
|
||||
|
||||
If ( len > wordLength )
|
||||
{
|
||||
wordLength := len
|
||||
longestWord := m
|
||||
|
||||
; MsgBox, %m%
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user