LocalsSchedule:
;------------------------------------------------
CurrentSite := "Locals"
SaveOrPostProgress(Message:="Scheduling Post",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
IniRead, LocalsPostPageURL, %SettingsIniFilepath%, General, LocalsPostPageURL, %A_Space%
if(LocalsPostPageURL = ""){
Message = LocalsPostPageURL is blank in Settings.ini. Please add the Locals server URL Under [General]`nLocalsPostPageURL=
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
else {
; Reformat URL in case it has any extras we don't need.
LocalsPostPageURLArray := StrSplit(LocalsPostPageURL,".locals.com")
LocalsPostPageURL := LocalsPostPageURLArray[1] . ".locals.com/share?livestream"
}
Status := NavigateFromBaseURLTo(LocalsPostPageURL)
if(Status)
Return
try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
CheckForAlerts()
; Check Login Status on Locals
#Include, %A_ScriptDir%\Modules\Locals-Check-Login-Status.ahk
; Input Title and Description into Create a Livestream - First Screen
; ------------------------------------------------
Xpath = //input[@id='title']
; try, driver.FindElementByXPath(Xpath).SendKeys("TEST STRINGHERE")
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=LivestreamTitle)
Xpath = //textarea[@id='body']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=LivestreamDescription)
; click next button
Xpath = //span[contains(text(),'Next')]
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
; Create a Livestream - Second Screen
; ------------------------------------------------
; check if "Schedule Livestream" checkbox is checked, check it if not
LivestreamScheduledCheckbox := driver.findElementByID("is_scheduled_livestream").isSelected() ;Checks if a checkbox is ticked or not and saves it to a variable, usually: 0 = Unchecked, -1 = Checked
if(LivestreamScheduledCheckbox = 0){
Xpath = //label[normalize-space()='Schedule this live stream?']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
LivestreamScheduledCheckbox := driver.findElementByID("is_scheduled_livestream").isSelected()
if(LivestreamScheduledCheckbox = 0){
Message = Failed to select the "Schedule Livestream" checkbox
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
}
}
; Make sure the "Notify Users" checkbox is checked
NotifyUsersCheckbox := driver.findElementByID("is_do_promo").isSelected() ;Checks if a checkbox is ticked or not and saves it to a variable, usually: 0 = Unchecked, -1 = Checked
if(NotifyUsersCheckbox = 0){
Xpath = //label[@for='is_do_promo']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
NotifyUsersCheckbox := driver.findElementByID("is_do_promo").isSelected()
if(NotifyUsersCheckbox = 0){
Message = Failed to select the "Notify Users" checkbox
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
}
}
FormatTime, LocalsLivestreamDate , %LivestreamDate%, MM/dd/yyyy ; _hhmmss
FormatTime, LocalsLivestreamTime , %LivestreamTime%, hh:mm tt ; _hhmmss
; clear data from date box and input date
Xpath = //input[@id='stream_schedule_date']
try, driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.BackSpace).SendKeys(driver.Keys.BackSpace).SendKeys(driver.Keys.BackSpace).SendKeys(driver.Keys.BackSpace).SendKeys(driver.Keys.BackSpace).SendKeys(driver.Keys.BackSpace).SendKeys(driver.Keys.BackSpace).SendKeys(driver.Keys.BackSpace).SendKeys(driver.Keys.BackSpace).SendKeys(driver.Keys.BackSpace)
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=LocalsLivestreamDate)
; clear data from time box and input time
Xpath = //input[@id='stream_schedule_time']
try, driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.BackSpace).SendKeys(driver.Keys.BackSpace).SendKeys(driver.Keys.BackSpace).SendKeys(driver.Keys.BackSpace).SendKeys(driver.Keys.BackSpace).SendKeys(driver.Keys.BackSpace).SendKeys(driver.Keys.BackSpace).SendKeys(driver.Keys.BackSpace).SendKeys(driver.Keys.BackSpace).SendKeys(driver.Keys.BackSpace)
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=LocalsLivestreamTime)
if(ConfirmBeforeSubmit){
OnMessage(0x44, "OnMsgBoxUserConfirmation")
MsgBox 0x21, User Confirmation, Please check that all data was input correctly and fix any mistakes and then click PROCEED to finalize the Upload.`n`nClick STOP to cancel the rest of this Upload and move on to the next website.
OnMessage(0x44, "")
IfMsgBox OK, {
} Else IfMsgBox Cancel, {
Message = User Selected STOP button when asked for confirmation. Cancelling Rest of Site Upload.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
}
/*
*/
; click schedule button
Xpath = //span[normalize-space()='Schedule']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
if(Status){
Message = Failed to click schedule post button
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
}
LivestreamURL := GrabLocalsPostURLUsingTitle(LivestreamTitle)
if(!InStr(LivestreamURL, "https")){
; If url was not grabbed. wait 1 minute, reload page and then try grabbing URL again
; @todo
}
; Navigate to the post
Message = Navigating to Livestream Page to grab RTMP Settings
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
try, driver.Get(LivestreamURL) ;Open selected URL
driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
; Switch to RSTP mode
Xpath = //a[normalize-space()='switch to RTMP']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
if(Status){
Message = Failed to switch Livestream to RTMP mode
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
Message = Waiting 5 seconds for Page to catch up
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
sleep, 5000
; Open Stream Settings Popup Window
Xpath = //button[normalize-space()='Stream Settings']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000)
if(Status){
Message = Failed grab RTMP Settings. Unable to click the Stream Settings button.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
Message = Waiting 5 seconds for Page to catch up
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
sleep, 5000
; Get RTMP Values from the popup
Xpath = //input[@id='rtmp_url']
try, LocalsRTMPURL := driver.findelementbyxpath(Xpath).Attribute("value")
/*Xpath = //div[@class='modal-wrapper modal-wrapper_stream']//div[5]
try, LocalsRTMPKey := driver.findelementbyxpath(Xpath).Attribute("value")
*/
Xpath = //div[@class='modal-wrapper modal-wrapper_stream']//div[5]
; Pull Out the RTMPKey from the OuterHTML using RegEx
LocalsRTMPKey := GetHTMLValueFromXpathOuterHTML(XPATH, "value")
IniWrite, %LocalsRTMPURL%, %PostStatusesFilepath%, Livestream,LocalsRTMPURL
IniWrite, %LocalsRTMPKey%, %PostStatusesFilepath%, Livestream,LocalsRTMPKey
IniWrite, %LivestreamURL%, %PostStatusesFilepath%, Livestream,LivestreamURL
ToolTip
Return