diff --git a/Freedomain Video Uploader.ahk b/Freedomain Video Uploader.ahk index 1813041..7d75a24 100644 --- a/Freedomain Video Uploader.ahk +++ b/Freedomain Video Uploader.ahk @@ -2937,1531 +2937,20 @@ AddToTotalVideosUploadedCount() Return -; -------------------------------BitChute------------------------------- -BitChuteUpload: -CurrentSite := "Bitchute" - -Message = Starting Upload -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - -Status := NavigateFromBaseURLTo("https://www.bitchute.com/myupload", "BitChute Video Uploader") -if(Status) -Return - -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 - 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, check if input and if not, try again -loop, 5 { - status := js_SendAndCheckWithQuerySelector(Selector:="#title",ValueToCheck:="value",SleepLength:=1000,JSStringText:=VideoTitle) - ; Msgbox % "status: " status - - if(!Status) - break -} - - -if(Status){ - Message = Failed to input Video Title with Javascript. Trying again with Manual Typing - SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging") - - Xpath = //input[@id='title'] - Status := Selenium_TypeTextIntoElement(VideoTitle, Xpath) - if(Status){ - Message = Failed to Input Video Title after trying two different ways. Please try Upload again and double check that the website hasn't been updated in a major way. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar, DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - - try, TextInputted := driver.findelementbyxpath(Xpath).Attribute("value") ;XPath: ID=site-title & span tag - if(InStr(VideoTitle, TextInputted) OR VideoTitle = TextInputted){ - ; Title got input successfully - } - else, { - Message = Title that got input into Bitchute: %TextInputted% - SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging") - - Message = Failed to Input Video Title after trying two different ways. Please try Upload again and double check that the website hasn't been updated in a major way. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar, DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } -} - - - -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") - - - 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 - } - - - 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 -} - - -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 . " " -} - -; 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") - -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='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 - - try BitChuteUploadProgress := driver.executeScript("return document.querySelector('.filepond--file-status').innerHTML;") ;navigate using javascript - ; Msgbox % "BitChuteUploadProgress: " BitChuteUploadProgress - - 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 - - } - - ; split_text = "> - ; Pull out upload percentage - 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) - } -} - - - - -Message = Checking Login Status -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") -try CurrentTab := driver.url -if(InStr(CurrentTab, "login")) ; we're logged out -{ - - Message = Currently Logged Out`nClosing out of any popups that might appear before clicking Login button - 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) - - 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 PageURL := driver.url - if(InStr(PageURL, "auth.brighteon.com/login?state")){ ; we're logged out and need to manually log back in - - - 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) - - ; 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 - ; } - - - } - else, { - SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - } -} - - - -Message = Navigating to Upload Page -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - -; Navigate to Upload Page -try driver.executeScript("window.location = 'https://www.brighteon.com/dashboard/video-upload'") ;navigate using javascript - -try driver.executeScript("return document.readyState").equals("complete") - -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() - - -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 -} - - -loop, 3 { - if(A_index = 3){ - Message = Failed to input Video Title - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - 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 - - ; 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) - - Message = Title that got input: %status% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - break - -} - - -TooltipThis("Inputting Video Description") - - - -; 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) - - 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") - - ; driver.FindElementByXPath(Xpath).SendKeys(VideoDescription) - - ; 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, 5000 - - - js = return document.querySelector("div[class='e-content e-lib e-keyboard'] p").innerText; - try Input_Description := driver.executeScript(JS) ;Execute Javascript - - Input_DescriptionStrLen := StrLen(Input_Description) - Message = Length of Description that got input: %Input_DescriptionStrLen% - SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging") - - ; if text in description box is longer than x chars, then description input worked - if(StrLen(Input_Description) > 15){ - Input_Description := SubStr(Input_Description, 1, 20) - Message = Description that got input: %Input_Description% ... - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - Break - } - -} - - - -; Thumbnail -if(VideoThumbFilepath != "") { - TooltipThis("Uploading Thumbnail") - Xpath = //input[@type='file'] - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoThumbFilepath) - if(Status){ - Message = Failed to Upload Thumbnail - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - } -} - - -; DevModeMsgBox(VideoTags) -TooltipThis("Inputting Keywords") -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") - } - - ; click into video title to get focus away from inputbox - Xpath = /html/body/div/section[2]/div[2]/div/form/div[1]/div[1]/div[2]/div[1]/div/input - try, driver.FindElementByXPath(Xpath).click() ;Sends Variable to an Xpath Item - - ; check that the tags got input - js = return document.querySelector("#keywords").value; - try, status := driver.executeScript(js) - if(!status){ - Message = Failed to input tags. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - } - else, { - Message = Tags that got input: %status% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - break - } - ; Msgbox % "status: " status - - -} - -; double check on video description after inputting tags -js = return document.querySelector("div[class='e-content e-lib e-keyboard'] p").innerText; -try Input_Description := driver.executeScript(JS) ;Execute Javascript - -; if text in description box is longer than x chars, then description input worked -if(StrLen(Input_Description) > 5){ - SaveOrPostProgress(Message:="Video Description second double check was successful",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") -} -else, { - SaveOrPostProgress(Message:="Secondary video description check failed",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return -} - - - -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) - - 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 - } - - ; 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") - - Status := Check_For_Stuck_Video_Upload(A_index, UploadPercent) - if(Status = "Failed") - Return -} - - -; "Save Now" button -js = return document.querySelector("button[class='mr-2 btn btn-primary btn-sm']").textContent; -try, status := driver.executeScript(js) -if(!InStr(status, "Save Video")){ - Message = Save Video Button is not clickable. Please check page for errors. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return -} - - -; Save Video button -TooltipThis("Clicking Save Video Button to finalize Upload") -try BrighteonUploadPageURL := driver.url -try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding - - -TooltipThis("Waiting for Result page to finish loading") -Loop, 10 { ; 5 loops of 1 minute each - if(A_index = 10){ - Message = Upload Failed: Clicking "Save Video" did not Finalize the Upload - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return ; Break out of gosub - } - js = document.getElementsByClassName('mr-2 btn btn-primary btn-sm')[0].click(); ; Save Video Button - try driver.executeScript(js) - driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding - - sleep, 5000 ; 30 seconds - try CurrentURL := driver.url - if(BrighteonUploadPageURL != CurrentURL) - Break -} - - -Message = Trying to Grab Newest Video's URL -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") -sleep, 2000 - -; 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 - - -; 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] -} - - -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 - - jsCheck = return document.getElementsByClassName('col')[%ElementIndexNumber%].outerHTML; - try BrighteonURL := driver.executeScript(jsCheck) - - jsCheck = return document.getElementsByClassName('col')[%ElementIndexNumber%].textContent; - try InnerText := driver.executeScript(jsCheck) - - ; Message = Loop Number: %ElementIndexNumber% element's Text Content: %innerText%`nBrighteonURL: %BrighteonURL% - ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - ; Message = InnerText: %InnerText% - ; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") - ; DevModeMsgBox(InnerText) - - ; Message = BrighteonURL: %BrighteonURL% - ; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") - - - - ; Msgbox % "VideoTitleLongWord: " VideoTitleLongWord "`nInnerText: " InnerText - ; clipboard := Message - ; msgbox % Message - ; Msgbox % "InnerText: " InnerText . "`n" . "BrighteonURL: " . BrighteonURL - - 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") - - BrighteonURL := StrSplit(BrighteonURL, "/dashboard/videos/") - BrighteonURL := BrighteonURL[2] - BrighteonURL := StrSplit(BrighteonURL, "> 2900){ - DailyMotionDescription := SubStr(VideoDescription, 1, 2900) . "..." -} -else, -DailyMotionDescription := VideoDescription - - -DailyMotionJSDescription := FormatTextToJSText(DailyMotionDescription) - -Message := "DailyMotionJSDescription String Length: " . StrLen(DailyMotionJSDescription) -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - -Message = Inputting Video Description -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") -Loop, 5 { ; make a couple attempts to input description - if(A_index = 5){ - Message = Failed to input Description after %A_index% attempts. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - - - ; click into element - Xpath = //textarea[@placeholder='Enter a description'] - try driver.FindElementByXPath(Xpath).click() - - ; send a space and then backspace so element registers the input - Xpath = //textarea[@placeholder='Enter a description'] - try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.SPACE) - try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.BackSpace) - - - ; inut description with javascript - js = document.querySelector("textarea[placeholder='Enter a description']").value = "%JSVideoDescription%"; - try driver.executeScript(js) - - ; send a space and then backspace so element registers the input - Xpath = //textarea[@placeholder='Enter a description'] - try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.SPACE) - try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.BackSpace) - - sleep, 1000 - - js = return document.querySelector("textarea[placeholder='Enter a description']").textContent; - try, InputDescription := driver.executeScript(js) - - message = InputDescription: %InputDescription% - DevModeMsgBox(InputDescription) - - ; if input description is less than 15 chars, try again - if(StrLen(InputDescription) < 15) - Continue - else, - Break - -} - - - -; Make a couple attempts to Click on Drop down menu and select the "Education" Category -Message = Selecting Education Category -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - -Loop, 3 { - if(A_index = 3){ - Message = Failed to Select Education Category after %A_index% attempts - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - - Xpath = //div[@name='channel'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - - js = document.querySelector("div[title='Education'] div[class='ant-select-item-option-content']").click() - try status := driver.executeScript(js) - - js = return document.querySelector("div[name='channel']").textContent; - try, status := driver.executeScript(js) - - if(instr(status, "Education")) - break - -} - - -Message = Inputting Tags -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - -; Append comma to end of tags -; DailyMotion page automtically splits the tags into their little boxes when they're seperated by commas -DailyMotionVideoTags := VideoTags . "," - -Message = Video Tags: %DailyMotionVideoTags% -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - -Xpath = //div[@class='ant-select-selection-search']//input[@role='combobox'] -Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=DailyMotionVideoTags) - -; double check the input -js = return document.querySelector("div[name='tags']").textContent; -try, inputTags := driver.executeScript(js) -Message = Tags that got input: %inputTags% (Will be doubled b/c of js) -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - -; msgbox -Message = Clicking Next Button to Move on to next input screen -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - -Xpath = //button[@type='button']//span[contains(text(),'Next')] -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - -; msgbox, click work? - -Message = Selecting "Not For Kids" checkbox -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - -try driver.findElementsByName("is_created_for_kids").item[2].click() -catch e { - sleep, 2000 - try driver.findElementsByName("is_created_for_kids").item[2].click() - catch e { - Message = Failed to Click on the "Not Made For Kids" checkbox. Please switch to tab and finalize upload. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } -} - - -/* -; Disable monitization for video -SaveOrPostProgress(Message:="Unchecking monetizaton checkbox",PostType:="Tooltip,ErrorLoggingTextFile") -Xpath = //button[normalize-space()='Advanced'] ; advanced tab button -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) -if(Status = "Failed"){ - Message = Unable to Navigate to Advanced Settings Page to turn off monetization - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") -} - - -*/ -; SaveOrPostProgress(Message:="Unchecking monetizaton checkbox",PostType:="Tooltip,ErrorLoggingTextFile") - -; switch over to advanced tab -; js = document.getElementsByName('advanced')[0].click(); -; try driver.executeScript(js) -/* - -sleep, 1000 -Loop, 5 { ; Loop to uncheck the "monetization button" - -if(A_index = 5){ - Message = Failed to uncheck "monetization enabled" checkbox - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") -} - -Xpath = //input[@name='advertising_instream_blocked'] ; monetization checkbox -try Status := driver.FindElementByXPath(Xpath).isSelected() - -if(Status = 0) ; -1 is checked, 0 is unchecked -Break - -; Click to uncheck the "allow monetization" checkbox -Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) -} - -*/ -/* -; Switch back to Basic tab -js = document.getElementsByName('basic')[0].click(); -try driver.executeScript(js) - -*/ - -Message = Clicking Next Button to Move on to third video settings screen -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - -Xpath = //button[@type='button']//span[contains(text(),'Next')] -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - - - -Message = Clicking Save Button to Finalize Upload -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - -Xpath = //span[normalize-space()='Save'] -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) -if(Status){ - Message = Upload was ALMOST successfuly. Failed to Click Final Save button - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") -} - - -; Grab the Share URL and pull out the Video Link from it and save it to the Video links ini file, so double uploads are not tried if fialure occurs -Message = Waiting 30 seconds before grabbing Video URL -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - -sleep, 30000 - - -Xpath = //ul[@data-test-id='videos-media-list']//li//div//div//div//div//h3//a -try, DailyMotionInternalURL := driver.findelementbyxpath(Xpath).Attribute("href") -if(DailyMotionInternalURL = ""){ - Message = Failed to Grab Video URL. Upload Most likely Failed. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return -} - - -; Pull out URL slug from internal video URL and create dailymotion share URL from it -DailyMotionURL := StrSplit(DailyMotionInternalURL, "/video/details/")[2] -DailyMotionURL := "https://www.dailymotion.com/video/" . DailyMotionURL +; -------------------------------BitChute------------------------------- +#Include %A_ScriptDir%\Modules\Bitchute-Upload.ahk +; -------------------------------Brighteon Upload------------------------------- +#Include %A_ScriptDir%\Modules\Brighteon-Upload.ahk -Message = Upload Complete: %DailyMotionURL% -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") -IniWrite, %DailyMotionURL%, %VideoLinksIniFile%, URLs, DailyMotionURL -SaveDriverURL() -AddToTotalVideosUploadedCount() -Return -; -------------------------------/DailyMotion------------------------------- +; -------------------------------DailyMotion------------------------------- +#Include %A_ScriptDir%\Modules\DailyMotion-Upload.ahk ; -------------------------------LBRY------------------------------- -LBRYVideoUpload: -LBRYAudioUpload: - - - -if(LBRYUploadType = "Video"){ - CurrentSite := "LBRY Video" - IniRead, LBRYPermanentURL, %VideoLinksIniFile%, Misc, LBRYVideoPermanentURL, %A_Space% - -} -if(LBRYUploadType = "Audio"){ - CurrentSite := "LBRY Audio" - IniRead, LBRYPermanentURL, %VideoLinksIniFile%, Misc, LBRYAudioPermanentURL, %A_Space% -} - -; if LBRY permanent URL was already grabbed before, exit -if(LBRYPermanentURL != "") -Return - -CheckLBRYProcess() ; double check lbry process - - -SaveOrPostProgress(Message:="Starting Upload",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - -; If LBRY Killer not found, then download it -; @todo: Add LBRY kill download functionality from gitea - -LBRYKillerPath := LibFolder . "\LBRY Process Killer.exe" -if(!FileExist(LBRYKillerPath)){ - - ; Msgbox % "LBRYKillerPath: " LBRYKillerPath - ; Msgbox % "LBRYProcessKillerURL: " LBRYProcessKillerURL - LBRYKillerPath = %A_ScriptDir%\Lib\LBRY Process Killer.exe - LBRYKillerUpdateURL = https://git.freedomainplaylists.com/attachments/7865dc8d-5aad-4f9f-8a30-94bab0192b1d - - UrlDownloadToFile, %LBRYKillerUpdateURL%, %LBRYKillerPath% - ; msgbox, work? - ; UrlDownloadToFile, URL, Filename - Message = LBRY Process Killer Not Found. Automatically Downloading. - 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") - 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 - } -} - -; Clipboard := UploadResult -; Msgbox % "UploadResult: " UploadResult - -/*if(DevMode){ - Clipboard := UploadResult - Msgbox % "UploadResult: " UploadResult -} -*/ -; Create an object out of the API Return -LBRYJSONResult := JSON.Load(UploadResult) - -if(!InStr(UploadResult, "permanent_url")){ ; if no permanent_url is generated then API issue - LBRYAPIError := LBRYJSONResult.message - ; LBRYAPIError := GetLBRYAPIErrorFromString(UploadResult) - ; if the returned string does not have "permanent_url" in it, then upload failed - Message = Upload Error (E#6930)`nVideo Upload Failed due to API Issue. Please send errorlog to Yuriy. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return -} - -if(KillLBRYAfterUpload){ - try run, %LBRYKillerPath% - catch e { - Message = LBRYKiller not found. Unable to find File. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - } -} - -; Transform the Upload Result json into the LBRY.tv link -; PermanentURL := GetPermanentLBRYURL(UploadResult) ; get permanentURL from the upload result json -LBRYPermanentURL := LBRYJSONResult.outputs[1].permanent_url -if(LBRYPermanentURL = ""){ - Message = Failed to grab permanent_url with json.ahk. Please send errorlog to Yuriy. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - Return -} - - -Message = Claim Was Successfully Submitted to lbrynet with: %LBRYPermanentURL% -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - -; Message = LBRYPermanentURL: %LBRYPermanentURL% -; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") - -if(CurrentSite = "LBRY Video"){ - IniWrite, %LBRYPermanentURL%, %VideoLinksIniFile%, Misc, LBRYVideoPermanentURL -} - -if(CurrentSite = "LBRY Audio"){ - IniWrite, %LBRYPermanentURL%, %VideoLinksIniFile%, Misc, LBRYAudioPermanentURL -} -Return - -; -------------------------------LBRY URL------------------------------- - -LBRYGetURL: -if(LBRYUploadType = "Video"){ - - CurrentSite := "LBRY Video" - ; IniWrite, %PermanentURL%, %VideoLinksIniFile%, URLs, LBRYVideoPermanentURL - IniRead, LBRYPermanentURL, %VideoLinksIniFile%, Misc, LBRYVideoPermanentURL, %A_Space% -} -if(LBRYUploadType = "Audio"){ - - CurrentSite := "LBRY Audio" - IniRead, LBRYPermanentURL, %VideoLinksIniFile%, Misc, LBRYAudioPermanentURL, %A_Space% - -} - -if(LBRYPermanentURL = ""){ - Message = Upload Skipped. LBRYPermanentURL is blank (Upload Failed due to some API issue) - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return -} - -; Message := "Waiting a couple of minutes for lbrynet blockchain to generate blockchain metadata for newest video" -Message = Waiting for LBRYNet to Generate LBRY URL -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") -; sleep, 60000 ; 1 minute -; sleep, 300000 ; sleep for 5 minutes so LBRYNet blockchain has a chance to register the new video ; as recomended by LBRY Devs -; sleep, 360000 ; sleep for 6 minutes so LBRYNet blockchain has a chance to register the new video ; LBRY devs recommend 5 mins - - -LBRYResolveAPICommand = "%LBRYNetFilepath%" resolve %LBRYPermanentURL% ; create variable with the text that's needed for the API command -Message := "LBRYResolveAPICommand: " . LBRYResolveAPICommand ; Save the result to the errorlogging file -SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") - -; msgbox - -loop, 15 { - LBRYResolveResult := StdOutToVar(LBRYResolveAPICommand) ; Save API call to a variable - - if(A_index = 1 OR a_index = 10){ - Message := "LBRYResolveResult: " . LBRYResolveResult ; Save result to the errorlogging file - SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile") - } - - if(InStr(LBRYResolveResult, "could not find claim") AND A_Index < 10) ; try 4 times to get the resolveURL, sometimes the blockchain is quite slow - { - ; @todo: Make it check every 2 minutes? - ; TooltipThis("Not Able to Grab URL from API. `nWaiting another 5 for blockchain to sync claim before trying again") - ; MessageNumber := A_index + 5 - - if(A_index < 5) - Message = Waiting for LBRYNet to Generate LBRY URL`nChecking Every 2 Minutes - if(A_index > 5) - Message = Still Waiting for LBRYNet to Generate LBRY URL`nLBRY Network is most likely congested.`nChecking Every 2 Minutes - - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - ; sleep, 300000 ; 5 minutes - sleep, 120000 ; 2 minute - - Continue - } - - if(InStr(LBRYResolveResult, "could not find claim") AND A_index = 15){ - Message = Failed to Grab URL from LBRY after 30 minutes. Either LBRY IS REALLY congested or there is a bug and the API commands were passed incorrectly. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - - if(InStr(LBRYResolveResult, "canonical_url")) - Break -} - - -if(LBRYUploadType = "Video"){ - LBRYVideoURL := GetLBRYCanonicalURL(LBRYResolveResult) ; Transform the API resulting json into the LBRY.tv link - if(LBRYVideoURL = ""){ - Message = Failed to Grab LBRY URL from LBRYNet - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - - ; DevModeMsgBox(LBRYVideoURL) - - Message = LBRYVideoURL from GetLBRYCanonicalURL: %LBRYVideoURL% - SaveOrPostProgress(Message, PostType:=",ErrorLoggingTextFile") - - OpenLBRYVideoURL := StrReplace(LBRYVideoURL, "https://lbry.tv", "https://open.lbry.com") - OpenLBRYVideoURL := StrReplace(OpenLBRYVideoURL, "#", ":") - - - OdyseeVideoURL := StrReplace(LBRYVideoURL, "https://lbry.tv", "https://odysee.com") - OdyseeVideoURL := StrReplace(OdyseeVideoURL, "#", ":") - - Message = Upload Complete: <%OpenLBRYVideoURL%> + <%OdyseeVideoURL%> - SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging") - - IniWrite, %OpenLBRYVideoURL%, %VideoLinksIniFile%, URLs, LBRYVideoURL - IniWrite, %OdyseeVideoURL%, %VideoLinksIniFile%, URLs, OdyseeVideoURL - -} -if(LBRYUploadType = "Audio"){ - LBRYAudioURL := GetLBRYCanonicalURL(LBRYResolveResult) ; Transform the API resulting json into the LBRY.tv link - if(LBRYAudioURL = ""){ - Message = Failed to Grab LBRY URL from LBRYNet - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - - Message = LBRYAudioURL from GetLBRYCanonicalURL: %LBRYAudioURL% - SaveOrPostProgress(Message, PostType:=",ErrorLoggingTextFile") - - OpenLBRYAudioURL := StrReplace(LBRYAudioURL, "https://lbry.tv", "https://open.lbry.com") - OpenLBRYAudioURL := StrReplace(OpenLBRYAudioURL, "#", ":") - - OdyseeAudioURL := StrReplace(LBRYAudioURL, "https://lbry.tv", "https://odysee.com") - OdyseeAudioURL := StrReplace(OdyseeAudioURL, "#", ":") - - Message = Upload Complete: <%OpenLBRYAudioURL%> + <%OdyseeAudioURL%> - SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging") - - IniWrite, %OpenLBRYAudioURL%, %VideoLinksIniFile%, URLs, LBRYAudioURL - IniWrite, %OdyseeAudioURL%, %VideoLinksIniFile%, URLs, OdyseeAudioURL -} - - -; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") -; SaveDriverURL() -AddToTotalVideosUploadedCount() -Return -; -------------------------------/LBRY Video------------------------------- - - - +#Include %A_ScriptDir%\Modules\LBRY-Upload.ahk ; -------------------------------Rumble------------------------------- diff --git a/Modules/Bitchute-Upload.ahk b/Modules/Bitchute-Upload.ahk new file mode 100644 index 0000000..f716874 --- /dev/null +++ b/Modules/Bitchute-Upload.ahk @@ -0,0 +1,313 @@ +BitChuteUpload: +;------------------------------------------------ +CurrentSite := "Bitchute" + +Message = Starting Upload +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + +Status := NavigateFromBaseURLTo("https://www.bitchute.com/myupload", "BitChute Video Uploader") +if(Status) +Return + +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 + 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, check if input and if not, try again +loop, 5 { + status := js_SendAndCheckWithQuerySelector(Selector:="#title",ValueToCheck:="value",SleepLength:=1000,JSStringText:=VideoTitle) + ; Msgbox % "status: " status + + if(!Status) + break +} + + +if(Status){ + Message = Failed to input Video Title with Javascript. Trying again with Manual Typing + SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging") + + Xpath = //input[@id='title'] + Status := Selenium_TypeTextIntoElement(VideoTitle, Xpath) + if(Status){ + Message = Failed to Input Video Title after trying two different ways. Please try Upload again and double check that the website hasn't been updated in a major way. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar, DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + try, TextInputted := driver.findelementbyxpath(Xpath).Attribute("value") ;XPath: ID=site-title & span tag + if(InStr(VideoTitle, TextInputted) OR VideoTitle = TextInputted){ + ; Title got input successfully + } + else, { + Message = Title that got input into Bitchute: %TextInputted% + SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging") + + Message = Failed to Input Video Title after trying two different ways. Please try Upload again and double check that the website hasn't been updated in a major way. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar, DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } +} + + + +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") + + + 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 + } + + + 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 +} + + +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 . " " +} + +; 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") + +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='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 + + try BitChuteUploadProgress := driver.executeScript("return document.querySelector('.filepond--file-status').innerHTML;") ;navigate using javascript + ; Msgbox % "BitChuteUploadProgress: " BitChuteUploadProgress + + 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 + + } + + ; split_text = "> + ; Pull out upload percentage + 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) + } +} + + + + +Message = Checking Login Status +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") +try CurrentTab := driver.url +if(InStr(CurrentTab, "login")) ; we're logged out +{ + + Message = Currently Logged Out`nClosing out of any popups that might appear before clicking Login button + 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) + + 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 PageURL := driver.url + if(InStr(PageURL, "auth.brighteon.com/login?state")){ ; we're logged out and need to manually log back in + + + 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) + + ; 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 + ; } + + + } + else, { + SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + } +} + + + +Message = Navigating to Upload Page +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +; Navigate to Upload Page +try driver.executeScript("window.location = 'https://www.brighteon.com/dashboard/video-upload'") ;navigate using javascript + +try driver.executeScript("return document.readyState").equals("complete") + +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() + + +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 +} + + +loop, 3 { + if(A_index = 3){ + Message = Failed to input Video Title + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + 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 + + ; 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) + + Message = Title that got input: %status% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + break + +} + + +TooltipThis("Inputting Video Description") + + + +; 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) + + 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") + + ; driver.FindElementByXPath(Xpath).SendKeys(VideoDescription) + + ; 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, 5000 + + + js = return document.querySelector("div[class='e-content e-lib e-keyboard'] p").innerText; + try Input_Description := driver.executeScript(JS) ;Execute Javascript + + Input_DescriptionStrLen := StrLen(Input_Description) + Message = Length of Description that got input: %Input_DescriptionStrLen% + SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging") + + ; if text in description box is longer than x chars, then description input worked + if(StrLen(Input_Description) > 15){ + Input_Description := SubStr(Input_Description, 1, 20) + Message = Description that got input: %Input_Description% ... + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + Break + } + +} + + + +; Thumbnail +if(VideoThumbFilepath != "") { + TooltipThis("Uploading Thumbnail") + Xpath = //input[@type='file'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoThumbFilepath) + if(Status){ + Message = Failed to Upload Thumbnail + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + } +} + + +; DevModeMsgBox(VideoTags) +TooltipThis("Inputting Keywords") +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") + } + + ; click into video title to get focus away from inputbox + Xpath = /html/body/div/section[2]/div[2]/div/form/div[1]/div[1]/div[2]/div[1]/div/input + try, driver.FindElementByXPath(Xpath).click() ;Sends Variable to an Xpath Item + + ; check that the tags got input + js = return document.querySelector("#keywords").value; + try, status := driver.executeScript(js) + if(!status){ + Message = Failed to input tags. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + } + else, { + Message = Tags that got input: %status% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + break + } + ; Msgbox % "status: " status + + +} + +; double check on video description after inputting tags +js = return document.querySelector("div[class='e-content e-lib e-keyboard'] p").innerText; +try Input_Description := driver.executeScript(JS) ;Execute Javascript + +; if text in description box is longer than x chars, then description input worked +if(StrLen(Input_Description) > 5){ + SaveOrPostProgress(Message:="Video Description second double check was successful",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +} +else, { + SaveOrPostProgress(Message:="Secondary video description check failed",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} + + + +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) + + 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 + } + + ; 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") + + Status := Check_For_Stuck_Video_Upload(A_index, UploadPercent) + if(Status = "Failed") + Return +} + + +; "Save Now" button +js = return document.querySelector("button[class='mr-2 btn btn-primary btn-sm']").textContent; +try, status := driver.executeScript(js) +if(!InStr(status, "Save Video")){ + Message = Save Video Button is not clickable. Please check page for errors. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + + +; Save Video button +TooltipThis("Clicking Save Video Button to finalize Upload") +try BrighteonUploadPageURL := driver.url +try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding + + +TooltipThis("Waiting for Result page to finish loading") +Loop, 10 { ; 5 loops of 1 minute each + if(A_index = 10){ + Message = Upload Failed: Clicking "Save Video" did not Finalize the Upload + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return ; Break out of gosub + } + js = document.getElementsByClassName('mr-2 btn btn-primary btn-sm')[0].click(); ; Save Video Button + try driver.executeScript(js) + driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding + + sleep, 5000 ; 30 seconds + try CurrentURL := driver.url + if(BrighteonUploadPageURL != CurrentURL) + Break +} + + +Message = Trying to Grab Newest Video's URL +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") +sleep, 2000 + +; 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 + + +; 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] +} + + +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 + + jsCheck = return document.getElementsByClassName('col')[%ElementIndexNumber%].outerHTML; + try BrighteonURL := driver.executeScript(jsCheck) + + jsCheck = return document.getElementsByClassName('col')[%ElementIndexNumber%].textContent; + try InnerText := driver.executeScript(jsCheck) + + ; Message = Loop Number: %ElementIndexNumber% element's Text Content: %innerText%`nBrighteonURL: %BrighteonURL% + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + ; Message = InnerText: %InnerText% + ; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") + ; DevModeMsgBox(InnerText) + + ; Message = BrighteonURL: %BrighteonURL% + ; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") + + + + ; Msgbox % "VideoTitleLongWord: " VideoTitleLongWord "`nInnerText: " InnerText + ; clipboard := Message + ; msgbox % Message + ; Msgbox % "InnerText: " InnerText . "`n" . "BrighteonURL: " . BrighteonURL + + 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") + + BrighteonURL := StrSplit(BrighteonURL, "/dashboard/videos/") + BrighteonURL := BrighteonURL[2] + BrighteonURL := StrSplit(BrighteonURL, "> 2900){ + DailyMotionDescription := SubStr(VideoDescription, 1, 2900) . "..." +} +else, +DailyMotionDescription := VideoDescription + + +DailyMotionJSDescription := FormatTextToJSText(DailyMotionDescription) + +Message := "DailyMotionJSDescription String Length: " . StrLen(DailyMotionJSDescription) +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + +Message = Inputting Video Description +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") +Loop, 5 { ; make a couple attempts to input description + if(A_index = 5){ + Message = Failed to input Description after %A_index% attempts. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + + ; click into element + Xpath = //textarea[@placeholder='Enter a description'] + try driver.FindElementByXPath(Xpath).click() + + ; send a space and then backspace so element registers the input + Xpath = //textarea[@placeholder='Enter a description'] + try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.SPACE) + try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.BackSpace) + + + ; inut description with javascript + js = document.querySelector("textarea[placeholder='Enter a description']").value = "%JSVideoDescription%"; + try driver.executeScript(js) + + ; send a space and then backspace so element registers the input + Xpath = //textarea[@placeholder='Enter a description'] + try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.SPACE) + try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.BackSpace) + + sleep, 1000 + + js = return document.querySelector("textarea[placeholder='Enter a description']").textContent; + try, InputDescription := driver.executeScript(js) + + message = InputDescription: %InputDescription% + DevModeMsgBox(InputDescription) + + ; if input description is less than 15 chars, try again + if(StrLen(InputDescription) < 15) + Continue + else, + Break + +} + + + +; Make a couple attempts to Click on Drop down menu and select the "Education" Category +Message = Selecting Education Category +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + +Loop, 3 { + if(A_index = 3){ + Message = Failed to Select Education Category after %A_index% attempts + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + Xpath = //div[@name='channel'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + + js = document.querySelector("div[title='Education'] div[class='ant-select-item-option-content']").click() + try status := driver.executeScript(js) + + js = return document.querySelector("div[name='channel']").textContent; + try, status := driver.executeScript(js) + + if(instr(status, "Education")) + break + +} + + +Message = Inputting Tags +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + +; Append comma to end of tags +; DailyMotion page automtically splits the tags into their little boxes when they're seperated by commas +DailyMotionVideoTags := VideoTags . "," + +Message = Video Tags: %DailyMotionVideoTags% +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + +Xpath = //div[@class='ant-select-selection-search']//input[@role='combobox'] +Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=DailyMotionVideoTags) + +; double check the input +js = return document.querySelector("div[name='tags']").textContent; +try, inputTags := driver.executeScript(js) +Message = Tags that got input: %inputTags% (Will be doubled b/c of js) +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + +; msgbox +Message = Clicking Next Button to Move on to next input screen +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + +Xpath = //button[@type='button']//span[contains(text(),'Next')] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + +; msgbox, click work? + +Message = Selecting "Not For Kids" checkbox +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + +try driver.findElementsByName("is_created_for_kids").item[2].click() +catch e { + sleep, 2000 + try driver.findElementsByName("is_created_for_kids").item[2].click() + catch e { + Message = Failed to Click on the "Not Made For Kids" checkbox. Please switch to tab and finalize upload. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } +} + + +/* +; Disable monitization for video +SaveOrPostProgress(Message:="Unchecking monetizaton checkbox",PostType:="Tooltip,ErrorLoggingTextFile") +Xpath = //button[normalize-space()='Advanced'] ; advanced tab button +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) +if(Status = "Failed"){ + Message = Unable to Navigate to Advanced Settings Page to turn off monetization + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") +} + + +*/ +; SaveOrPostProgress(Message:="Unchecking monetizaton checkbox",PostType:="Tooltip,ErrorLoggingTextFile") + +; switch over to advanced tab +; js = document.getElementsByName('advanced')[0].click(); +; try driver.executeScript(js) +/* + +sleep, 1000 +Loop, 5 { ; Loop to uncheck the "monetization button" + +if(A_index = 5){ + Message = Failed to uncheck "monetization enabled" checkbox + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +} + +Xpath = //input[@name='advertising_instream_blocked'] ; monetization checkbox +try Status := driver.FindElementByXPath(Xpath).isSelected() + +if(Status = 0) ; -1 is checked, 0 is unchecked +Break + +; Click to uncheck the "allow monetization" checkbox +Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) +} + +*/ +/* +; Switch back to Basic tab +js = document.getElementsByName('basic')[0].click(); +try driver.executeScript(js) + +*/ + +Message = Clicking Next Button to Move on to third video settings screen +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + +Xpath = //button[@type='button']//span[contains(text(),'Next')] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + + + +Message = Clicking Save Button to Finalize Upload +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + +Xpath = //span[normalize-space()='Save'] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) +if(Status){ + Message = Upload was ALMOST successfuly. Failed to Click Final Save button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") +} + + +; Grab the Share URL and pull out the Video Link from it and save it to the Video links ini file, so double uploads are not tried if fialure occurs +Message = Waiting 30 seconds before grabbing Video URL +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +sleep, 30000 + + +Xpath = //ul[@data-test-id='videos-media-list']//li//div//div//div//div//h3//a +try, DailyMotionInternalURL := driver.findelementbyxpath(Xpath).Attribute("href") +if(DailyMotionInternalURL = ""){ + Message = Failed to Grab Video URL. Upload Most likely Failed. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + + +; Pull out URL slug from internal video URL and create dailymotion share URL from it +DailyMotionURL := StrSplit(DailyMotionInternalURL, "/video/details/")[2] +DailyMotionURL := "https://www.dailymotion.com/video/" . DailyMotionURL + + +Message = Upload Complete: %DailyMotionURL% +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +IniWrite, %DailyMotionURL%, %VideoLinksIniFile%, URLs, DailyMotionURL +SaveDriverURL() +AddToTotalVideosUploadedCount() + +Return \ No newline at end of file diff --git a/Modules/LBRY-Upload.ahk b/Modules/LBRY-Upload.ahk new file mode 100644 index 0000000..8b2b93c --- /dev/null +++ b/Modules/LBRY-Upload.ahk @@ -0,0 +1,363 @@ +LBRYVideoUpload: +LBRYAudioUpload: +;------------------------------------------------ + +if(LBRYUploadType = "Video"){ + CurrentSite := "LBRY Video" + IniRead, LBRYPermanentURL, %VideoLinksIniFile%, Misc, LBRYVideoPermanentURL, %A_Space% + +} +if(LBRYUploadType = "Audio"){ + CurrentSite := "LBRY Audio" + IniRead, LBRYPermanentURL, %VideoLinksIniFile%, Misc, LBRYAudioPermanentURL, %A_Space% +} + +; if LBRY permanent URL was already grabbed before, exit +if(LBRYPermanentURL != "") +Return + +CheckLBRYProcess() ; double check lbry process + + +SaveOrPostProgress(Message:="Starting Upload",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + +; If LBRY Killer not found, then download it +; @todo: Add LBRY kill download functionality from gitea + +LBRYKillerPath := LibFolder . "\LBRY Process Killer.exe" +if(!FileExist(LBRYKillerPath)){ + + ; Msgbox % "LBRYKillerPath: " LBRYKillerPath + ; Msgbox % "LBRYProcessKillerURL: " LBRYProcessKillerURL + LBRYKillerPath = %A_ScriptDir%\Lib\LBRY Process Killer.exe + LBRYKillerUpdateURL = https://git.freedomainplaylists.com/attachments/7865dc8d-5aad-4f9f-8a30-94bab0192b1d + + UrlDownloadToFile, %LBRYKillerUpdateURL%, %LBRYKillerPath% + ; msgbox, work? + ; UrlDownloadToFile, URL, Filename + Message = LBRY Process Killer Not Found. Automatically Downloading. + 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") + 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 + } +} + +; Clipboard := UploadResult +; Msgbox % "UploadResult: " UploadResult + +/*if(DevMode){ + Clipboard := UploadResult + Msgbox % "UploadResult: " UploadResult +} +*/ +; Create an object out of the API Return +LBRYJSONResult := JSON.Load(UploadResult) + +if(!InStr(UploadResult, "permanent_url")){ ; if no permanent_url is generated then API issue + LBRYAPIError := LBRYJSONResult.message + ; LBRYAPIError := GetLBRYAPIErrorFromString(UploadResult) + ; if the returned string does not have "permanent_url" in it, then upload failed + Message = Upload Error (E#6930)`nVideo Upload Failed due to API Issue. Please send errorlog to Yuriy. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} + +if(KillLBRYAfterUpload){ + try run, %LBRYKillerPath% + catch e { + Message = LBRYKiller not found. Unable to find File. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + } +} + +; Transform the Upload Result json into the LBRY.tv link +; PermanentURL := GetPermanentLBRYURL(UploadResult) ; get permanentURL from the upload result json +LBRYPermanentURL := LBRYJSONResult.outputs[1].permanent_url +if(LBRYPermanentURL = ""){ + Message = Failed to grab permanent_url with json.ahk. Please send errorlog to Yuriy. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + Return +} + + +Message = Claim Was Successfully Submitted to lbrynet with: %LBRYPermanentURL% +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + +; Message = LBRYPermanentURL: %LBRYPermanentURL% +; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") + +if(CurrentSite = "LBRY Video"){ + IniWrite, %LBRYPermanentURL%, %VideoLinksIniFile%, Misc, LBRYVideoPermanentURL +} + +if(CurrentSite = "LBRY Audio"){ + IniWrite, %LBRYPermanentURL%, %VideoLinksIniFile%, Misc, LBRYAudioPermanentURL +} +Return + + + + +LBRYGetURL: +;------------------------------------------------ +if(LBRYUploadType = "Video"){ + + CurrentSite := "LBRY Video" + ; IniWrite, %PermanentURL%, %VideoLinksIniFile%, URLs, LBRYVideoPermanentURL + IniRead, LBRYPermanentURL, %VideoLinksIniFile%, Misc, LBRYVideoPermanentURL, %A_Space% +} +if(LBRYUploadType = "Audio"){ + + CurrentSite := "LBRY Audio" + IniRead, LBRYPermanentURL, %VideoLinksIniFile%, Misc, LBRYAudioPermanentURL, %A_Space% + +} + +if(LBRYPermanentURL = ""){ + Message = Upload Skipped. LBRYPermanentURL is blank (Upload Failed due to some API issue) + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} + +; Message := "Waiting a couple of minutes for lbrynet blockchain to generate blockchain metadata for newest video" +Message = Waiting for LBRYNet to Generate LBRY URL +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") +; sleep, 60000 ; 1 minute +; sleep, 300000 ; sleep for 5 minutes so LBRYNet blockchain has a chance to register the new video ; as recomended by LBRY Devs +; sleep, 360000 ; sleep for 6 minutes so LBRYNet blockchain has a chance to register the new video ; LBRY devs recommend 5 mins + + +LBRYResolveAPICommand = "%LBRYNetFilepath%" resolve %LBRYPermanentURL% ; create variable with the text that's needed for the API command +Message := "LBRYResolveAPICommand: " . LBRYResolveAPICommand ; Save the result to the errorlogging file +SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") + +; msgbox + +loop, 15 { + LBRYResolveResult := StdOutToVar(LBRYResolveAPICommand) ; Save API call to a variable + + if(A_index = 1 OR a_index = 10){ + Message := "LBRYResolveResult: " . LBRYResolveResult ; Save result to the errorlogging file + SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile") + } + + if(InStr(LBRYResolveResult, "could not find claim") AND A_Index < 10) ; try 4 times to get the resolveURL, sometimes the blockchain is quite slow + { + ; @todo: Make it check every 2 minutes? + ; TooltipThis("Not Able to Grab URL from API. `nWaiting another 5 for blockchain to sync claim before trying again") + ; MessageNumber := A_index + 5 + + if(A_index < 5) + Message = Waiting for LBRYNet to Generate LBRY URL`nChecking Every 2 Minutes + if(A_index > 5) + Message = Still Waiting for LBRYNet to Generate LBRY URL`nLBRY Network is most likely congested.`nChecking Every 2 Minutes + + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + ; sleep, 300000 ; 5 minutes + sleep, 120000 ; 2 minute + + Continue + } + + if(InStr(LBRYResolveResult, "could not find claim") AND A_index = 15){ + Message = Failed to Grab URL from LBRY after 30 minutes. Either LBRY IS REALLY congested or there is a bug and the API commands were passed incorrectly. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + if(InStr(LBRYResolveResult, "canonical_url")) + Break +} + + +if(LBRYUploadType = "Video"){ + LBRYVideoURL := GetLBRYCanonicalURL(LBRYResolveResult) ; Transform the API resulting json into the LBRY.tv link + if(LBRYVideoURL = ""){ + Message = Failed to Grab LBRY URL from LBRYNet + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + ; DevModeMsgBox(LBRYVideoURL) + + Message = LBRYVideoURL from GetLBRYCanonicalURL: %LBRYVideoURL% + SaveOrPostProgress(Message, PostType:=",ErrorLoggingTextFile") + + OpenLBRYVideoURL := StrReplace(LBRYVideoURL, "https://lbry.tv", "https://open.lbry.com") + OpenLBRYVideoURL := StrReplace(OpenLBRYVideoURL, "#", ":") + + + OdyseeVideoURL := StrReplace(LBRYVideoURL, "https://lbry.tv", "https://odysee.com") + OdyseeVideoURL := StrReplace(OdyseeVideoURL, "#", ":") + + Message = Upload Complete: <%OpenLBRYVideoURL%> + <%OdyseeVideoURL%> + SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging") + + IniWrite, %OpenLBRYVideoURL%, %VideoLinksIniFile%, URLs, LBRYVideoURL + IniWrite, %OdyseeVideoURL%, %VideoLinksIniFile%, URLs, OdyseeVideoURL + +} +if(LBRYUploadType = "Audio"){ + LBRYAudioURL := GetLBRYCanonicalURL(LBRYResolveResult) ; Transform the API resulting json into the LBRY.tv link + if(LBRYAudioURL = ""){ + Message = Failed to Grab LBRY URL from LBRYNet + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + Message = LBRYAudioURL from GetLBRYCanonicalURL: %LBRYAudioURL% + SaveOrPostProgress(Message, PostType:=",ErrorLoggingTextFile") + + OpenLBRYAudioURL := StrReplace(LBRYAudioURL, "https://lbry.tv", "https://open.lbry.com") + OpenLBRYAudioURL := StrReplace(OpenLBRYAudioURL, "#", ":") + + OdyseeAudioURL := StrReplace(LBRYAudioURL, "https://lbry.tv", "https://odysee.com") + OdyseeAudioURL := StrReplace(OdyseeAudioURL, "#", ":") + + Message = Upload Complete: <%OpenLBRYAudioURL%> + <%OdyseeAudioURL%> + SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging") + + IniWrite, %OpenLBRYAudioURL%, %VideoLinksIniFile%, URLs, LBRYAudioURL + IniWrite, %OdyseeAudioURL%, %VideoLinksIniFile%, URLs, OdyseeAudioURL +} + + +; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +; SaveDriverURL() +AddToTotalVideosUploadedCount() +Return \ No newline at end of file