From 4ad5fde4d4ab73b0dd0d456dbe3d07771dac3e9a Mon Sep 17 00:00:00 2001 From: yuriy Date: Thu, 23 Feb 2023 14:58:34 -0500 Subject: [PATCH] reworked bitchute login status check, reworked Bitchute title input to use JS with double check --- Freedomain Video Uploader.ahk | 1660 ++++++++++++++------------------- 1 file changed, 681 insertions(+), 979 deletions(-) diff --git a/Freedomain Video Uploader.ahk b/Freedomain Video Uploader.ahk index 8b57356..c09a106 100644 --- a/Freedomain Video Uploader.ahk +++ b/Freedomain Video Uploader.ahk @@ -158,6 +158,10 @@ IniRead, ReuseTabs, %SettingsIniFilepath%, General, ReuseTabs, 1 IniRead, AutoUpdateCheck, %SettingsIniFilepath%, General, AutoUpdateCheck, 1 (AutoUpdateCheck)?(AutoUpdateCheckCheckStatus := 1) : (AutoUpdateCheckCheckStatus := 0) +; AutoLogin setting +IniRead, AutoLogin, %SettingsIniFilepath%, General, AutoLogin, 1 +(AutoUpdateCheck)?(AutoUpdateCheckCheckStatus := 1) : (AutoUpdateCheckCheckStatus := 0) + IniRead, PingOnCompletion, %SettingsIniFilepath%, General, PingOnCompletion, 1 (PingOnCompletion)?(PingOnCompletionCheckStatus := 1) : (PingOnCompletionCheckStatus := 0) @@ -732,6 +736,7 @@ Gui, Add, Checkbox, xp+10 yp+20 vReuseTabs Checked%ReuseTabsCheckStatus% gUpdat Gui, Add, Checkbox, vShowTooltipProgress Checked%ShowTooltipProgressCheckStatus% gUpdateVars,Show Tooltip Progress Gui, Add, Checkbox, vKillLBRYAfterUpload Checked%KillLBRYAfterUploadCheckStatus% ,Kill LBRY After Uploading Gui, Add, Checkbox, vAutoUpdateCheck gUpdateVars Checked%AutoUpdateCheckCheckStatus%, Auto Update Check +Gui, Add, Checkbox, vAutoLogin gUpdateVars Checked%AutoLoginCheckStatus%, Try to Login Automatically Gui, Add, Checkbox, vPingOnCompletion gUpdateVars Checked%PingOnCompletionCheckStatus%, Discord Ping Upon Finish ; Gui, Add, Checkbox, vAutoUploadErrorLog gUpdateVars Checked%AutoUploadErrorLog%, Auto-Upload Large Errors @@ -1065,6 +1070,7 @@ if(VideoDescription != OriginalVideoDescription){ IniWrite, %ReuseTabs%, %SettingsIniFilepath%, General, ReuseTabs IniWrite, %ShowTooltipProgress%, %SettingsIniFilepath%, General, ShowTooltipProgress IniWrite, %AutoUpdateCheck%, %SettingsIniFilepath%, General, AutoUpdateCheck +IniWrite, %AutoLogin%, %SettingsIniFilepath%, General, AutoLogin IniWrite, %PingOnCompletion%, %SettingsIniFilepath%, General, PingOnCompletion IniWrite, %KillLBRYAfterUpload%, %SettingsIniFilepath%, General, KillLBRYAfterUpload @@ -1542,7 +1548,7 @@ if(SocialMediaPosterFilepath = "" or !FileExist(SocialMediaPosterFilepath)){ ; https://www.autohotkey.com/boards/viewtopic.php?t=59882 Message = Calculating MP3 File Size and Length - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile, DiscordErrorLogging") Obj := Filexpro(MP3AudioFilepath,, , "Length" @@ -1552,9 +1558,16 @@ if(SocialMediaPosterFilepath = "" or !FileExist(SocialMediaPosterFilepath)){ ; MsgBox % obj["Size"] AudioLengthArray := StrSplit(MP3AudioLength,":") - AudioLength_Hours := AudioLengthArray[1] - AudioLength_Minutes := AudioLengthArray[2] - AudioLength_Seconds := AudioLengthArray[3] + + Message = MP3 Audio Length: %MP3AudioLength% + SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging") + + AudioLength_Seconds := ((AudioLengthArray[1] * 60 ) * 60) + (AudioLengthArray[2] * 60) + AudioLengthArray[3] + Message = MP3 Audio Length in Seconds: %TotalTimeInSeconds% + + ; AudioLength_Hours := AudioLengthArray[1] + ; AudioLength_Minutes := AudioLengthArray[2] + ; AudioLength_Seconds := AudioLengthArray[3] ; AudioLength_SecondsOriginal := AudioLength_Seconds ; AudioLength_Seconds := (AudioLength_Minutes * 60) + ((AudioLength_Hours * 60) * 60) + AudioLength_Seconds @@ -1567,7 +1580,7 @@ if(SocialMediaPosterFilepath = "" or !FileExist(SocialMediaPosterFilepath)){ FIlesizeInBytes := OutputVar * 1024 - Message = Uploading Podcast Information + Message = Inputting Podcast Information SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") @@ -1690,6 +1703,8 @@ if(SocialMediaPosterFilepath = "" or !FileExist(SocialMediaPosterFilepath)){ Xpath = //input[@id='lengthSeconds'] Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=AudioLength_Seconds) + ; Message = Audio Length in Seconds that got input: %AudioLength_Seconds% + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") Message = Inputting Description SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") @@ -2919,43 +2934,56 @@ Loop, %Number_of_loops_to_Check_Upload_status% { } + Message = Checking Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - Message = Uploading Video + 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 + } + + } + + + + Message = Inputting Title SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - ; sleep, 5000 ; Try to input video title and if fail try to login again - loop, 2 { - Xpath = //input[@id='title'] - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=1000,StringTextContent:=VideoTitle) + loop, 5 { + if(A_index = 5){ + try CurrentURL := driver.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 + } - if(!Status) - Break + status := js_SendAndCheckWithQuerySelector(Selector:="#title",ValueToCheck:="value",SleepLength:=1000,JSStringText:=VideoTitle) + ; Msgbox % "status: " status - ; Try to login - Message = Checking Login Status - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - Xpath = //input[@id='id_username'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=1000) - if(!Status){ - Xpath = //button[normalize-space()='Submit'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(!Status) + break - Message = Waiting for Upload Page to Load - SaveOrPostProgress(Message:=Message,PostType:="Tooltip") - try driver.executeScript("return document.readyState").equals("complete") - sleep, 5000 - Continue - } - } - ; DevModeMsgBox("stop") - - ; BitchuteDescription := SubStr(VideoDescription, 0, 2995) . "..." - ; JSBitchuteDescription := FormatTextToJSText(BitchuteDescription) - + ; trim description if it's too long BitchuteDescription := VideoDescription if(StrLen(BitchuteDescription) > 2995){ BitchuteDescription := SubStr(BitchuteDescription, 1, 2995) @@ -2967,7 +2995,21 @@ Loop, %Number_of_loops_to_Check_Upload_status% { Message = Inputting Description SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") Loop, 10 { ; Attempt to input video description a couple of times - LogErrorToTextFile("Inputting Description") + Message = Inputting Description. Attempt #%A_index% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + + if(A_index = 10){ + try currentTabURL := driver.url + currentTabURL := SubStr(currentTabURL, 1, 40) + Message = Failed to input Video Description after %A_index% attempts`n `nCurrent Tab URL Beginning: %currentTabURL% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + ; LogErrorToTextFile("Inputting Description") + ; Input text ; try BitChuteUploadProgress := driver.executeScript("return document.getElementsByClassName('progress-bar')[0].innerHTML;") ;navigate using javascript @@ -2986,651 +3028,686 @@ Loop, %Number_of_loops_to_Check_Upload_status% { ; check contents of page try VideoDescriptionOnPage := driver.executeScript(jsCheck) ;Executes a Javascript on the webpage, mostly used for buttons. - if (A_index = 1){ - message := SubStr(VideoDescriptionOnPage, 1, 250) - message = Bitchute Inputted description: %message% - SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,DiscordErrorLogging") + if(StrLen(VideoDescription) > 5){ + Message = Video Description input successfully + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + break } - if(VideoDescriptionOnPage = ""){ - Message = Failed to input Video Description - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return + ; if (A_index = 1){ + ; message := SubStr(VideoDescriptionOnPage, 1, 250) + ; message = Description that got input: %message% + ; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,DiscordErrorLogging") + ; } + } - } + Message = Inputting Tags + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - 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 . " " + } - ; 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) - ; 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") - ; 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") - if(VideoThumbFilepath != ""){ - ; Upload Cover Image Button - Message = Uploading Thumbnail - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + 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 Video button + Message = Uploading Video File + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - Xpath = //input[@name='thumbnailInput'] - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoThumbFilepath) + Xpath = //input[@name='videoInput'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoFilepath) if(Status){ - Message = Failed to Attach Thumbnail + Message = Failed to Upload Video SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveDriverURLOFErrorPage() Return } - ; sleep, 5000 - } - ; Upload Video button - 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 - } + 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 - 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% + try BitChuteUploadProgress := driver.executeScript("return document.querySelector('.filepond--file-status').innerHTML;") ;navigate using javascript + ; Msgbox % "BitChuteUploadProgress: " BitChuteUploadProgress - 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() + if(BitChuteUploadProgress = ""){ + Message = Unable to Grab Upload Progress, Upload Possibly Failed + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return } - } - ; 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 + 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 - if(BitChuteUploadProgress = ""){ - Message = Unable to Grab Upload Progress, Upload Possibly Failed - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() + } + + ; 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) + } + } - JSBrighteonVideoDescription := FormatTextToJSText(VideoDescription) - ; Msgbox % "JSBrighteonVideoDescription: " JSBrighteonVideoDescription - ; 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) - } - } + Message = Checking Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + try CurrentTab := driver.url + if(InStr(CurrentTab, "login")) ; we're logged out + { -/*; Closing any popups that might appear -loop, 3 { -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:=1000) + Message = Closing out of any popups that might appear on loin page + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") -; try driver.FindElementByXPath(Xpath).click() + 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) -; If newsletter pop up exists then close it. -Xpath = //div[@class='overlay__close inside'] -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=1000) + 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) + ; 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 CurrentTab := driver.url -if(InStr(CurrentTab, "login")) ; we're logged out -{ + Message = Checking Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - Message = Closing out of any popups that might appear on loin page - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - 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) + try PageURL := driver.url + if(InStr(PageURL, "auth.brighteon.com/login?state")){ ; we're logged out and need to manually log back in - 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) - ; If newsletter pop up exists then close it. - Xpath = //div[@class='overlay__close inside'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=100) + if(AutoLogin){ + Message = Trying to Log Back In + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - ; 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) + js = return document.querySelector("input[placeholder='username/email']").value; + status := try driver.executeScript(JS) ;Execute Javascript + if(StrLen(Status) > 0){ + ; msgbox, clicking login button + Xpath = //a[normalize-space()='Log In'] ; click login button + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=6,SleepLength:=1000) - Message = Checking Login Status - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + sleep, 2000 + Xpath = //button[@type='submit'] ; click login button on login page + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + try driver.executeScript("return document.readyState").equals("complete") - try PageURL := driver.url - if(InStr(PageURL, "auth.brighteon.com/login?state")){ ; we're logged out and need to manually log back in + sleep, 2000 + } - if(AutoLogin){ - Message = Trying to Log Back In - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + } + else, { + SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + } + } - js = return document.querySelector("input[placeholder='username/email']").value; - status := try driver.executeScript(JS) ;Execute Javascript - if(StrLen(Status) > 0){ - ; msgbox, clicking login button - Xpath = //a[normalize-space()='Log In'] ; click login button - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=6,SleepLength:=1000) - sleep, 2000 - Xpath = //button[@type='submit'] ; click login button on login page - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - try driver.executeScript("return document.readyState").equals("complete") + ; Navigate to Upload Page + try driver.executeScript("window.location = 'https://www.brighteon.com/dashboard/video-upload'") ;navigate using javascript - sleep, 2000 - } + try driver.executeScript("return document.readyState").equals("complete") + ; 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() - } - else, { - SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + ; 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 } -} -} + loop, 3 { + if(A_index = 3){ + Message = Failed to input Video Title + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } -; Navigate to Upload Page -try driver.executeScript("window.location = 'https://www.brighteon.com/dashboard/video-upload'") ;navigate using javascript + ; Input Title of the Video + Xpath = /html/body/div/section[2]/div[2]/div/form/div[1]/div[1]/div[2]/div[1]/div/input + try driver.FindElementByXPath(Xpath).SendKeys(VideoTitle) ;Sends Variable to an Xpath Item -try driver.executeScript("return document.readyState").equals("complete") -; 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("#name").value; + try, status := driver.executeScript(js) -; 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 -} + if(status = ""){ + Message = Failed to input Title + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + continue + } -; Input Title of the Video -Xpath = /html/body/div/section[2]/div[2]/div/form/div[1]/div[1]/div[2]/div[1]/div/input -try driver.FindElementByXPath(Xpath).SendKeys(VideoTitle) ;Sends Variable to an Xpath Item + Message = Title that got input: %status% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + break + } + ; Msgbox % "status: " status -TooltipThis("Inputting Video Description") -; sleep, 5000 -; @todo this doesn't do anything anymore. -; DevModeMsgBox("rework me here") -; Xpath = //textarea[@id='description'] -; try, driver.FindElementByXPath(XPATH).SendKeys(driver.Keys.SPACE) + TooltipThis("Inputting Video Description") -; sleep, 1000 -; Attempt to input video description a couple of times -Loop, 10 { - Message = Inputting Description. `nAttempt Number: %A_index% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - ; SaveOrPostProgress(Message:=Message,PostType:="DiscordErrorLogging") + ; Attempt to input video description a couple of times + Loop, 10 { + Message = Inputting Description. `nAttempt 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) + ; SaveOrPostProgress(Message:="Inputting Video Description",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar") + ; TooltipThis("Inputting Description) - 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,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } + 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,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } - ; DevModeMsgBox("pause") + ; DevModeMsgBox("pause") - ; driver.FindElementByXPath(Xpath).SendKeys(VideoDescription) + ; driver.FindElementByXPath(Xpath).SendKeys(VideoDescription) - ; js = document.getElementById('description').value = "%JSBrighteonVideoDescription%"; - ; try driver.executeScript(js) + ; js = document.getElementById('description').value = "%JSBrighteonVideoDescription%"; + ; try driver.executeScript(js) - ; sleep, 1000 - ; TooltipThis("checking description input") - ; try driver.findElementsByID("description").item[1].SendKeys(driver.Keys.ENTER) - ; sleep, 1000 + ; sleep, 1000 + ; TooltipThis("checking description input") + ; try driver.findElementsByID("description").item[1].SendKeys(driver.Keys.ENTER) + ; sleep, 1000 - sleep, 5000 + sleep, 5000 - js = return document.querySelector("div[class='e-content e-lib e-keyboard'] p").innerText; - try Input_Description := driver.executeScript(JS) ;Execute Javascript + 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) > 15){ - Input_Description := SubStr(Description, 1, 200) - Message = Description that got input: %Input_Description% ... - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - Break - } + 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") - } -} + ; 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") + } + } -; Keywords (Tags) -; DevModeMsgBox(VideoTags) -TooltipThis("Inputting Keywords") -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") -} + ; 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") + } -; 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 -DevModeMsgBox(Input_Description) - -; 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 -} + ; 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 -TooltipThis("Waiting for Video to Finish Uploading") -Loop, %Number_of_loops_to_Check_Upload_status% { - sleep, %Time_Between_Loops_Upload_Status% + } - ; Get progress status through javascript - jsCheck = return document.getElementsByClassName('video-upload--details')[0].textContent; - try ProgressStatus := driver.executeScript(jsCheck) + ; 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 + DevModeMsgBox(Input_Description) - if(ProgressStatus = ""){ - Message = Failed to Grab Video Upload Status. Upload Most Likely Failed - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() + ; 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 } - if(InStr(ProgressStatus, "Upload complete.")){ - Break - } - ; 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 Video to Finish Uploading") + Loop, %Number_of_loops_to_Check_Upload_status% { + sleep, %Time_Between_Loops_Upload_Status% - Status := Check_For_Stuck_Video_Upload(A_index, UploadPercent) - if(Status = "Failed") - Return -} + ; Get progress status through javascript + jsCheck = return document.getElementsByClassName('video-upload--details')[0].textContent; + try ProgressStatus := driver.executeScript(jsCheck) -; 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 + 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 Result page to finish loading") -Loop, 60 { ; 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 + ; Pull out progress Percentage from full string + UploadPercent := StrSplit(ProgressStatus, "(") + UploadPercent := UploadPercent[2] + UploadPercent := StrSplit(UploadPercent, ")") + UploadPercent := UploadPercent[1] - sleep, 5000 ; 30 seconds - try CurrentURL := driver.url - if(BrighteonUploadPageURL != CurrentURL) - Break -} + ; 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 + } -Message = Trying to Grab Uploaded Video URL -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + ; 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 -; 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 -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 + TooltipThis("Waiting for Result page to finish loading") + Loop, 60 { ; 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 + } -; 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 + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - ; MsgBox % VideoTitleArray[A_Index] -} + ; 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 + 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 -Message = VideoTitleLongWord: %VideoTitleLongWord% -SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") -Loop, 4 { - ElementIndexNumber := A_index + 1 + ; 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 - jsCheck = return document.getElementsByClassName('col')[%ElementIndexNumber%].outerHTML; - try BrighteonURL := driver.executeScript(jsCheck) + ; MsgBox % VideoTitleArray[A_Index] + } - jsCheck = return document.getElementsByClassName('col')[%ElementIndexNumber%].textContent; - try InnerText := driver.executeScript(jsCheck) - Message = InnerText: %InnerText% + Message = VideoTitleLongWord: %VideoTitleLongWord% SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") - Message = BrighteonURL: %BrighteonURL% - SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") - ; Msgbox % "VideoTitleLongWord: " VideoTitleLongWord "`nInnerText: " InnerText - ; clipboard := Message - ; msgbox % Message - ; Msgbox % "InnerText: " InnerText . "`n" . "BrighteonURL: " . BrighteonURL + Loop, 4 { + ElementIndexNumber := A_index + 1 - if(InStr(InnerText, VideoTitleLongWord)){ - BrighteonURL := StrSplit(BrighteonURL, "/dashboard/videos/") - BrighteonURL := BrighteonURL[2] - BrighteonURL := StrSplit(BrighteonURL, "> 10) ; if no errors then text got input correctly, break out of loop - Break - - - ; sleep, 2000 } +if(LBRYUploadType = "Audio"){ + ; Replace all items to make text passable to API + LBRYVideoTitle .= " (Audio)" + LBRYURLSlug .= "_Audio" + Message = Uploading through API with URL Slug: %LBRYURLSlug% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - -; Input Video Tags. We need to send them one item at a time to Streamanity -; StreamanityTagsArray := StrSplit(VideoTags,",") - - -Message = Inputting Video Tags -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - -; Xpath to Tags Input Box -; Xpath = /html/body/div[1]/div[3]/div[2]/div/div/div/div[1]/div/div[3]/div/div/div/div[2]/div[1]/form/div[3]/div/div/div/div/div/input -Xpath = /html/body/div[1]/div[3]/div[2]/div/div/div/div[1]/div/div[3]/div/div/div/div[2]/div[1]/form/div[3]/div/div/div/div/div/input -; Input Each tag one by one -Loop % KeywordsArray.Length() -{ - Tag := KeywordsArray[A_Index] - ; Msgbox % "Tag: " Tag - try driver.FindElementByXPath(Xpath).SendKeys(Tag) ;Sends Variable to an Xpath Item - try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.Enter) ;Sends Enter key to Xpath. - ; msgbox, pause - sleep, 250 + FilePathForLBRYAPI := WavAudioFilepath } - -; ASK STEF FOR INPUT HERE -TooltipThis("Waiting for User to Swipe Payment Button") -Xpath = //div[@class='video-title'] -; MsgBox,,Xpath Value,% driver.findelementbyxpath(Xpath).Attribute("value") ;XPath: ID=site-title & span tag - -Loop, 20 { - - if(A_index = 20){ - Message = Payment was not swiped. Skipping to Next Website - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - - - try Status := driver.findelementbyxpath(Xpath).Attribute("innerText") ; Grabb innertext - if !InStr(Status, "Waiting for payment") - break - - ; otherwise sleep and re-run check - sleep, 5000 +; if no lbry slug, then error out +if(LBRYURLSlug = "" OR LBRYURLSlug = "_Audio"){ + Message = Upload Failed because no URL Slug was provided. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return } +; loops through array and creates a string of: --tags="tag1" --tags="tag2" --tags="tag3" so that it can be passed to lbrynet +Loop % KeywordsArray.Length(){ + LBRYTags .= "--tags=" . SingleQuotationmark KeywordsArray[A_Index] . SingleQuotationmark . " " +} +; Msgbox % "FilePathForLBRYAPI: " FilePathForLBRYAPI -; Status := StrSplit(status, "`n") -; msgbox % Status[1] -; msgbox % Status[2] - - -; MsgBox,,XPATH Text Content,% driver.findelementbyxpath(Xpath).Attribute("textContent") ;XPath: ID=site-title & span tag -; MsgBox,,HREF Link Location: ,% driver.findelementbyxpath(Xpath).Attribute("href") ;XPath: Href (Link location) value -; MsgBox,,XPATH-ID & Tag,% driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPath: ID=site-title & span tag -; MsgBox,,XPATH Option Value,% driver.findelementbyxpath(Xpath).Attribute("option value") ;XPath: ID=site-title & span tag - - - -TooltipThis("Waiting for Video to Finish Uploading") - -; Upload status text at the top left of the page -Xpath = /html/body/div[1]/div[3]/div[2]/div/div/div/div[1]/div/div[1]/div/div[1]/span - -Loop, %Number_of_loops_to_Check_Upload_status% { - sleep, %Time_Between_Loops_Upload_Status% - - jsCheck = return document.querySelector("div[class='video-title'] span").textContent; - try UploadStatus := driver.executeScript(jsCheck) +SplitPath, VideoThumbFilepath, ThumbnailFileNameWExt, OutDir, OutExtension, OutNameNoExt, OutDrive - ; try UploadStatus := driver.findelementbyxpath(Xpath).Attribute("innerText") ; Grab innertext - - if(UploadStatus = ""){ - Message = Failed to Grab Video Upload Status. Upload Most Likely Failed - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - ; Msgbox % "UploadStatus: " UploadStatus +FDRThumbnailURL = https://cdn.freedomainradio.com/%ThumbnailFileNameWExt% +message = FDRThumbnailURL: %FDRThumbnailURL% +SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging") - if(InStr(UploadStatus, "Complete")){ ; If upload is complete then we're ready to click the Publish Button - sleep, 5000 ; 5 seconds - Break +; Msgbox % "FDRThumbnailURL: " FDRThumbnailURL +; Create API Command and save it to variable +LBRYAPICommand = "%LBRYNetFilepath%" publish --name="%LBRYURLSlug%" --bid="%LBRYNewVideoStakeAmount%" --file_path="%FilePathForLBRYAPI%" --title="%LBRYVideoTitle%" --description="%LBRYVideoDescription%" %LBRYTags% --thumbnail_url="%FDRThumbnailURL%" --channel_id="%LBRYChannelID%" +; LogErrorToTextFile(LBRYAPICommand) ; Log to file +LogErrorToTextFile("LBRYAPICommand: " LBRYAPICommand) - Status := Check_For_Stuck_Video_Upload(A_index, UploadStatus) - if(Status = "Failed") +; Parse returned API json for success status +UploadResult := StdOutToVar(LBRYAPICommand) +if(InStr(UploadResult, "Could not connect")){ + Message = Upload Failed. Reason: %UploadResult% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") Return +} - ; if(A_index = 240){ - ; Message = Upload Failed. Upload did not complete after 2 hours of waiting. Something possibly went wrong? - ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - ; SaveDriverURLOFErrorPage() - ; Return - ; } - - - ; if(HasVal(Array_Index_Num_of_Upload_StatusChecks, A_index)) { ; 30 minutes and 60 minutes - send a notification message - ; Message = Upload Status: %UploadStatus% - ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - ; } - - - } - - } - - ; Publish Button at the very bottom - SaveOrPostProgress(Message:="Trying to Click Publish Button",PostType:="Tooltip,ErrorLoggingTextFile") - Xpath = //span[normalize-space()='P U B L I S H'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) - if(Status){ - Message = Streamanity Upload Incomplete (E#4701)`nVideo Uploaded But Unable to click final "Publish" button - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - } - - ; Wait for Confirmation Page to load and grab the Video URL from here - Message = Waiting for Confirmation Page to Load - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - - Xpath = //div[@class='link'] ; Xpath to URL of the video - Loop, 60 { ; loop for a couple of minutes to wait for confirmation page to load - jsCheck = return document.getElementsByClassName('link')[0].textContent; - try StreamanityURL := driver.executeScript(jsCheck) - - if(InStr(StreamanityURL, "https://streamanity.com")) - Break - - if(A_index = 60){ - try PageURL := driver.URL - Message = Upload Complete: But Failed to Grab Video Link`nPage Stuck At at: %PageURL% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - IniWrite, Failed to Grab Link. Please copy and paste into here, %VideoLinksIniFile%, URLs, StreamanityURL - SaveDriverURLOFErrorPage() - Return - } - Sleep, 1000 - } - - if(StreamanityURL = ""){ - Message = Upload Successfull but unable to automatically grab URL. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - } - - Message = Upload Complete:`n%StreamanityURL% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - IniWrite, %StreamanityURL%, %VideoLinksIniFile%, URLs, StreamanityURL - SaveDriverURL() - AddToTotalVideosUploadedCount() - ; TakeScreenshotOfPage(ScreenShotSavePath) - +if(UploadResult = ""){ + Message = LBRYNet did not return anything. LBRY not running? + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") Return - ; -------------------------------/streamanity------------------------------- - - - +} +; Msgbox % "UploadResult: " UploadResult +try parsed := JSON.Load(UploadResult) +try UploadStatus := parsed.height - ; -------------------------------LBRY------------------------------- - LBRYVideoUpload: - LBRYAudioUpload: - if(LBRYUploadType = "Video"){ - CurrentSite := "LBRY Video" - IniRead, LBRYPermanentURL, %VideoLinksIniFile%, Misc, LBRYVideoPermanentURL, %A_Space% +; Msgbox % "UploadStatus: " UploadStatus - } - if(LBRYUploadType = "Audio"){ - CurrentSite := "LBRY Audio" - IniRead, LBRYPermanentURL, %VideoLinksIniFile%, Misc, LBRYAudioPermanentURL, %A_Space% - } +; -2 is returned if upload was successful +if(UploadStatus != "-2"){ + ; msgbox, error + ErrorCode := parsed.message + ErrorCode := parsed.message + ErrorCode := StrSplit(ErrorCode, "code") + ErrorCode := ErrorCode[1] - ; if LBRY permanent URL was already grabbed before, exit - if(LBRYPermanentURL != "") + Message = LBRY Upload Failed`nReason: %ErrorCode% + ; Msgbox % "Message: " Message + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") Return +} - CheckLBRYProcess() ; double check lbry process - SaveOrPostProgress(Message:="Starting Upload",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +; Clipboard := UploadResult +; Msgbox % "UploadResult: " UploadResult - ; If LBRY Killer not found, then download it - ; @todo: Add LBRY kill download functionality from gitea +LogErrorToTextFile("UploadResult: " UploadResult) - LBRYKillerPath := LibFolder . "\LBRY Process Killer.exe" - if(!FileExist(LBRYKillerPath)){ +if(InStr(UploadResult, "Could not connect to daemon")){ + if(LBRYAttemptNumber = 2){ - ; Msgbox % "LBRYKillerPath: " LBRYKillerPath - ; Msgbox % "LBRYProcessKillerURL: " LBRYProcessKillerURL - LBRYKillerPath = %A_ScriptDir%\Lib\LBRY Process Killer.exe - LBRYKillerUpdateURL = https://git.zinchuk.xyz/attachments/7865dc8d-5aad-4f9f-8a30-94bab0192b1d - - UrlDownloadToFile, %LBRYKillerUpdateURL%, %LBRYKillerPath% - ; msgbox, work? - ; UrlDownloadToFile, URL, Filename - Message = LBRY Process Killer Not Found. Automatically Downloading. + Message = Upload Error (E#4081)`nVideo Upload Failed due to daemon not running.`nPlease start it manually and re-run the upload. SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - } - - - - TooltipThis("Uploading Video through API") - ; Variables of items that need to be replaced before argument is passed to API - Apostrophe = ' - LBRYTags = ; Create empty variable - SingleQuotationmark = " - EscapedQuotationMark = \" - - ; Replace all items to make text passable to API - LBRYVideoTitle := StrReplace(VideoTitle, SingleQuotationmark, EscapedQuotationMark) ; replace all spaces with dashes - LBRYVideoDescription := StrReplace(VideoDescription, SingleQuotationmark, EscapedQuotationMark) - - if(StrLen(LBRYVideoDescription) >= 5000){ - LBRYVideoDescription := SubStr(LBRYVideoDescription, 1, 4990) - LBRYVideoDescription .= "...." - } - if(LBRYUploadType = "Video"){ - Message = Uploading through API with URL Slug: %LBRYURLSlug% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - FilePathForLBRYAPI := VideoFilepath - - } - - if(LBRYUploadType = "Audio"){ - ; Replace all items to make text passable to API - LBRYVideoTitle .= " (Audio)" - LBRYURLSlug .= "_Audio" - Message = Uploading through API with URL Slug: %LBRYURLSlug% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - FilePathForLBRYAPI := WavAudioFilepath - } - - ; if no lbry slug, then error out - if(LBRYURLSlug = "" OR LBRYURLSlug = "_Audio"){ - Message = Upload Failed because no URL Slug was provided. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - - - - ; loops through array and creates a string of: --tags="tag1" --tags="tag2" --tags="tag3" so that it can be passed to lbrynet - Loop % KeywordsArray.Length(){ - LBRYTags .= "--tags=" . SingleQuotationmark KeywordsArray[A_Index] . SingleQuotationmark . " " - } - - ; Msgbox % "FilePathForLBRYAPI: " FilePathForLBRYAPI - - SplitPath, VideoThumbFilepath, ThumbnailFileNameWExt, OutDir, OutExtension, OutNameNoExt, OutDrive - - FDRThumbnailURL = https://cdn.freedomainradio.com/%ThumbnailFileNameWExt% - message = FDRThumbnailURL: %FDRThumbnailURL% - SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging") - - ; Msgbox % "FDRThumbnailURL: " FDRThumbnailURL - ; Create API Command and save it to variable - LBRYAPICommand = "%LBRYNetFilepath%" publish --name="%LBRYURLSlug%" --bid="%LBRYNewVideoStakeAmount%" --file_path="%FilePathForLBRYAPI%" --title="%LBRYVideoTitle%" --description="%LBRYVideoDescription%" %LBRYTags% --thumbnail_url="%FDRThumbnailURL%" --channel_id="%LBRYChannelID%" - - ; LogErrorToTextFile(LBRYAPICommand) ; Log to file - LogErrorToTextFile("LBRYAPICommand: " LBRYAPICommand) - - ; Parse returned API json for success status - UploadResult := StdOutToVar(LBRYAPICommand) - if(InStr(UploadResult, "Could not connect")){ - Message = Upload Failed. Reason: %UploadResult% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - - if(UploadResult = ""){ - Message = LBRYNet did not return anything. LBRY not running? - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - - ; Msgbox % "UploadResult: " UploadResult - try parsed := JSON.Load(UploadResult) - try UploadStatus := parsed.height - - ; Msgbox % "UploadStatus: " UploadStatus - - ; -2 is returned if upload was successful - if(UploadStatus != "-2"){ - ; msgbox, error - ErrorCode := parsed.message - ErrorCode := parsed.message - ErrorCode := StrSplit(ErrorCode, "code") - ErrorCode := ErrorCode[1] - - Message = LBRY Upload Failed`nReason: %ErrorCode% - ; Msgbox % "Message: " Message - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + try run, %LBRYKillerPath% "Kill" + catch e { + ; Message = Unable to Kill LBRYKiller.ahk + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + } Return } - - - - ; Clipboard := UploadResult - ; Msgbox % "UploadResult: " UploadResult - - - LogErrorToTextFile("UploadResult: " UploadResult) - - if(InStr(UploadResult, "Could not connect to daemon")){ - if(LBRYAttemptNumber = 2){ - - Message = Upload Error (E#4081)`nVideo Upload Failed due to daemon not running.`nPlease start it manually and re-run the upload. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - try run, %LBRYKillerPath% "Kill" - catch e { - ; Message = Unable to Kill LBRYKiller.ahk - ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - } - Return - } - else, { ; if attempt number 1 - Process, Close, LBRY.exe ; terminate LBRY if it's running - LBRYAttemptNumber := 2 - Message = Upload Failed (E#1980)`nDue to daemon not running.`nTrying to restart LBRY.exe and try the upload again. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - Goto, LBRYVideoUpload - } + else, { ; if attempt number 1 + Process, Close, LBRY.exe ; terminate LBRY if it's running + LBRYAttemptNumber := 2 + Message = Upload Failed (E#1980)`nDue to daemon not running.`nTrying to restart LBRY.exe and try the upload again. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + Goto, LBRYVideoUpload } +} - ; Clipboard := UploadResult - ; Msgbox % "UploadResult: " UploadResult +; Clipboard := UploadResult +; Msgbox % "UploadResult: " UploadResult /*if(DevMode){ Clipboard := UploadResult @@ -5143,7 +4845,7 @@ try CurrentURL := driver.URL if(InStr(CurrentURL, "/login.php")){ - AutoLogin := 1 + ; AutoLogin := 1 ; Msgbox % "AutoLogin: " AutoLogin if(AutoLogin){