fixed locals uploading

main 3.32
Yuriy 8 months ago
parent 2cd1b0de84
commit 7acefafdc7

@ -438,7 +438,7 @@ TelegramCheckStatus := 0
;---Testing Mode Overrides---
;------------------------------------------------
IniRead, TestingMode, %SettingsIniFilepath%, General, TestingMode, 0
if(TestingMode){ ; save currently seelcted sites to ini file for next test
if(TestingMode OR DevMode){ ; save currently seelcted sites to ini file for next test
; IniRead, Streamanity, %SettingsIniFilepath%, Testing, Streamanity, %A_Space%
; (Streamanity)?(StreamanityCheckStatus := 1) : (StreamanityCheckStatus := 0)
IniRead, BitChute, %SettingsIniFilepath%, Testing, BitChute, %A_Space%

@ -13,14 +13,10 @@ if(LocalsPostPageURL = ""){
Return
}
if(!InStr(LocalsPostPageURL, "/share/post")){
LocalsPostPageURL .= "/share/post"
if(InStr(LocalsPostPageURL, "/share/post")){
LocalsPostPageURL := StrReplace(LocalsPostPageURL, "/share/post", "")
}
; replace any double slashes that migth have come from the combining
; LocalsPostPageURL := StrReplace(LocalsPostPageURL, "//", "/")
Status := NavigateFromBaseURLTo(LocalsPostPageURL)
if(Status)
Return
@ -44,69 +40,42 @@ if(Status){
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
*/
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.
TooltipThis("Inputting Title")
Loop, 5 { ; Attempt to input video description a couple of times
; try Description := driver.findElementsByName("body").item[1].Attribute("value") ;XPath: ID=site-title & span tag
if(VideoTitle != "")
Break
sleep, 2000
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)
if(Status){
Message = Failed to input Body
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
}
*/
; Input Description
; Input Video Description
; ------------------------------------------------
TooltipThis("Inputting Description")
Loop, 5 { ; Attempt to input video description a couple of times
Loop, 5 {
if(A_index = 5){
@ -119,10 +88,7 @@ Loop, 5 { ; Attempt to input video description a couple of times
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.
@ -149,9 +115,6 @@ if(Status){
; 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
@ -174,8 +137,6 @@ if(AutoSubmitstatus = "0"){
}
; DevModeMsgBox("autosubmit status -1 string here")
; msgbox % AutoSubmitstatus = "-1"
if(AutoSubmitstatus = "-1"){ ; if checked YES
; check that there are no error messages
@ -215,16 +176,6 @@ if(AutoSubmitstatus = "-1"){ ; if checked YES
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()
; Set variable so that URL gets grabbed later in the upload
LocalsGrabURL := 1
@ -249,7 +200,7 @@ Return
LocalsGrabURL:
CurrentSite := "Locals"
; msgbox, pause
SaveOrPostProgress(Message:="Navigating to Locals Feed to grab URL",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
@ -271,7 +222,6 @@ if(Status = "Failed"){
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
; Msgbox % "Status: " Status
try currentpageURL := driver.url
@ -340,25 +290,32 @@ Loop % VideoTitleArray.Length(){
; 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 % "LongestWordInVideoTitle: " LongestWordInVideoTitle
; MsgBox, Longest word: %longestWord%`, #%wordLength%
; Grab Video Share Link From Page Source
; ------------------------------------------------
; Iterate over the last couple of posts, find the post with the title that contains the Longest word from the uploaded video
; And grab the share URL for it
Message = Looking for - %LongestWordInVideoTitle% - within first 7 posts in order to grab share URL
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
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)
; clipboard := outerHTML
; Msgbox % "outerHTML: " outerHTML
if(DevMode){
Message = Looking for LongestWordInVideoTitle: %LongestWordInVideoTitle% `nwithin outerHTML: %outerHTML%
DevModeMsgBox(message)
@ -366,6 +323,8 @@ loop, 7 {
; DevModeMsgBox(outerHTML)
}
if(InStr(OuterHTML,LongestWordInVideoTitle)){
; @todo replace with regex
@ -406,9 +365,6 @@ if(ShareLink = ""){
Return
}
; DevModeMsgBox(ShareLink)
; ShareLink := "Successful"
Message = Upload Complete: %ShareLink%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
@ -421,253 +377,9 @@ 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(){
LongestWordInVideoTitle := VideoTitleArray[A_Index]
LongestWordInVideoTitle := StrReplace(LongestWordInVideoTitle, "_","-")
if(StrLen(LongestWordInVideoTitle) > 4)
Break
; MsgBox % VideoTitleArray[A_Index]
}
; DevModeMsgBox(LongestWordInVideoTitle)
; Message = LongestWordInVideoTitle: %LongestWordInVideoTitle%
; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile")
; 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, " ", "-")
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,LongestWordInVideoTitle)){
Message = %LongestWordInVideoTitle% 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------------------------------
Loading…
Cancel
Save