fixed brighteon not being able to grab video url at end of upload. Split up shared functions file into multiple pieces

pull/2/head
Yuriy 2 years ago
parent 7a27fa82b7
commit 9570085229

@ -165,6 +165,16 @@ IniRead, AutoLogin, %SettingsIniFilepath%, General, AutoLogin, 1
IniRead, PingOnCompletion, %SettingsIniFilepath%, General, PingOnCompletion, 1 IniRead, PingOnCompletion, %SettingsIniFilepath%, General, PingOnCompletion, 1
(PingOnCompletion)?(PingOnCompletionCheckStatus := 1) : (PingOnCompletionCheckStatus := 0) (PingOnCompletion)?(PingOnCompletionCheckStatus := 1) : (PingOnCompletionCheckStatus := 0)
if(PingOnCompletion){
IniRead, DiscordUsernameID, %SettingsIniFilepath%, General, DiscordUsernameID, %A_space%
if(!DiscordUsernameID){
Message = DiscordUsernameID is blank. Will not be able to ping to notify when uploads are complete.`nPlease add user ID in settings.ini under: `n`n[General]`nDiscordUsernameID=`nOr Uncheck "Discord Ping on Completion"
; SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile")
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar")
}
}
IniRead, KillLBRYAfterUpload, %SettingsIniFilepath%, General, KillLBRYAfterUpload, 1 IniRead, KillLBRYAfterUpload, %SettingsIniFilepath%, General, KillLBRYAfterUpload, 1
(KillLBRYAfterUpload)?(=KillLBRYAfterUploadCheckStatus := 1) : (KillLBRYAfterUploadCheckStatus := 0) (KillLBRYAfterUpload)?(=KillLBRYAfterUploadCheckStatus := 1) : (KillLBRYAfterUploadCheckStatus := 0)
@ -174,11 +184,7 @@ if(DiscordErrorLoggingWebhookBotURL = ""){
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
} }
IniRead, DiscordUsernameID, %SettingsIniFilepath%, General, DiscordUsernameID, %A_space%
if(DiscordUsernameID = ""){
Message = DiscordUsernameID is blank. Will not be able to ping to notify when uploads are complete.`nPlease add user ID in settings.ini under: `n`n[General]`nDiscordUsernameID=
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
}
;---Auto Updater Settings--- ;---Auto Updater Settings---
;------------------------------------------------ ;------------------------------------------------
@ -1570,7 +1576,7 @@ SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordError
AudioLength_Seconds := ((AudioLengthArray[1] * 60 ) * 60) + (AudioLengthArray[2] * 60) + AudioLengthArray[3] AudioLength_Seconds := ((AudioLengthArray[1] * 60 ) * 60) + (AudioLengthArray[2] * 60) + AudioLengthArray[3]
Message = MP3 Audio Length in Seconds: %TotalTimeInSeconds% Message = MP3 Audio Length in Seconds: %TotalTimeInSeconds%
SaveOrPostProgress(Message:="Message",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; AudioLength_Hours := AudioLengthArray[1] ; AudioLength_Hours := AudioLengthArray[1]
; AudioLength_Minutes := AudioLengthArray[2] ; AudioLength_Minutes := AudioLengthArray[2]
@ -3299,506 +3305,528 @@ Loop, %Number_of_loops_to_Check_Upload_status% {
try driver.executeScript("return document.readyState").equals("complete") try driver.executeScript("return document.readyState").equals("complete")
sleep, 2000 sleep, 2000
; } ; }
} }
else, { else, {
SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage() SaveDriverURLOFErrorPage()
Return Return
}
} }
} }
}
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
try driver.executeScript("return document.readyState").equals("complete") Message = Navigating to Upload Page
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
try, TabURL := driver.url ; Navigate to Upload Page
Message = Current Tab URL: %TabURL% try driver.executeScript("window.location = 'https://www.brighteon.com/dashboard/video-upload'") ;navigate using javascript
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; Click out of the "Support free speech" pop-up if it pops up 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()
try, TabURL := driver.url
Message = Current Tab URL: %TabURL%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
CheckForAlerts() ; Click out of the "Support free speech" pop-up if it pops up
Xpath = //body/div[@id='__next']/div[@id='modal-root']/div/div/div[1]//*[local-name()='svg']
try driver.FindElementByXPath(Xpath).click()
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)
if(Status){
Message = Failed to Upload Video, Please check Login Status
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
CheckForAlerts()
loop, 3 { Message = Uploading Video
if(A_index = 3){ SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
Message = Failed to input Video Title ; Upload Video
Xpath = //input[@type='file']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoFilepath)
if(Status){
Message = Failed to Upload Video, Please check Login Status
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return Return
} }
; Input Title of the Video loop, 3 {
Xpath = //input[@id='name'] if(A_index = 3){
try driver.FindElementByXPath(Xpath).SendKeys(VideoTitle) ;Sends Variable to an Xpath Item Message = Failed to input Video Title
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
; click into keyword box to get focus away from title element and see if the video title registers with website ; Input Title of the Video
xpath = //input[@id='keywords'] Xpath = //input[@id='name']
try driver.FindElementByXPath(Xpath).click() try driver.FindElementByXPath(Xpath).SendKeys(VideoTitle) ;Sends Variable to an Xpath Item
sleep, 500
; check if title got input ; click into keyword box to get focus away from title element and see if the video title registers with website
js = return document.querySelector("#name").value; xpath = //input[@id='keywords']
try, status := driver.executeScript(js) try driver.FindElementByXPath(Xpath).click()
if(status = "")
continue
js = return document.querySelector("#name").value; sleep, 500
try, status := driver.executeScript(js)
Message = Title that got input: %status% ; check if title got input
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") js = return document.querySelector("#name").value;
break try, status := driver.executeScript(js)
if(status = "")
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
TooltipThis("Inputting Video Description") }
TooltipThis("Inputting Video Description")
; Attempt to input video description a couple of times
Loop, 10 {
Message = Inputting Description. Attempt Number: %A_index%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; SaveOrPostProgress(Message:=Message,PostType:="DiscordErrorLogging")
; SaveOrPostProgress(Message:="Inputting Video Description",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar")
; TooltipThis("Inputting Description)
Xpath = //div[@class='e-content e-lib e-keyboard'] ; Attempt to input video description a couple of times
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoDescription) Loop, 10 {
if(Status){ if(A_index = 10){
SaveOrPostProgress(Message:="Failed to input Video Description",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") Message = Failed to input Video Description after 10 attempts.
SaveDriverURLOFErrorPage() SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return SaveDriverURLOFErrorPage()
} Return
}
; DevModeMsgBox("pause") Message = Inputting Description. Attempt Number: %A_index%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; SaveOrPostProgress(Message:=Message,PostType:="DiscordErrorLogging")
; driver.FindElementByXPath(Xpath).SendKeys(VideoDescription) ; SaveOrPostProgress(Message:="Inputting Video Description",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar")
; TooltipThis("Inputting Description)
; js = document.getElementById('description').value = "%JSBrighteonVideoDescription%"; Xpath = //div[@class='e-content e-lib e-keyboard']
; try driver.executeScript(js) Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoDescription)
if(Status){
SaveOrPostProgress(Message:="Failed to input Video Description",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; SaveDriverURLOFErrorPage()
; Return
}
; DevModeMsgBox("pause")
; sleep, 1000 ; driver.FindElementByXPath(Xpath).SendKeys(VideoDescription)
; TooltipThis("checking description input")
; try driver.findElementsByID("description").item[1].SendKeys(driver.Keys.ENTER)
; sleep, 1000
sleep, 5000 ; js = document.getElementById('description').value = "%JSBrighteonVideoDescription%";
; try driver.executeScript(js)
js = return document.querySelector("div[class='e-content e-lib e-keyboard'] p").innerText; ; sleep, 1000
try Input_Description := driver.executeScript(JS) ;Execute Javascript ; TooltipThis("checking description input")
; try driver.findElementsByID("description").item[1].SendKeys(driver.Keys.ENTER)
; sleep, 1000
Input_DescriptionStrLen := StrLen(Input_Description) sleep, 5000
Message = Length of Description that got input: %Input_DescriptionStrLen%
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging")
; if text in description box is longer than x chars, then description input worked
if(StrLen(Input_Description) > 15){
Input_Description := SubStr(Input_Description, 1, 20)
Message = Description that got input: %Input_Description% ...
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Break
}
} js = return document.querySelector("div[class='e-content e-lib e-keyboard'] p").innerText;
try Input_Description := driver.executeScript(JS) ;Execute Javascript
Input_DescriptionStrLen := StrLen(Input_Description)
Message = Length of Description that got input: %Input_DescriptionStrLen%
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging")
; if text in description box is longer than x chars, then description input worked
if(StrLen(Input_Description) > 15){
Input_Description := SubStr(Input_Description, 1, 20)
Message = Description that got input: %Input_Description% ...
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Break
}
; Thumbnail
if(VideoThumbFilepath != "") {
TooltipThis("Uploading Thumbnail")
Xpath = //input[@type='file']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoThumbFilepath)
if(Status){
Message = Failed to Upload Thumbnail
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
} }
}
; DevModeMsgBox(VideoTags)
TooltipThis("Inputting Keywords") ; Thumbnail
Loop, 5 { if(VideoThumbFilepath != "") {
XPath = //input[@id='keywords'] TooltipThis("Uploading Thumbnail")
try driver.FindElementByXPath(Xpath).SendKeys(VideoTags) ;Sends Variable to an Xpath Item Xpath = //input[@type='file']
catch e { Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoThumbFilepath)
Message = Error (E#2312)`nVideo Uploaded but Unable to Input Video Tags if(Status){
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") Message = Failed to Upload Thumbnail
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
}
} }
; click into video title to get focus away from inputbox
Xpath = /html/body/div/section[2]/div[2]/div/form/div[1]/div[1]/div[2]/div[1]/div/input
try, driver.FindElementByXPath(Xpath).click() ;Sends Variable to an Xpath Item
; check that the tags got input ; DevModeMsgBox(VideoTags)
js = return document.querySelector("#keywords").value; TooltipThis("Inputting Keywords")
try, status := driver.executeScript(js) Loop, 5 {
if(!status){ XPath = //input[@id='keywords']
Message = Failed to input tags. try driver.FindElementByXPath(Xpath).SendKeys(VideoTags) ;Sends Variable to an Xpath Item
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") catch e {
Message = Error (E#2312)`nVideo Uploaded but Unable to Input Video Tags
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
}
; click into video title to get focus away from inputbox
Xpath = /html/body/div/section[2]/div[2]/div/form/div[1]/div[1]/div[2]/div[1]/div/input
try, driver.FindElementByXPath(Xpath).click() ;Sends Variable to an Xpath Item
; check that the tags got input
js = return document.querySelector("#keywords").value;
try, status := driver.executeScript(js)
if(!status){
Message = Failed to input tags.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
}
else, {
Message = Tags that got input: %status%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
break
}
; Msgbox % "status: " status
}
; 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
; if text in description box is longer than x chars, then description input worked
if(StrLen(Input_Description) > 5){
SaveOrPostProgress(Message:="Video Description second double check was successful",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
} }
else, { else, {
Message = Tags that got input: %status% SaveOrPostProgress(Message:="Secondary video description check failed",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") Return
break
} }
; Msgbox % "status: " status
}
; double check on video description after inputting tags TooltipThis("Waiting for Video to Finish Uploading")
js = return document.querySelector("div[class='e-content e-lib e-keyboard'] p").innerText; Loop, %Number_of_loops_to_Check_Upload_status% {
try Input_Description := driver.executeScript(JS) ;Execute Javascript sleep, %Time_Between_Loops_Upload_Status%
; if text in description box is longer than x chars, then description input worked ; Get progress status through javascript
if(StrLen(Input_Description) > 5){ jsCheck = return document.getElementsByClassName('video-upload--details')[0].textContent;
SaveOrPostProgress(Message:="Video Description second double check was successful",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") try ProgressStatus := driver.executeScript(jsCheck)
}
else, {
SaveOrPostProgress(Message:="Secondary video description check failed",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
if(ProgressStatus = ""){
Message = Failed to Grab Video Upload Status. Upload Most Likely Failed
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
if(InStr(ProgressStatus, "Upload complete.")){
Break
}
TooltipThis("Waiting for Video to Finish Uploading") ; Pull out progress Percentage from full string
Loop, %Number_of_loops_to_Check_Upload_status% { UploadPercent := StrSplit(ProgressStatus, "(")
sleep, %Time_Between_Loops_Upload_Status% UploadPercent := UploadPercent[2]
UploadPercent := StrSplit(UploadPercent, ")")
UploadPercent := UploadPercent[1]
; Get progress status through javascript ; Message = Waiting for Video to Finish Uploading`nCurrent Upload Status: %UploadPercent%
jsCheck = return document.getElementsByClassName('video-upload--details')[0].textContent; ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip")
try ProgressStatus := driver.executeScript(jsCheck)
if(ProgressStatus = ""){ Status := Check_For_Stuck_Video_Upload(A_index, UploadPercent)
Message = Failed to Grab Video Upload Status. Upload Most Likely Failed if(Status = "Failed")
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return Return
} }
if(InStr(ProgressStatus, "Upload complete.")){
Break
}
; Pull out progress Percentage from full string ; "Save Now" button
UploadPercent := StrSplit(ProgressStatus, "(") js = return document.querySelector("button[class='mr-2 btn btn-primary btn-sm']").textContent;
UploadPercent := UploadPercent[2] try, status := driver.executeScript(js)
UploadPercent := StrSplit(UploadPercent, ")") if(!InStr(status, "Save Video")){
UploadPercent := UploadPercent[1] Message = Save Video Button is not clickable. Please check page for errors.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
; Message = Waiting for Video to Finish Uploading`nCurrent Upload Status: %UploadPercent%
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip")
Status := Check_For_Stuck_Video_Upload(A_index, UploadPercent) ; Save Video button
if(Status = "Failed") TooltipThis("Clicking Save Video Button to finalize Upload")
Return try BrighteonUploadPageURL := driver.url
} try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
; "Save Now" button
js = return document.querySelector("button[class='mr-2 btn btn-primary btn-sm']").textContent;
try, status := driver.executeScript(js)
if(!InStr(status, "Save Video")){
Message = Save Video Button is not clickable. Please check page for errors.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
; Save Video button
TooltipThis("Clicking Save Video Button to finalize Upload")
try BrighteonUploadPageURL := driver.url
try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
TooltipThis("Waiting for Result page to finish loading")
Loop, 10 { ; 5 loops of 1 minute each
if(A_index = 10){
Message = Upload Failed: Clicking "Save Video" did not Finalize the Upload
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return ; Break out of gosub
}
js = document.getElementsByClassName('mr-2 btn btn-primary btn-sm')[0].click(); ; Save Video Button
try driver.executeScript(js)
driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
sleep, 5000 ; 30 seconds
try CurrentURL := driver.url
if(BrighteonUploadPageURL != CurrentURL)
Break
}
Message = Trying to Grab Newest Video's URL
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
sleep, 2000
TooltipThis("Waiting for Result page to finish loading") ; Navigate to Videos page to make sure it's refreshed with latest video
Loop, 10 { ; 5 loops of 1 minute each try driver.Get("https://www.brighteon.com/dashboard/videos") ;Open selected URL
if(A_index = 10){ try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
Message = Upload Failed: Clicking "Save Video" did not Finalize the Upload sleep, 2000
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return ; Break out of gosub
}
js = document.getElementsByClassName('mr-2 btn btn-primary btn-sm')[0].click(); ; Save Video Button
try driver.executeScript(js)
driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
sleep, 5000 ; 30 seconds
try CurrentURL := driver.url
if(BrighteonUploadPageURL != CurrentURL)
Break
}
; Get First word in video title to use in grabbing video URL
VideoTitleArray := StrSplit(VideoTitle, " ")
; Iterate from 1 to the end of the array:
Loop % VideoTitleArray.Length(){
VideoTitleLongWord := VideoTitleArray[A_Index]
; VideoTitleFirstWord := StrReplace(VideoTitleFirstWord, "_","-")
if(StrLen(VideoTitleLongWord) > 4)
Break
Message = Trying to Grab Uploaded Video URL ; MsgBox % VideoTitleArray[A_Index]
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") }
; Message = Waiting 60 Seconds Before Checking Results Page for URL
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
; Navigate to Videos page and loop through the videos and grab the URL of the latest upload Message = VideoTitleLongWord: %VideoTitleLongWord%
try driver.Get("https://www.brighteon.com/dashboard/videos") ;Open selected URL SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile")
try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
try, CurrentURL := driver.url
Message = Trying to Grab URL of latest upload containing keyword: %VideoTitleLongWord%. Tab's current URL: %CurrentURL%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; DevModeMsgBox(Message)
Loop, 4 {
ElementIndexNumber := A_index
; Get First word in video title to use in grabbing video URL jsCheck = return document.getElementsByClassName('col')[%ElementIndexNumber%].outerHTML;
VideoTitleArray := StrSplit(VideoTitle, " ") try BrighteonURL := driver.executeScript(jsCheck)
; Iterate from 1 to the end of the array:
Loop % VideoTitleArray.Length(){
VideoTitleLongWord := VideoTitleArray[A_Index]
; VideoTitleFirstWord := StrReplace(VideoTitleFirstWord, "_","-")
if(StrLen(VideoTitleLongWord) > 4)
Break
; MsgBox % VideoTitleArray[A_Index] jsCheck = return document.getElementsByClassName('col')[%ElementIndexNumber%].textContent;
} try InnerText := driver.executeScript(jsCheck)
; Message = Loop Number: %ElementIndexNumber% element's Text Content: %innerText%`nBrighteonURL: %BrighteonURL%
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Message = VideoTitleLongWord: %VideoTitleLongWord% ; Message = InnerText: %InnerText%
SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") ; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile")
; DevModeMsgBox(InnerText)
; Message = BrighteonURL: %BrighteonURL%
; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile")
Loop, 4 {
ElementIndexNumber := A_index + 1
jsCheck = return document.getElementsByClassName('col')[%ElementIndexNumber%].outerHTML;
try BrighteonURL := driver.executeScript(jsCheck)
jsCheck = return document.getElementsByClassName('col')[%ElementIndexNumber%].textContent; ; Msgbox % "VideoTitleLongWord: " VideoTitleLongWord "`nInnerText: " InnerText
try InnerText := driver.executeScript(jsCheck) ; clipboard := Message
; msgbox % Message
; Msgbox % "InnerText: " InnerText . "`n" . "BrighteonURL: " . BrighteonURL
Message = InnerText: %InnerText% if(InStr(InnerText, VideoTitleLongWord)){
SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") Message = Title Keyword was found on %A_index% loop, within element: %innerText%`nTrying to pull out BrighteonURL from element's outerHTML
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Message = BrighteonURL: %BrighteonURL% BrighteonURL := StrSplit(BrighteonURL, "/dashboard/videos/")
SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") BrighteonURL := BrighteonURL[2]
BrighteonURL := StrSplit(BrighteonURL, "><div")
BrighteonURL := BrighteonURL[1]
BrighteonURL := StrReplace(BrighteonURL, """", "")
BrighteonURL := "https://www.brighteon.com/" . BrighteonURL
Break
}
else, {
message = Keyword was not within: %VideoTitle%. Trying again with next element.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; Msgbox % "VideoTitleLongWord: " VideoTitleLongWord "`nInnerText: " InnerText BrighteonURL :=
; clipboard := Message
; msgbox % Message
; Msgbox % "InnerText: " InnerText . "`n" . "BrighteonURL: " . BrighteonURL
if(InStr(InnerText, VideoTitleLongWord)){ }
BrighteonURL := StrSplit(BrighteonURL, "/dashboard/videos/")
BrighteonURL := BrighteonURL[2]
BrighteonURL := StrSplit(BrighteonURL, "><div")
BrighteonURL := BrighteonURL[1]
BrighteonURL := StrReplace(BrighteonURL, """", "")
BrighteonURL := "https://www.brighteon.com/" . BrighteonURL
; Msgbox % "BrighteonURL: " BrighteonURL
Break
} }
BrighteonURL :=
}
; Convert dashboard URL to Public URL
; BrighteonURL := StrReplace(BrighteonURL, "dashboard/videos/", "")
; Convert dashboard URL to Public URL if(BrighteonURL = ""){
; BrighteonURL := StrReplace(BrighteonURL, "dashboard/videos/", "") Message = Upload Completed Successfully but failed to grab Share URL. Please Copy and Paste it in.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
if(BrighteonURL = ""){ Message = Upload Complete:`n%BrighteonURL%
Message = Upload Completed Successfully but failed to grab Share URL. Please Copy and Paste it in. SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") IniWrite, %BrighteonURL%, %VideoLinksIniFile%, URLs, BrighteonURL
SaveDriverURLOFErrorPage() SaveDriverURL()
Return AddToTotalVideosUploadedCount()
} ; TakeScreenshotOfPage(ScreenShotSavePath)
Message = Upload Complete:`n%BrighteonURL% Return
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") ; -------------------------------/Brighteon Upload-------------------------------
IniWrite, %BrighteonURL%, %VideoLinksIniFile%, URLs, BrighteonURL
SaveDriverURL()
AddToTotalVideosUploadedCount()
; TakeScreenshotOfPage(ScreenShotSavePath)
Return
; -------------------------------/Brighteon Upload-------------------------------
; -------------------------------DailyMotion-------------------------------
DailyMotionUpload:
; -------------------------------DailyMotion------------------------------- CurrentSite := "DailyMotion"
DailyMotionUpload: SaveOrPostProgress(Message:="Starting Upload",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
CurrentSite := "DailyMotion" IniRead, DailyMotionParnerUploadPage, %SettingsIniFilepath%, General, DailyMotionPostPageURL, %A_Space%
SaveOrPostProgress(Message:="Starting Upload",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") if(DailyMotionParnerUploadPage = ""){
Message = Please add your DailyMotion Upload URL to settings.ini file under:`n`n[General]`nDailyMotionParnerUploadPage=https://www.dailymotion.com/partner/[YOURIDNUMBER]/media/video/upload
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
IniRead, DailyMotionParnerUploadPage, %SettingsIniFilepath%, General, DailyMotionPostPageURL, %A_Space% Status := NavigateFromBaseURLTo(DailyMotionParnerUploadPage,"Partner HQ - Dailymotion")
if(DailyMotionParnerUploadPage = ""){ if(Status)
Message = Please add your DailyMotion Upload URL to settings.ini file under:`n`n[General]`nDailyMotionParnerUploadPage=https://www.dailymotion.com/partner/[YOURIDNUMBER]/media/video/upload
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return Return
}
Status := NavigateFromBaseURLTo(DailyMotionParnerUploadPage,"Partner HQ - Dailymotion") Message = Waiting for Page to Finish Fully Loading
if(Status) SaveOrPostProgress(Message:=Message,PostType:="Tooltip")
Return try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
sleep, 1500
Message = Waiting for Page to Finish Fully Loading Message = Checking Log In Status
SaveOrPostProgress(Message:=Message,PostType:="Tooltip") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
sleep, 1500
Message = Checking Log In Status LoggedOutStatus := CheckURLForSubstring("/sign-in")
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") if(LoggedOutStatus){
LoggedOutStatus := CheckURLForSubstring("/sign-in") if(AutoLogin){
if(LoggedOutStatus){ Message = Trying to Log Back in Automatically
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
if(AutoLogin){ ; have to click into username and password field for page to register that there's input
Message = Trying to Log Back in Automatically ; clicking with JS doesn't make it register, but with xpath selenium it does
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") Xpath = //input[@placeholder='Email address']
try driver.FindElementByXPath(Xpath).click()
; have to click into username and password field for page to register that there's input Xpath = //input[@placeholder='Enter password']
; clicking with JS doesn't make it register, but with xpath selenium it does driver.FindElementByXPath(Xpath).click()
Xpath = //input[@placeholder='Email address']
try driver.FindElementByXPath(Xpath).click()
Xpath = //input[@placeholder='Enter password'] js = document.querySelector("button[type='submit']").click();
driver.FindElementByXPath(Xpath).click() driver.executeScript(js)
js = document.querySelector("button[type='submit']").click(); driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
driver.executeScript(js) sleep, 1000
driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding ; Do a double check to make sure that login worked
sleep, 1000 Message = Checking Login Status
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; Do a double check to make sure that login worked LoggedOutStatus := CheckURLForSubstring("/sign-in")
Message = Checking Login Status if(LoggedOutStatus){
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") Message = Failed to log back in. Please Log Back In Manually
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
LoggedOutStatus := CheckURLForSubstring("/sign-in") }
if(LoggedOutStatus){ else, { ; notify user and return
Message = Failed to log back in. Please Log Back In Manually Message = Login Expired. Please Log Back in
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage() SaveDriverURLOFErrorPage()
Return Return
} }
} Message = Waiting 5 seconds for page to fully load
else, { ; notify user and return SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
Message = Login Expired. Please Log Back in sleep, 5000
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
}
status := CheckForAlerts()
status := CheckForAlerts() if(Status){
if(Status){ Message = Waiting for page to fully load
Message = Waiting for page to fully load try, driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
try, driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding sleep, 2000
sleep, 2000 }
}
Message = Uploading Video Message = Uploading Video
SaveOrPostProgress(Message:=Message,PostType:="Tooltip") SaveOrPostProgress(Message:=Message,PostType:="Tooltip")
Xpath = //input[@type='file'] Xpath = //input[@type='file']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=2000,StringTextContent:=VideoFilepath) Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=2000,StringTextContent:=VideoFilepath)
if(Status){ if(Status){
Message = Failed to Upload Video. Please Check Login Status Message = Failed to Upload Video. Please Check Login Status
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage() SaveDriverURLOFErrorPage()
Return Return
} }
sleep, 2000 sleep, 2000
Message = Uploading Thumbnail Message = Uploading Thumbnail
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Xpath = //input[@type='file'] Xpath = //input[@type='file']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoThumbFilepath) Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoThumbFilepath)
if(Status){ if(Status){
Message = Failed to Upload Thumbnail: Check Login Status Message = Failed to Upload Thumbnail: Check Login Status
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
} }
Message = Inputting Title Message = Inputting Title
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
loop, 5 { ; sometimes the pre-inserted title doesn't get cleaned out when inputting title loop, 5 { ; sometimes the pre-inserted title doesn't get cleaned out when inputting title
if(A_index = 5){ if(A_index = 5){
Message = Failed to input title after 5 attempts. Message = Failed to input title after 5 attempts.
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
; Return ; Return
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage() SaveDriverURLOFErrorPage()
Return Return
} }
Xpath = (//input[@placeholder='Enter text'])[1] Xpath = (//input[@placeholder='Enter text'])[1]
try, driver.FindElementByXPath(Xpath).click() try, driver.FindElementByXPath(Xpath).click()
js = document.querySelector("input[placeholder='Enter text']").value = "%JSVideoTitle%"; js = document.querySelector("input[placeholder='Enter text']").value = "%JSVideoTitle%";
try driver.executeScript(js) try driver.executeScript(js)
Xpath = (//input[@placeholder='Enter text'])[1] Xpath = (//input[@placeholder='Enter text'])[1]
try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.SPACE) try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.SPACE)
try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.BackSpace) try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.BackSpace)
; get text in title box and see if it matches video title ; get text in title box and see if it matches video title
js = return document.querySelector("input[placeholder='Enter text']").value; js = return document.querySelector("input[placeholder='Enter text']").value;
try CurrentTitle := driver.executeScript(js) try CurrentTitle := driver.executeScript(js)
; Msgbox % "CurrentTitle: " CurrentTitle ; Msgbox % "CurrentTitle: " CurrentTitle
if(CurrentTitle != VideoTitle){ if(CurrentTitle != VideoTitle){
Message = Failed to input title on attempt %A_index% Message = Failed to input title on attempt %A_index%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
sleep, 1000 sleep, 1000
} }
else, else,
Break Break
} }
@ -4474,18 +4502,17 @@ Return
try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
Message = Checking Login Status
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
CheckForAlerts() CheckForAlerts()
Message = Checking Login Status
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
try CurrentURL := driver.URL try CurrentURL := driver.URL
if(InStr(CurrentURL, "/login.php")){ if(InStr(CurrentURL, "/login.php")){
; AutoLogin := 1
; Msgbox % "AutoLogin: " AutoLogin
if(AutoLogin){ if(AutoLogin){
Message = Logging in Automatically by clicking into the UN+PW fields for info to register Message = Logging in Automatically by clicking into the UN+PW fields for info to register
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
@ -4530,7 +4557,7 @@ if(InStr(CurrentURL, "/login.php")){
sleep, 5000 sleep, 5000
} }
CheckForAlerts() ; CheckForAlerts()
Message = Uploading Video File Message = Uploading Video File
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
@ -4885,8 +4912,11 @@ Return
; -------------------------------Functions------------------------------- ; -------------------------------Functions-------------------------------
; Included Files ; Included Files
#include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\StdOutToVar.ahk ; used for chrome debugging mode connection #include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\StdOutToVar.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Freedomain-Posters-Shared-Functions.ahk #Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\General-Shared-Functions.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Selenium-Shared-Functions.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Gitea-Shared-Functions.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\APIs-Shared-Functions.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\JSON.ahk #Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\JSON.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\RunCMD.ahk #Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\RunCMD.ahk

@ -1 +1 @@
Subproject commit f39051ff5fd27550ef00d62d1bfaffcf2cf4a51b Subproject commit c5be14ba23e58f79bc7d8886c3528394b285decc
Loading…
Cancel
Save