2024-04-25 19:57:59 -04:00
LocalsSchedule:
;------------------------------------------------
2024-04-30 23:47:34 -04:00
2024-04-25 19:57:59 -04:00
CurrentSite := "Locals"
2024-04-30 23:47:34 -04:00
SaveOrPostProgress ( Message := "Scheduling Post" , PostType := "Tooltip,ErrorLoggingTextFile,DiscordErrorLogging" )
2024-04-25 19:57:59 -04:00
IniRead , LocalsPostPageURL , %SettingsIniFilepath% , General , LocalsPostPageURL , %A_Space%
if ( LocalsPostPageURL = "" ){
Message = LocalsPostPageURL is blank in Settings . ini . Please add the Locals server URL Under [ General ] `n LocalsPostPageURL =
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 ']
Status := Selenium_LoopToSendValueToXpath ( Xpath := Xpath , NumOfLoops := 2 , SleepLength := 1000 , StringTextContent := LivestreamTitle )
2024-05-08 13:58:37 -04:00
if ( Status ){
Message = Failed to input Livestream Title
SaveOrPostProgress ( Message := Message , PostType := "Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging" )
Return
}
2024-04-25 19:57:59 -04:00
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
2024-05-08 13:58:37 -04:00
try , 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
2024-04-25 19:57:59 -04:00
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
2024-05-08 13:58:37 -04:00
try , 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
2024-04-25 19:57:59 -04:00
if ( NotifyUsersCheckbox = 0 ){
Xpath = // label [ @for = 'is_do_promo ']
Status := Selenium_LoopToClickXpath ( Xpath := Xpath , NumOfLoops := 2 , SleepLength := 1000 )
2024-05-08 13:58:37 -04:00
try , NotifyUsersCheckbox := driver . findElementByID ( "is_do_promo" ) . isSelected ()
2024-04-25 19:57:59 -04:00
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 )
2024-05-08 21:35:32 -04:00
; Upload Custom Thumbnail
; ------------------------------------------------
if ( Livestreamthumbnail ){
Message = Uploading Thumbnail
SaveOrPostProgress ( Message := Message , PostType := "Tooltip,ErrorLoggingTextFile,DiscordErrorLogging" )
; this `label` element is a child of the thumbnail input element.
xpath = ( // label [ @id = 'photo - upload - btn '])[ 2 ]
; the element ID for input elements seems to change/be generated each time the page is generated
XpathIDForUploads := GetHTMLValueFromXpathOuterHTML ( XPATH , "label for" )
if ( XpathIDForUploads = "Failed" ){
Message = Failed to grab element needed for uploading thumbnail . Please attach thumbnail manually .
SaveOrPostProgress ( Message := Message , PostType := "Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging" )
Return
}
ThubmnailInputXpath = ( // input [ @id = '%XpathIDForUploads% '])[ 1 ]
Status := Selenium_LoopToSendValueToXpath ( Xpath := ThubmnailInputXpath , NumOfLoops := 2 , SleepLength := 1000 , StringTextContent := Livestreamthumbnail )
if ( Status ){
Message = Failed to upload livestream thumbnail
SaveOrPostProgress ( Message := Message , PostType := "Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging" )
Return
}
Sleep , 2000
}
2024-05-03 12:54:50 -04:00
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`n Click 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
}
}
/*
*/
2024-04-30 23:47:34 -04:00
2024-04-25 19:57:59 -04:00
; 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" )
}
2024-05-16 14:40:53 -04:00
LocalsLivestreamURL := GrabLocalsPostURLUsingTitle ( LivestreamTitle )
2024-04-25 19:57:59 -04:00
2024-05-16 14:40:53 -04:00
if ( ! InStr ( LocalsLivestreamURL , "https" )){
2024-04-25 19:57:59 -04:00
; If url was not grabbed. wait 1 minute, reload page and then try grabbing URL again
; @todo
}
2024-05-08 21:35:32 -04:00
; Navigate to the Post and Grab the URL
; ------------------------------------------------
2024-04-25 19:57:59 -04:00
Message = Navigating to Livestream Page to grab RTMP Settings
SaveOrPostProgress ( Message := Message , PostType := "Tooltip,ErrorLoggingTextFile,DiscordErrorLogging" )
2024-05-16 14:40:53 -04:00
try , driver . Get ( LocalsLivestreamURL ) ;Open selected URL
2024-04-25 19:57:59 -04:00
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" )
2024-04-30 23:47:34 -04:00
Return
2024-04-25 19:57:59 -04:00
}
2024-04-30 23:47:34 -04:00
Message = Waiting 5 seconds for Page to catch up
SaveOrPostProgress ( Message := Message , PostType := "Tooltip,ErrorLoggingTextFile,DiscordErrorLogging" )
sleep , 5000
2024-04-25 19:57:59 -04:00
; Open Stream Settings Popup Window
Xpath = // button [ normalize - space () = 'Stream Settings ']
2024-04-30 23:47:34 -04:00
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
2024-04-25 19:57:59 -04:00
; 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
2024-04-30 23:47:34 -04:00
LocalsRTMPKey := GetHTMLValueFromXpathOuterHTML ( XPATH , "value" )
2024-04-25 19:57:59 -04:00
2024-05-03 12:54:50 -04:00
2024-04-30 23:47:34 -04:00
IniWrite , %LocalsRTMPURL% , %PostStatusesFilepath% , Livestream , LocalsRTMPURL
IniWrite , %LocalsRTMPKey% , %PostStatusesFilepath% , Livestream , LocalsRTMPKey
2024-05-16 14:40:53 -04:00
IniWrite , %LocalsLivestreamURL% , %PostStatusesFilepath% , Livestream , LocalsLivestreamURL
2024-04-25 19:57:59 -04:00
2024-05-03 12:54:50 -04:00
ToolTip
2024-04-25 19:57:59 -04:00
Return