diff --git a/.gitignore b/.gitignore index 33bcfcf..5b8ac1e 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ body.txt Freedomain Social Media Poster*.exe Compile Scripts to EXE.ahk Freedomain Video Uploader.exe -Lib/LBRY Process Killer.exe \ No newline at end of file +Lib/LBRY Process Killer.exe +Lib/chrome-win64 \ No newline at end of file diff --git a/Freedomain Video Uploader.ahk b/Freedomain Video Uploader.ahk index dfd03ff..646858d 100644 --- a/Freedomain Video Uploader.ahk +++ b/Freedomain Video Uploader.ahk @@ -29,7 +29,7 @@ global ScriptVersion global FullScriptName ScriptName = Freedomain Video Uploader -ScriptVersion = 3.17 +ScriptVersion = 3.18 FullScriptName := ScriptName . " - " . ScriptVersion @@ -136,9 +136,9 @@ IniRead, ShowTooltipProgress, %SettingsIniFilepath%, General, ShowTooltipProgres (ShowTooltipProgress)?(ShowTooltipProgressCheckStatus := 1) : (ShowTooltipProgressCheckStatus := 0) -Message = Reading Settings from .ini files +; Message = Reading Settings from .ini files ; ToolTip, reading settings -SaveOrPostProgress(Message:=Message,PostType:="Tooltip") +; SaveOrPostProgress(Message:=Message,PostType:="Tooltip") @@ -264,7 +264,7 @@ else, { } -; Do this with an array. Add all filepaths to array and then pull out the ones with the extension. +; @todo Do this with an array. Add all filepaths to array and then pull out the ones with the extension. ; get directory from the filepath grabbed SplitPath, BodyTextFilePath, OutFileName, VideoFolderDir, OutExtension, OutNameNoExt, OutDrive @@ -2849,987 +2849,988 @@ Loop, %Number_of_loops_to_Check_Upload_status% { ; ;------------------/Locals------------------------------ +/* +*/ +; +;--------------------Telegram---------------------------- +TelegramVideoUpload: - ; - ;--------------------Telegram---------------------------- - TelegramVideoUpload: - - if(VideoFileSizeInMB > 50){ - Message = Telegram Upload Skipped. Video is larger than 50MB - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } +if(VideoFileSizeInMB > 50){ + Message = Telegram Upload Skipped. Video is larger than 50MB + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} - CurrentSocialMediaPosting := "Telegram Video" - Message = Uploading Video to Telegram - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +CurrentSocialMediaPosting := "Telegram Video" +Message = Uploading Video to Telegram +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - IniRead, TelegramBotToken, %SettingsIniFilepath%, SocialMediaPoster, TelegramBotToken, %A_Space% - IniRead, TelegramBotChatID, %SettingsIniFilepath%, SocialMediaPoster, TelegramBotChatID, %A_Space% +IniRead, TelegramBotToken, %SettingsIniFilepath%, SocialMediaPoster, TelegramBotToken, %A_Space% +IniRead, TelegramBotChatID, %SettingsIniFilepath%, SocialMediaPoster, TelegramBotChatID, %A_Space% - LineBreakChar = `%0A ; Used for Telegram API +LineBreakChar = `%0A ; Used for Telegram API - SaveOrPostProgress(Message:="Posting to Telegram",PostType:="Tooltip,ErrorLoggingTextFile") +SaveOrPostProgress(Message:="Posting to Telegram",PostType:="Tooltip,ErrorLoggingTextFile") - if(TelegramBotToken = "" Or TelegramBotChatID =""){ - Message = TelegramBotToken or TelegramBotChatID is missing from %SettingsIniFilepath%. `nPlease input them and click the button again. - msgbox, 4096, Error!, %Message% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - ; Msgbox, 4096, Error!, TelegramBotToken or TelegramBotChatID is missing from %SettingsIniFilepath%. `nPlease input them and rerun the script. - Return - } +if(TelegramBotToken = "" Or TelegramBotChatID =""){ + Message = TelegramBotToken or TelegramBotChatID is missing from %SettingsIniFilepath%. `nPlease input them and click the button again. + msgbox, 4096, Error!, %Message% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + ; Msgbox, 4096, Error!, TelegramBotToken or TelegramBotChatID is missing from %SettingsIniFilepath%. `nPlease input them and rerun the script. + Return +} - ; If description is longer than 2k chars, then API will error out. goto section that will allow user to edit video description to shorten it for posting - if(StrLen(SocialMediaDescription) > 2000){ - TelegramVideoUploadDescription := SubStr(SocialMediaDescription, 1, 990) - TelegramVideoUploadDescription .= "...." - ; msgbox, here goes - ; Goto, CreateDescriptionForVideosPosting - } +; If description is longer than 2k chars, then API will error out. goto section that will allow user to edit video description to shorten it for posting +if(StrLen(SocialMediaDescription) > 2000){ + TelegramVideoUploadDescription := SubStr(SocialMediaDescription, 1, 990) + TelegramVideoUploadDescription .= "...." + ; msgbox, here goes + ; Goto, CreateDescriptionForVideosPosting +} - SubmitDescriptionForTelegramVideoUpload: - TelegramVideoTitle := ASCIISTRReplace(VideoTitle) +SubmitDescriptionForTelegramVideoUpload: +TelegramVideoTitle := ASCIISTRReplace(VideoTitle) - TelegramBodymessage := ASCIISTRReplace(TelegramVideoUploadDescription) +TelegramBodymessage := ASCIISTRReplace(TelegramVideoUploadDescription) - LineBreakChar = `%0A ; Used for API +LineBreakChar = `%0A ; Used for API - Message := "*" . TelegramVideoTitle . "*" . LineBreakChar . TelegramBodymessage . LineBreakChar +Message := "*" . TelegramVideoTitle . "*" . LineBreakChar . TelegramBodymessage . LineBreakChar - Message := StrReplace(Message, "`n", LineBreakChar) ; replace all new line characters with the global charater +Message := StrReplace(Message, "`n", LineBreakChar) ; replace all new line characters with the global charater - ; Msgbox % "Message: " Message +; Msgbox % "Message: " Message - Status := SendTelegramVideo(TelegramBotToken, TelegramBotChatID, VideoFilepath, caption := Message ) ; you could add more options; compare the Telegram API docs - if(InStr(Status, "error_code")){ - Message = Telegram Post Failed due to an API Issue. Error was saved to ErrorLogging file. Please send it to Yuriy. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") +Status := SendTelegramVideo(TelegramBotToken, TelegramBotChatID, VideoFilepath, caption := Message ) ; you could add more options; compare the Telegram API docs +if(InStr(Status, "error_code")){ + Message = Telegram Post Failed due to an API Issue. Error was saved to ErrorLogging file. Please send it to Yuriy. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - ; SaveOrPostProgress(Message:=Status,PostType:=",ErrorLoggingTextFile") - Message = Telegram Error: %Status% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + ; SaveOrPostProgress(Message:=Status,PostType:=",ErrorLoggingTextFile") + Message = Telegram Error: %Status% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - ToolTip - Return - } - ; msgbox + ToolTip + Return +} +; msgbox - Message = Upload Complete to Telegram - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - IniWrite, Successful, %VideoLinksIniFile%, Misc, Telegram - ; SaveDriverURL() - AddToTotalVideosUploadedCount() +Message = Upload Complete to Telegram +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +IniWrite, Successful, %VideoLinksIniFile%, Misc, Telegram +; SaveDriverURL() +AddToTotalVideosUploadedCount() - Return +Return - ; -------------------------------BitChute------------------------------- - BitChuteUpload: - CurrentSite := "Bitchute" +; -------------------------------BitChute------------------------------- +BitChuteUpload: +CurrentSite := "Bitchute" - Message = Starting Upload - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +Message = Starting Upload +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - Status := NavigateFromBaseURLTo("https://www.bitchute.com/myupload", "BitChute Video Uploader") - if(Status) - Return +Status := NavigateFromBaseURLTo("https://www.bitchute.com/myupload", "BitChute Video Uploader") +if(Status) +Return - Message = Checking Login Status - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +Message = Checking Login Status +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - try TabUrl := driver.url - if(InStr(TabUrl, "/accounts/login/")){ - if(AutoLogin){ - Xpath = (//button[normalize-space()='Submit'])[1] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - if(Status){ - Message = Failed to click Login Button. Please Log Back In - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - } - else, { - Message = Login Expired. Please Log Back In +try TabUrl := driver.url +if(InStr(TabUrl, "/accounts/login/")){ + if(AutoLogin){ + Xpath = (//button[normalize-space()='Submit'])[1] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Failed to click Login Button. Please Log Back In SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveDriverURLOFErrorPage() Return } - + } + else, { + Message = Login Expired. Please Log Back In + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return } +} - CheckForAlerts() - - Message = Inputting Title - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - ; Try to input video title and if fail try to login again - loop, 5 { - if(A_index = 5){ - try CurrentURL := driver.url - ; CurrentURL := ExtractBaseURL(URL) - ; currentTabURL := SubStr(currentTabURL, 1, 40) - Message = Failed to input Video Title after %A_index% attempts.`nCurrent Tab URL: %currentTabURL% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - status := js_SendAndCheckWithQuerySelector(Selector:="#title",ValueToCheck:="value",SleepLength:=1000,JSStringText:=VideoTitle) - ; Msgbox % "status: " status +CheckForAlerts() - if(!Status) - break +Message = Inputting Title +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") +; Try to input video title and if fail try to login again +loop, 5 { + if(A_index = 5){ + try CurrentURL := driver.url + ; CurrentURL := ExtractBaseURL(URL) + ; currentTabURL := SubStr(currentTabURL, 1, 40) + Message = Failed to input Video Title after %A_index% attempts.`nCurrent Tab URL: %currentTabURL% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return } + status := js_SendAndCheckWithQuerySelector(Selector:="#title",ValueToCheck:="value",SleepLength:=1000,JSStringText:=VideoTitle) + ; Msgbox % "status: " status + if(!Status) + break - Message = Inputting Description - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +} - ; trim description if it's too long - BitchuteDescription := VideoDescription - if(StrLen(BitchuteDescription) > 2995){ - BitchuteDescription := SubStr(BitchuteDescription, 1, 2995) - JSBitchuteDescription := FormatTextToJSText(BitchuteDescription) - } - else, - JSBitchuteDescription := FormatTextToJSText(BitchuteDescription) - Loop, 10 { ; Attempt to input video description a couple of times - Message = Inputting Description. Attempt #%A_index% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +Message = Inputting Description +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - if(A_index = 10){ - try currentTabURL := GetCurrentTabURlBase() - ; currentTabURL := SubStr(currentTabURL, 1, 40) - Message = Failed to input Video Description after %A_index% attempts`nCurrent Tab URL: %currentTabURL% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } +; trim description if it's too long +BitchuteDescription := VideoDescription +if(StrLen(BitchuteDescription) > 2995){ + BitchuteDescription := SubStr(BitchuteDescription, 1, 2995) + JSBitchuteDescription := FormatTextToJSText(BitchuteDescription) +} +else, +JSBitchuteDescription := FormatTextToJSText(BitchuteDescription) +Loop, 10 { ; Attempt to input video description a couple of times + Message = Inputting Description. Attempt #%A_index% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - status := js_SendAndCheckWithQuerySelector("#description",ValueToCheck:="value",SleepLength:=1000,JSStringText:=JSBitchuteDescription) - if(status){ - Message = %status% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - } - else, - Break - - sleep, 1000 - } + if(A_index = 10){ + try currentTabURL := GetCurrentTabURlBase() + ; currentTabURL := SubStr(currentTabURL, 1, 40) + Message = Failed to input Video Description after %A_index% attempts`nCurrent Tab URL: %currentTabURL% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } - Message = Inputting Tags - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - ; Convert tags into #hasthtags - Loop, 3 { - Value := KeywordsArray[A_Index] - Value := StrReplace(Value, " ", "") ; Remove spaces if hashtag has two words - ; HashTag := "#" . Value - BitchuteHashtags .= Value . " " + status := js_SendAndCheckWithQuerySelector("#description",ValueToCheck:="value",SleepLength:=1000,JSStringText:=JSBitchuteDescription) + if(status){ + Message = %status% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") } + else, + Break + + sleep, 1000 +} - ; input hashtags - Xpath = //input[@placeholder='Search Terms'] - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=BitchuteHashtags) - ; Upload Thumbnail - Message = Attaching Thumbnail - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +Message = Inputting Tags +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - if(VideoThumbFilepath != ""){ - ; Upload Cover Image Button - Message = Uploading Thumbnail - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") +; Convert tags into #hasthtags +Loop, 3 { + Value := KeywordsArray[A_Index] + Value := StrReplace(Value, " ", "") ; Remove spaces if hashtag has two words + ; HashTag := "#" . Value + BitchuteHashtags .= Value . " " +} +; input hashtags +Xpath = //input[@placeholder='Search Terms'] +Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=BitchuteHashtags) - Xpath = //input[@name='thumbnailInput'] - 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 - } - ; sleep, 5000 - } +; Upload Thumbnail +Message = Attaching Thumbnail +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + +if(VideoThumbFilepath != ""){ + ; Upload Cover Image Button + Message = Uploading Thumbnail + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - ; Upload Video button - Message = Uploading Video File - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - Xpath = //input[@name='videoInput'] - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoFilepath) + Xpath = //input[@name='thumbnailInput'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoThumbFilepath) if(Status){ - Message = Failed to Upload Video + Message = Failed to Attach Thumbnail SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveDriverURLOFErrorPage() Return } + ; sleep, 5000 +} +; Upload Video button +Message = Uploading Video File +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - Message = Waiting for Video to Finish Uploading`nChecking Progress Every 5 seconds - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - Xpath = //div[@role='progressbar'] ; Xpath to progress % - Loop, %Number_of_loops_to_Check_Upload_status% { - sleep, %Time_Between_Loops_Upload_Status% - - if(A_index = 5){ ; while waiting for bitchute video to finish uploading, start up lbry - if(OdyseeVideo OR OdyseeAudio){ - SaveOrPostProgress(Message:="Starting up LBRY while waiting for Bitchute Video to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - CheckLBRYProcess() - } - } - ; Selenium - ; try BitChuteUploadProgress := driver.findelementbyxpath(Xpath).Attribute("innerText") ;GREAT FOR GRABBING INNER CONTENTS/Values - - try BitChuteUploadProgress := driver.executeScript("return document.querySelector('.filepond--file-status').innerHTML;") ;navigate using javascript - ; Msgbox % "BitChuteUploadProgress: " BitChuteUploadProgress +Xpath = //input[@name='videoInput'] +Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoFilepath) +if(Status){ + Message = Failed to Upload Video + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} - if(BitChuteUploadProgress = ""){ - Message = Unable to Grab Upload Progress, Upload Possibly Failed - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - if(InStr(BitChuteUploadProgress, "Upload complete")){ - Message = Waiting 10 Seconds before clicking "Proceed" button - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 10000 - Break ; Break out of the loop when 100% upload status +Message = Waiting for Video to Finish Uploading`nChecking Progress Every 5 seconds +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") +Xpath = //div[@role='progressbar'] ; Xpath to progress % +Loop, %Number_of_loops_to_Check_Upload_status% { + sleep, %Time_Between_Loops_Upload_Status% + if(A_index = 5){ ; while waiting for bitchute video to finish uploading, start up lbry + if(OdyseeVideo OR OdyseeAudio){ + SaveOrPostProgress(Message:="Starting up LBRY while waiting for Bitchute Video to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + CheckLBRYProcess() } - - ; split_text = "> - ; Pull out upload percentage - BitChuteUploadProgress := StrSplit(BitChuteUploadProgress, ">") - BitChuteUploadProgress := BitChuteUploadProgress[2] - BitChuteUploadProgress := StrSplit(BitChuteUploadProgress, "") + BitChuteUploadProgress := BitChuteUploadProgress[2] + BitChuteUploadProgress := StrSplit(BitChuteUploadProgress, "= 5000){ - BrighteonVideoDescription := SubStr(VideoDescription, 1, 4800) - BrighteonVideoDescription .= "...." - JSBrighteonVideoDescription := FormatTextToJSText(BrighteonVideoDescription) - if(StrLen(JSBrighteonVideoDescription) > 5000){ - BrighteonVideoDescription := SubStr(VideoDescription, 1, 4500) - BrighteonVideoDescription .= "...." - JSBrighteonVideoDescription := FormatTextToJSText(BrighteonVideoDescription) - } - } +Return +; -------------------------------/BitChute Upload------------------------------- - Message = Checking Login Status - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - try CurrentTab := driver.url - if(InStr(CurrentTab, "login")) ; we're logged out - { +; -------------------------------Brighteon Upload------------------------------- +BrighteonUpload: - Message = Currently Logged Out`nClosing out of any popups that might appear before clicking Login button - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") +CurrentSite := "Brighteon" +SaveOrPostProgress(Message:="Starting Upload",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +Status := NavigateFromBaseURLTo("https://www.brighteon.com/dashboard/video-upload") +if(Status) +Return - Xpath = //body/div[@id='__next']/div[@id='modal-root']/div[2]/div[1]/div[1]//*[local-name()='svg'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=100) - Xpath = //body/div[@id='__next']/div[@id='modal-root']/div/div/div[1] ; get our free newsletter - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=100) +JSBrighteonVideoDescription := FormatTextToJSText(VideoDescription) +; Msgbox % "JSBrighteonVideoDescription: " JSBrighteonVideoDescription - ; If newsletter pop up exists then close it. - Xpath = //div[@class='overlay__close inside'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=100) - - ; Try clicking the login button, sometimes this will auto log you back in without having to input credentials - xpath = //a[normalize-space()='Log In'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=100) - ; DevModeMsgBox(Status) - - - Message = Checking Login Status - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - try PageURL := driver.url - if(InStr(PageURL, "auth.brighteon.com/login?state")){ ; we're logged out and need to manually log back in +; descriptions longer than 5k characters just fail to get input so trim them to below 5000 characters +if(StrLen(VideoDescription) >= 5000){ + BrighteonVideoDescription := SubStr(VideoDescription, 1, 4800) + BrighteonVideoDescription .= "...." + JSBrighteonVideoDescription := FormatTextToJSText(BrighteonVideoDescription) + if(StrLen(JSBrighteonVideoDescription) > 5000){ + BrighteonVideoDescription := SubStr(VideoDescription, 1, 4500) + BrighteonVideoDescription .= "...." + JSBrighteonVideoDescription := FormatTextToJSText(BrighteonVideoDescription) + } +} - if(AutoLogin){ - Message = Trying to Log Back In - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile, DiscordErrorLogging") - ; js = return document.querySelector("input[placeholder='username/email']").value; - ; status := try driver.executeScript(JS) ;Execute Javascript - ; sleep, 5000 - ; Msgbox % "status: " status - ; if(StrLen(Status) > 0){ - ; msgbox, clicking login button - Xpath = //a[normalize-space()='Log In'] ; click login button at top right of page - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) +Message = Checking Login Status +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") +try CurrentTab := driver.url +if(InStr(CurrentTab, "login")) ; we're logged out +{ - ; sleep, 2000 - Xpath = //button[@type='submit'] ; click login button on login page - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=6,SleepLength:=1000) - try driver.executeScript("return document.readyState").equals("complete") + Message = Currently Logged Out`nClosing out of any popups that might appear before clicking Login button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 2000 - ; } + Xpath = //body/div[@id='__next']/div[@id='modal-root']/div[2]/div[1]/div[1]//*[local-name()='svg'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=100) + Xpath = //body/div[@id='__next']/div[@id='modal-root']/div/div/div[1] ; get our free newsletter + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=100) - } - else, { - SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - } - } + ; If newsletter pop up exists then close it. + Xpath = //div[@class='overlay__close inside'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=100) + ; Try clicking the login button, sometimes this will auto log you back in without having to input credentials + xpath = //a[normalize-space()='Log In'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=100) + ; DevModeMsgBox(Status) - Message = Navigating to Upload Page + Message = Checking Login Status 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 PageURL := driver.url + if(InStr(PageURL, "auth.brighteon.com/login?state")){ ; we're logged out and need to manually log back in - try driver.executeScript("return document.readyState").equals("complete") - TabURl := GetCurrentTabURlBase() - Message = Current Tab URL: %TabURL% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + if(AutoLogin){ + Message = Trying to Log Back In + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile, DiscordErrorLogging") - ; 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() + ; js = return document.querySelector("input[placeholder='username/email']").value; + ; status := try driver.executeScript(JS) ;Execute Javascript + ; sleep, 5000 + ; Msgbox % "status: " status - CheckForAlerts() + ; if(StrLen(Status) > 0){ + ; msgbox, clicking login button + Xpath = //a[normalize-space()='Log In'] ; click login button at top right of page + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - 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 - } + ; sleep, 2000 + Xpath = //button[@type='submit'] ; click login button on login page + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=6,SleepLength:=1000) + try driver.executeScript("return document.readyState").equals("complete") + sleep, 2000 + ; } - loop, 3 { - if(A_index = 3){ - Message = Failed to input Video Title - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + + } + else, { + SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() Return } + } +} - ; Input Title of the Video - Xpath = //input[@id='name'] - try driver.FindElementByXPath(Xpath).SendKeys(VideoTitle) ;Sends Variable to an Xpath Item - - - ; click into keyword box to get focus away from title element and see if the video title registers with website - xpath = //input[@id='keywords'] - try driver.FindElementByXPath(Xpath).click() - sleep, 500 +Message = Navigating to Upload Page +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - ; check if title got input - js = return document.querySelector("#name").value; - try, status := driver.executeScript(js) - if(status = "") - continue +; Navigate to Upload Page +try driver.executeScript("window.location = 'https://www.brighteon.com/dashboard/video-upload'") ;navigate using javascript - js = return document.querySelector("#name").value; - try, status := driver.executeScript(js) +try driver.executeScript("return document.readyState").equals("complete") - Message = Title that got input: %status% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - break +TabURl := GetCurrentTabURlBase() +Message = Current Tab URL: %TabURL% +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - } +; 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() - TooltipThis("Inputting Video Description") +CheckForAlerts() +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 +} - ; Attempt to input video description a couple of times - Loop, 10 { - if(A_index = 10){ - Message = Failed to input Video Description after 10 attempts. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } +loop, 3 { + if(A_index = 3){ + Message = Failed to input Video Title + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } - 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) + ; Input Title of the Video + Xpath = //input[@id='name'] + try driver.FindElementByXPath(Xpath).SendKeys(VideoTitle) ;Sends Variable to an Xpath Item - Xpath = //div[@class='e-content e-lib e-keyboard'] - 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") + ; click into keyword box to get focus away from title element and see if the video title registers with website + xpath = //input[@id='keywords'] + try driver.FindElementByXPath(Xpath).click() - ; driver.FindElementByXPath(Xpath).SendKeys(VideoDescription) + sleep, 500 - ; js = document.getElementById('description').value = "%JSBrighteonVideoDescription%"; - ; try driver.executeScript(js) + ; check if title got input + js = return document.querySelector("#name").value; + try, status := driver.executeScript(js) + if(status = "") + continue + js = return document.querySelector("#name").value; + try, status := driver.executeScript(js) - ; sleep, 1000 - ; TooltipThis("checking description input") - ; try driver.findElementsByID("description").item[1].SendKeys(driver.Keys.ENTER) - ; sleep, 1000 + Message = Title that got input: %status% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + break - sleep, 5000 +} - js = return document.querySelector("div[class='e-content e-lib e-keyboard'] p").innerText; - try Input_Description := driver.executeScript(JS) ;Execute Javascript +TooltipThis("Inputting Video Description") - 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 - } +; Attempt to input video description a couple of times +Loop, 10 { + if(A_index = 10){ + Message = Failed to input Video Description after 10 attempts. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return } + 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) - ; 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") - } + Xpath = //div[@class='e-content e-lib e-keyboard'] + 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") - ; DevModeMsgBox(VideoTags) - TooltipThis("Inputting Keywords") - Loop, 5 { - XPath = //input[@id='keywords'] - try driver.FindElementByXPath(Xpath).SendKeys(VideoTags) ;Sends Variable to an Xpath Item - catch e { - Message = Error (E#2312)`nVideo Uploaded but Unable to Input Video Tags - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - } + ; driver.FindElementByXPath(Xpath).SendKeys(VideoDescription) - ; 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 + ; js = document.getElementById('description').value = "%JSBrighteonVideoDescription%"; + ; try driver.executeScript(js) - ; 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 + ; sleep, 1000 + ; TooltipThis("checking description input") + ; try driver.findElementsByID("description").item[1].SendKeys(driver.Keys.ENTER) + ; sleep, 1000 + + sleep, 5000 - } - ; 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 + 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) > 5){ - SaveOrPostProgress(Message:="Video Description second double check was successful",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + 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 } - else, { - SaveOrPostProgress(Message:="Secondary video description check failed",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return + +} + + + +; 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") +Loop, 5 { + XPath = //input[@id='keywords'] + try driver.FindElementByXPath(Xpath).SendKeys(VideoTags) ;Sends Variable to an Xpath Item + catch e { + Message = Error (E#2312)`nVideo Uploaded but Unable to Input Video Tags + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + } - TooltipThis("Waiting for Video to Finish Uploading") - Loop, %Number_of_loops_to_Check_Upload_status% { - sleep, %Time_Between_Loops_Upload_Status% + ; 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 - ; Get progress status through javascript - jsCheck = return document.getElementsByClassName('video-upload--details')[0].textContent; - try ProgressStatus := driver.executeScript(jsCheck) - 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 - } +; 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 - ; Pull out progress Percentage from full string - UploadPercent := StrSplit(ProgressStatus, "(") - UploadPercent := UploadPercent[2] - UploadPercent := StrSplit(UploadPercent, ")") - UploadPercent := UploadPercent[1] +; 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, { + SaveOrPostProgress(Message:="Secondary video description check failed",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + 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) - if(Status = "Failed") - Return - } +TooltipThis("Waiting for Video to Finish Uploading") +Loop, %Number_of_loops_to_Check_Upload_status% { + sleep, %Time_Between_Loops_Upload_Status% - ; "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. + ; Get progress status through javascript + jsCheck = return document.getElementsByClassName('video-upload--details')[0].textContent; + try ProgressStatus := driver.executeScript(jsCheck) + + 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 + } - ; 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 + ; Pull out progress Percentage from full string + UploadPercent := StrSplit(ProgressStatus, "(") + UploadPercent := UploadPercent[2] + UploadPercent := StrSplit(UploadPercent, ")") + UploadPercent := UploadPercent[1] + ; Message = Waiting for Video to Finish Uploading`nCurrent Upload Status: %UploadPercent% + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip") - 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 - } + Status := Check_For_Stuck_Video_Upload(A_index, UploadPercent) + if(Status = "Failed") + Return +} - Message = Trying to Grab Newest Video's URL - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 2000 +; "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 +} - ; Navigate to Videos page to make sure it's refreshed with latest video - try driver.Get("https://www.brighteon.com/dashboard/videos") ;Open selected URL - try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding - sleep, 2000 +; 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 - ; 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 - ; MsgBox % VideoTitleArray[A_Index] +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 = VideoTitleLongWord: %VideoTitleLongWord% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - ; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") - 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) +Message = Trying to Grab Newest Video's URL +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") +sleep, 2000 - Loop, 4 { - ElementIndexNumber := A_index - 1 +; Navigate to Videos page to make sure it's refreshed with latest video +try driver.Get("https://www.brighteon.com/dashboard/videos") ;Open selected URL +try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding +sleep, 2000 - jsCheck = return document.getElementsByClassName('col')[%ElementIndexNumber%].outerHTML; - try BrighteonURL := driver.executeScript(jsCheck) - jsCheck = return document.getElementsByClassName('col')[%ElementIndexNumber%].textContent; - try InnerText := driver.executeScript(jsCheck) +; 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 = Loop Number: %ElementIndexNumber% element's Text Content: %innerText%`nBrighteonURL: %BrighteonURL% - ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + ; MsgBox % VideoTitleArray[A_Index] +} - ; Message = InnerText: %InnerText% - ; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") - ; DevModeMsgBox(InnerText) - ; Message = BrighteonURL: %BrighteonURL% - ; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") +Message = VideoTitleLongWord: %VideoTitleLongWord% +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") +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 - 1 - ; Msgbox % "VideoTitleLongWord: " VideoTitleLongWord "`nInnerText: " InnerText - ; clipboard := Message - ; msgbox % Message - ; Msgbox % "InnerText: " InnerText . "`n" . "BrighteonURL: " . BrighteonURL + jsCheck = return document.getElementsByClassName('col')[%ElementIndexNumber%].outerHTML; + try BrighteonURL := driver.executeScript(jsCheck) - if(InStr(InnerText, VideoTitleLongWord)){ - 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") + jsCheck = return document.getElementsByClassName('col')[%ElementIndexNumber%].textContent; + try InnerText := driver.executeScript(jsCheck) - BrighteonURL := StrSplit(BrighteonURL, "/dashboard/videos/") - BrighteonURL := BrighteonURL[2] - BrighteonURL := StrSplit(BrighteonURL, ">