reworked Bitchute title and description input to use js

pull/2/head
Yuriy 2 years ago
parent 468e6afdb6
commit 83f10976d6

@ -3008,38 +3008,16 @@ Loop, %Number_of_loops_to_Check_Upload_status% {
Return Return
} }
; LogErrorToTextFile("Inputting Description")
status := js_SendAndCheckWithQuerySelector("#description",ValueToCheck:="value",SleepLength:=1000,JSStringText:=JSBitchuteDescription)
; Input text if(status){
; try BitChuteUploadProgress := driver.executeScript("return document.getElementsByClassName('progress-bar')[0].innerHTML;") ;navigate using javascript Message = %status%
; send text to page
; jsSend = document.getElementsByClassName('form-control')[1].value = "%JSBitchuteDescription%";
jsSend = document.getElementById('description').value = "%JSBitchuteDescription%";
; try driver.executeScript(js)
; Check text in the box
jsCheck = return document.getElementById('description').value;
; send text to the page
try driver.executeScript(jsSend)
; check contents of page
try VideoDescriptionOnPage := driver.executeScript(jsCheck) ;Executes a Javascript on the webpage, mostly used for buttons.
if(StrLen(VideoDescription) > 5){
Message = Video Description input successfully
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
break
} }
else,
Break
; if (A_index = 1){ sleep, 1000
; message := SubStr(VideoDescriptionOnPage, 1, 250)
; message = Description that got input: %message%
; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,DiscordErrorLogging")
; }
} }
@ -3198,6 +3176,7 @@ Loop, %Number_of_loops_to_Check_Upload_status% {
} }
BitChuteURL := "https://www.bitchute.com/" . VideoHref BitChuteURL := "https://www.bitchute.com/" . VideoHref
BitChuteURL := StrReplace(BitchuteURL, "//video", "/")
; navigate to video page ; navigate to video page
try driver.Get(BitChuteURL) ;Open selected URL try driver.Get(BitChuteURL) ;Open selected URL
@ -3335,31 +3314,31 @@ Loop, %Number_of_loops_to_Check_Upload_status% {
Return Return
} }
} }
} }
; Navigate to Upload Page ; Navigate to Upload Page
try driver.executeScript("window.location = 'https://www.brighteon.com/dashboard/video-upload'") ;navigate using javascript try driver.executeScript("window.location = 'https://www.brighteon.com/dashboard/video-upload'") ;navigate using javascript
try driver.executeScript("return document.readyState").equals("complete") try driver.executeScript("return document.readyState").equals("complete")
; Click out of the "Support free speech" pop-up if it pops up ; 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'] Xpath = //body/div[@id='__next']/div[@id='modal-root']/div/div/div[1]//*[local-name()='svg']
try driver.FindElementByXPath(Xpath).click() try driver.FindElementByXPath(Xpath).click()
; Upload Video ; Upload Video
Xpath = //input[@type='file'] Xpath = //input[@type='file']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoFilepath) Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoFilepath)
if(Status){ if(Status){
Message = Failed to Upload Video, Please check Login Status Message = Failed to Upload Video, Please check Login Status
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage() SaveDriverURLOFErrorPage()
Return Return
} }
loop, 3 { loop, 3 {
if(A_index = 3){ if(A_index = 3){
Message = Failed to input Video Title Message = Failed to input Video Title
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
@ -3384,16 +3363,16 @@ Loop, %Number_of_loops_to_Check_Upload_status% {
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
break break
} }
; Msgbox % "status: " status ; Msgbox % "status: " status
TooltipThis("Inputting Video Description") TooltipThis("Inputting Video Description")
; Attempt to input video description a couple of times ; Attempt to input video description a couple of times
Loop, 10 { Loop, 10 {
Message = Inputting Description. `nAttempt Number: %A_index% Message = Inputting Description. `nAttempt Number: %A_index%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; SaveOrPostProgress(Message:=Message,PostType:="DiscordErrorLogging") ; SaveOrPostProgress(Message:=Message,PostType:="DiscordErrorLogging")
@ -3440,12 +3419,12 @@ Loop, %Number_of_loops_to_Check_Upload_status% {
Break Break
} }
} }
; Thumbnail ; Thumbnail
if(VideoThumbFilepath != "") { if(VideoThumbFilepath != "") {
TooltipThis("Uploading Thumbnail") TooltipThis("Uploading Thumbnail")
Xpath = //input[@type='file'] Xpath = //input[@type='file']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoThumbFilepath) Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoThumbFilepath)
@ -3453,12 +3432,12 @@ Loop, %Number_of_loops_to_Check_Upload_status% {
Message = Failed to Upload Thumbnail Message = Failed to Upload Thumbnail
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
} }
} }
; DevModeMsgBox(VideoTags) ; DevModeMsgBox(VideoTags)
TooltipThis("Inputting Keywords") TooltipThis("Inputting Keywords")
Loop, 5 { Loop, 5 {
XPath = //input[@id='keywords'] XPath = //input[@id='keywords']
try driver.FindElementByXPath(Xpath).SendKeys(VideoTags) ;Sends Variable to an Xpath Item try driver.FindElementByXPath(Xpath).SendKeys(VideoTags) ;Sends Variable to an Xpath Item
catch e { catch e {
@ -3485,26 +3464,26 @@ Loop, %Number_of_loops_to_Check_Upload_status% {
; Msgbox % "status: " status ; Msgbox % "status: " status
} }
; double check on video description after inputting tags ; double check on video description after inputting tags
js = return document.querySelector("div[class='e-content e-lib e-keyboard'] p").innerText; js = return document.querySelector("div[class='e-content e-lib e-keyboard'] p").innerText;
try Input_Description := driver.executeScript(JS) ;Execute Javascript try Input_Description := driver.executeScript(JS) ;Execute Javascript
DevModeMsgBox(Input_Description) DevModeMsgBox(Input_Description)
; if text in description box is longer than x chars, then description input worked ; if text in description box is longer than x chars, then description input worked
if(StrLen(Input_Description) > 5){ if(StrLen(Input_Description) > 5){
SaveOrPostProgress(Message:="Video Description second double check was successful",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") SaveOrPostProgress(Message:="Video Description second double check was successful",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
} }
else, { else, {
SaveOrPostProgress(Message:="Secondary video description check failed",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:="Secondary video description check failed",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return Return
} }
TooltipThis("Waiting for Video to Finish Uploading") TooltipThis("Waiting for Video to Finish Uploading")
Loop, %Number_of_loops_to_Check_Upload_status% { Loop, %Number_of_loops_to_Check_Upload_status% {
sleep, %Time_Between_Loops_Upload_Status% sleep, %Time_Between_Loops_Upload_Status%
; Get progress status through javascript ; Get progress status through javascript
@ -3534,16 +3513,16 @@ Loop, %Number_of_loops_to_Check_Upload_status% {
Status := Check_For_Stuck_Video_Upload(A_index, UploadPercent) Status := Check_For_Stuck_Video_Upload(A_index, UploadPercent)
if(Status = "Failed") if(Status = "Failed")
Return Return
} }
; Save Video button ; Save Video button
TooltipThis("Clicking Save Video Button to finalize Upload") TooltipThis("Clicking Save Video Button to finalize Upload")
try BrighteonUploadPageURL := driver.url try BrighteonUploadPageURL := driver.url
try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
TooltipThis("Waiting for Result page to finish loading") TooltipThis("Waiting for Result page to finish loading")
Loop, 60 { ; 5 loops of 1 minute each Loop, 60 { ; 5 loops of 1 minute each
if(A_index = 10){ if(A_index = 10){
Message = Upload Failed: Clicking "Save Video" did not Finalize the Upload Message = Upload Failed: Clicking "Save Video" did not Finalize the Upload
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
@ -3558,39 +3537,39 @@ Loop, %Number_of_loops_to_Check_Upload_status% {
try CurrentURL := driver.url try CurrentURL := driver.url
if(BrighteonUploadPageURL != CurrentURL) if(BrighteonUploadPageURL != CurrentURL)
Break Break
} }
Message = Trying to Grab Uploaded Video URL Message = Trying to Grab Uploaded Video URL
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
; Message = Waiting 60 Seconds Before Checking Results Page for URL ; Message = Waiting 60 Seconds Before Checking Results Page for URL
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
; Navigate to Videos page and loop through the videos and grab the URL of the latest upload ; 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.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 try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
; Get First word in video title to use in grabbing video URL ; Get First word in video title to use in grabbing video URL
VideoTitleArray := StrSplit(VideoTitle, " ") VideoTitleArray := StrSplit(VideoTitle, " ")
; Iterate from 1 to the end of the array: ; Iterate from 1 to the end of the array:
Loop % VideoTitleArray.Length(){ Loop % VideoTitleArray.Length(){
VideoTitleLongWord := VideoTitleArray[A_Index] VideoTitleLongWord := VideoTitleArray[A_Index]
; VideoTitleFirstWord := StrReplace(VideoTitleFirstWord, "_","-") ; VideoTitleFirstWord := StrReplace(VideoTitleFirstWord, "_","-")
if(StrLen(VideoTitleLongWord) > 4) if(StrLen(VideoTitleLongWord) > 4)
Break Break
; MsgBox % VideoTitleArray[A_Index] ; MsgBox % VideoTitleArray[A_Index]
} }
Message = VideoTitleLongWord: %VideoTitleLongWord% Message = VideoTitleLongWord: %VideoTitleLongWord%
SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile")
Loop, 4 { Loop, 4 {
ElementIndexNumber := A_index + 1 ElementIndexNumber := A_index + 1
jsCheck = return document.getElementsByClassName('col')[%ElementIndexNumber%].outerHTML; jsCheck = return document.getElementsByClassName('col')[%ElementIndexNumber%].outerHTML;
@ -3623,62 +3602,62 @@ Loop, %Number_of_loops_to_Check_Upload_status% {
} }
BrighteonURL := BrighteonURL :=
} }
; Convert dashboard URL to Public URL ; Convert dashboard URL to Public URL
; BrighteonURL := StrReplace(BrighteonURL, "dashboard/videos/", "") ; BrighteonURL := StrReplace(BrighteonURL, "dashboard/videos/", "")
if(BrighteonURL = ""){ if(BrighteonURL = ""){
Message = Upload Completed Successfully but failed to grab Share URL. Please Copy and Paste it in. Message = Upload Completed Successfully but failed to grab Share URL. Please Copy and Paste it in.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage() SaveDriverURLOFErrorPage()
Return Return
} }
Message = Upload Complete:`n%BrighteonURL% Message = Upload Complete:`n%BrighteonURL%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
IniWrite, %BrighteonURL%, %VideoLinksIniFile%, URLs, BrighteonURL IniWrite, %BrighteonURL%, %VideoLinksIniFile%, URLs, BrighteonURL
SaveDriverURL() SaveDriverURL()
AddToTotalVideosUploadedCount() AddToTotalVideosUploadedCount()
; TakeScreenshotOfPage(ScreenShotSavePath) ; TakeScreenshotOfPage(ScreenShotSavePath)
Return Return
; -------------------------------/Brighteon Upload------------------------------- ; -------------------------------/Brighteon Upload-------------------------------
; -------------------------------DailyMotion------------------------------- ; -------------------------------DailyMotion-------------------------------
DailyMotionUpload: DailyMotionUpload:
CurrentSite := "DailyMotion" CurrentSite := "DailyMotion"
SaveOrPostProgress(Message:="Starting Upload",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") SaveOrPostProgress(Message:="Starting Upload",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
IniRead, DailyMotionParnerUploadPage, %SettingsIniFilepath%, General, DailyMotionPostPageURL, %A_Space% IniRead, DailyMotionParnerUploadPage, %SettingsIniFilepath%, General, DailyMotionPostPageURL, %A_Space%
if(DailyMotionParnerUploadPage = ""){ if(DailyMotionParnerUploadPage = ""){
Message = Please add your DailyMotion Upload URL to settings.ini file under:`n`n[General]`nDailyMotionParnerUploadPage=https://www.dailymotion.com/partner/[YOURIDNUMBER]/media/video/upload Message = Please add your DailyMotion Upload URL to settings.ini file under:`n`n[General]`nDailyMotionParnerUploadPage=https://www.dailymotion.com/partner/[YOURIDNUMBER]/media/video/upload
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return Return
} }
Status := NavigateFromBaseURLTo(DailyMotionParnerUploadPage,"Partner HQ - Dailymotion") Status := NavigateFromBaseURLTo(DailyMotionParnerUploadPage,"Partner HQ - Dailymotion")
if(Status) if(Status)
Return Return
Message = Waiting for Page to Finish Fully Loading Message = Waiting for Page to Finish Fully Loading
SaveOrPostProgress(Message:=Message,PostType:="Tooltip") SaveOrPostProgress(Message:=Message,PostType:="Tooltip")
try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
sleep, 1500 sleep, 1500
Message = Uploading Video Message = Uploading Video
SaveOrPostProgress(Message:=Message,PostType:="Tooltip") SaveOrPostProgress(Message:=Message,PostType:="Tooltip")
Xpath = //input[@type='file'] Xpath = //input[@type='file']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=2000,StringTextContent:=VideoFilepath) Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=2000,StringTextContent:=VideoFilepath)
if(Status){ if(Status){
; DevModeMsgBox(Status) ; DevModeMsgBox(Status)
Message = Trying to Log Back In Message = Trying to Log Back In
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
@ -3689,25 +3668,25 @@ Loop, %Number_of_loops_to_Check_Upload_status% {
; Upload file again ; Upload file again
Xpath = //input[@type='file'] Xpath = //input[@type='file']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=2000,StringTextContent:=VideoFilepath) Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=2000,StringTextContent:=VideoFilepath)
} }
; DevModeMsgBox("test") ; DevModeMsgBox("test")
sleep, 2000 sleep, 2000
; Click on Upload Thumbnail Button ; Click on Upload Thumbnail Button
TooltipThis("Uploading Thumbnail") TooltipThis("Uploading Thumbnail")
Xpath = //input[@type='file'] Xpath = //input[@type='file']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoThumbFilepath) Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=VideoThumbFilepath)
if(Status){ if(Status){
Message = Failed to Upload Thumbnail: Check Login Status Message = Failed to Upload Thumbnail: Check Login Status
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
} }
Message = Inputting Video Details Message = Inputting Video Details
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
; @todo: uncomment this and replace the selenium funciton ; @todo: uncomment this and replace the selenium funciton
; Clear video title that is input automatically and input the real title ; Clear video title that is input automatically and input the real title
/*Msgbox % "JSVideoTitle: " JSVideoTitle /*Msgbox % "JSVideoTitle: " JSVideoTitle
js_SendAndCheckWithNAME(Element:="title",ClassIndexNum:=0,ValueToCheck:="value",SleepLength:=1000,JSStringText:=JSVideoTitle) js_SendAndCheckWithNAME(Element:="title",ClassIndexNum:=0,ValueToCheck:="value",SleepLength:=1000,JSStringText:=JSVideoTitle)
Msgbox % "Status: " Status Msgbox % "Status: " Status
@ -5244,9 +5223,8 @@ Return
; Included Files ; Included Files
#include %A_ScriptDir%\Lib\StdOutToVar.ahk ; used for chrome debugging mode connection #include %A_ScriptDir%\Lib\StdOutToVar.ahk ; used for chrome debugging mode connection
#Include %A_ScriptDir%\Lib\SharedFunctions.ahk #Include %A_ScriptDir%\Lib\\Freedomain-Posters-Shared-Functions\Freedomain-Posters-Shared-Functions.ahk
#Include %A_ScriptDir%\Lib\JSON.ahk #Include %A_ScriptDir%\Lib\JSON.ahk
#Include %A_ScriptDir%\Lib\ChromeAutomationFunctions.ahk
#Include %A_ScriptDir%\Lib\\RunCMD.ahk #Include %A_ScriptDir%\Lib\\RunCMD.ahk
; #Include %A_ScriptDir%\Lib\ChromeAutomationFunctions.ahk ; #Include %A_ScriptDir%\Lib\ChromeAutomationFunctions.ahk

Loading…
Cancel
Save