diff --git a/Freedomain Video Uploader.ahk b/Freedomain Video Uploader.ahk index def2c62..4f7dcac 100644 --- a/Freedomain Video Uploader.ahk +++ b/Freedomain Video Uploader.ahk @@ -24,7 +24,7 @@ Menu, Tray, Add, Restart with Last Project, RetryUpload Menu, Tray, Default, Restart with Last Project -global ScriptName +global ScriptNameav global ScriptVersion global FullScriptName @@ -47,6 +47,7 @@ UStartTime := A_TickCount ; start time #Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\RunCMD.ahk #include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\StdOutToVar.ahk #include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Zip.ahk +#include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\URLDownloadToVar.ahk ;---ToDo--- @@ -425,7 +426,7 @@ OdyseeAudioThumbCheckStatus := 0 */ (RumbleURL != "")?(RumbleCheckStatus := 0) : (RumbleCheckStatus := 1) ; if user tried to upload to locals already and still needs to grab the url, check -(LocalsURL = "LocalsUploadStartedNeedToGrabURL")?(LocalsCheckStatus := 0) : (LocalsCheckStatus := 0) +(LocalsURL = "LocalsUploadStartedNeedToGrabURL")?(LocalsCheckStatus := 1) : (LocalsCheckStatus := 0) (BrighteonURL != "")?(BrighteonCheckStatus := 0) : (BrighteonCheckStatus := 1) if(VideoFileSizeInMB > 6144){ VideoFileSizeOver6GB := 1 @@ -654,8 +655,12 @@ Gui, Add, Button, x+5 yp+0 h%EditBoxHeight% gSelectVideoThumbFilepath, Select Gui, Font, Bold if(WavAudioFilepath = "") Gui, Add, Text,cRed x%MarginSquared% y+15,WAV Filepath -else, -Gui, Add, Text,x%MarginSquared% y+15,WAV Filepath +else, { ; change text depending on if WAV or FLAC file + if(InStr(WavFilepath, ".flac")) + Gui, Add, Text,x%MarginSquared% y+15,FLAC Filepath + else, + Gui, Add, Text,x%MarginSquared% y+15,WAV Filepath +} Gui, Font, Normal Gui, Add, Edit, x%MarginSquared% y+2 w%FilePathEditBoxWidths% h%EditBoxHeight% gUpdateVars vWavAudioFilepath,%WavAudioFilepath% Gui, Add, Button, x+5 yp+0 h%EditBoxHeight% gSelectWAVFilepath, Select @@ -768,11 +773,12 @@ else, { Gui, Add, Checkbox, x+%MarginSpaceTripled% yp+0 vLocals Checked%LocalsCheckStatus% gUpdateVars, Locals } +Gui, Add, Checkbox, x%GroupBoxCheckboxPos% y+%MarginSpace% vOdyseeVideo Checked%OdyseeVideoCheckStatus% gUpdateVars, Odysee Video + if(VideoFileSizeInMB < 50) -Gui, Add, Checkbox, vTelegram x+%MarginSpaceDoubled% Checked%TelegramCheckStatus% gUpdateVars, Telegram +Gui, Add, Checkbox, vTelegram x+%MarginSpaceTripled% yp+0 Checked%TelegramCheckStatus% gUpdateVars, Telegram (>50 MB) -Gui, Add, Checkbox, x%GroupBoxCheckboxPos% y+%MarginSpace% vOdyseeVideo Checked%OdyseeVideoCheckStatus% gUpdateVars, Odysee Video ; Gui, Add, Checkbox, x+%MarginSpace% vOdyseeVideoThumb Checked%OdyseeVideoThumbCheckStatus%,Thumbnail Gui, Add, Checkbox, x%GroupBoxCheckboxPos% y+%MarginSpace% vOdyseeAudio Checked%OdyseeAudioCheckStatus% gUpdateVars, Odysee Audio ; Gui, Add, Checkbox, x+%MarginSpace% vOdyseeAudioThumb Checked%OdyseeAudioThumbCheckStatus%, Thumbnail @@ -1150,9 +1156,9 @@ SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") Message := "TotalVideosUploaded: " TotalVideosUploaded SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") -; Convert Video Description into javascript text format for sending to selenium -JSVideoDescription := FormatTextToJSText(VideoDescription) +; Convert Video Title and Description into javascript formatting for sending to pages through js instead of plain selenium JSVideoTitle := FormatTextToJSText(VideoTitle) +JSVideoDescription := FormatTextToJSText(VideoDescription) ; -------------------------------/Log Info To Text------------------------------- @@ -1169,14 +1175,6 @@ KeywordsArray := StrSplit(VideoTags,",") ; Call each sub one by one, if errors occur then an upload will be stopped and the next upload will then proceed -/* - -if(Facebook) - gosub, FacebookUpload - - */ -/* -*/ if(Telegram) gosub, TelegramVideoUpload @@ -1253,7 +1251,11 @@ SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,Disc DisplayResults: + +/* +; i forget why i have it get the window position here WinGetPos, XPosition, YPosition, , , A +Msgbox % "XPosition: " XPosition "`n" "YPosition: " YPosition if(XPosition > 0 and YPosition > 0){ ; if gui doesn't exist, both are set to -8 ; Msgbox % "XPosition: " XPosition @@ -1263,6 +1265,7 @@ IniWrite, %YPosition%, %SettingsIniFilepath%, General, YPosition } +*/ diff --git a/Modules/Locals-Upload.ahk b/Modules/Locals-Upload.ahk index f2beeec..1dc4ffb 100644 --- a/Modules/Locals-Upload.ahk +++ b/Modules/Locals-Upload.ahk @@ -57,7 +57,7 @@ if(DevMode){ Return } } - +/* Message = Inputting Title SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") @@ -69,6 +69,45 @@ if(DevMode){ } sleep, 1000 + */ + + + + TooltipThis("Inputting Title") + Loop, 5 { ; Attempt to input video description a couple of times + + + if(A_index = 5){ + ; Clipboard := VideoDescription + Message = Failed to input Video Title + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + js = document.querySelector("#title").value = "%JSVideoTitle%"; ; Send content through javascript (Great for getting around emoji chrome limitaitons) + try driver.executeScript(js) ;Executes a Javascript on the webpage, mostly used for buttons. + + ; msgbox + ; try driver.findElementsByName("body").item[1].SendKeys(driver.Keys.SPACE) + ; driver.findElementsByID("ELEMENTID").item[1].SendKeys(driver.Keys.ENTER) + ; msgbox + + jsCheck = return document.querySelector("#title").value; ; Send content through javascript (Great for getting around emoji chrome limitaitons) + try VideoTitle := driver.executeScript(jsCheck) ;Executes a Javascript on the webpage, mostly used for buttons. + + + ; try Description := driver.findElementsByName("body").item[1].Attribute("value") ;XPath: ID=site-title & span tag + if(VideoTitle != "") + Break + sleep, 2000 + } + + + + + + + /*Xpath = //textarea[@id='body'] Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=VideoDescription) @@ -108,7 +147,7 @@ Loop, 5 { ; Attempt to input video description a couple of times sleep, 2000 } -SaveOrPostProgress(Message:="Waiting Video to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") +; SaveOrPostProgress(Message:="Waiting Video to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") Message = Uploading Video File SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") Xpath = //div[@class='uploadvideo-wrapper']//input[@name='Filedata'] @@ -148,7 +187,7 @@ if(AutoSubmitstatus = "0"){ } -DevModeMsgBox("autosubmit status -1 string here") +; DevModeMsgBox("autosubmit status -1 string here") ; msgbox % AutoSubmitstatus = "-1" if(AutoSubmitstatus = "-1"){ ; if checked YES @@ -254,26 +293,65 @@ Return js = return document.querySelector("a[class='btn']").innerText; try, status := driver.executeScript(js) if(status){ - Message = Video was uploaded but Locals saved it as a draft instead of instantly publishing it. Please go to the Locals Page and Retrieve Draft and manually Publish it. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return -} + Message = Video is in Draft Mode. Publishing. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,DiscordErrorLogging") + + ; video is in draft mode, we need to confirm the title and then publish it. + + ; click Retrieve draft button + js = document.querySelector("a[class='btn']").click() + try, driver.executeScript(js) + js = return document.querySelector("#title").value + try LocalsDraftTitle := driver.executeScript(JS) + if(LocalsDraftTitle != VideoTitle){ + Message = Failed to Grab URL. Locals Draft Title does not Match video Title:`nVideo Title: %VideoTitle%`nLocals Draft Title: %LocalsDraftTitle% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + ; otherwise we are good to publish video + Xpath = (//button[@name='submitPost'])[1] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Failed to click Publish button on saved Draft + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + sleep, 2000 + +} + + +/* ; Get word that's longer than 4 characters in video title VideoTitleArray := StrSplit(VideoTitle, " ") ; Iterate from 1 to the end of the array: Loop % VideoTitleArray.Length(){ - VideoTitleFirstWord := VideoTitleArray[A_Index] - VideoTitleFirstWord := StrReplace(VideoTitleFirstWord, "_","-") - if(StrLen(VideoTitleFirstWord) > 4) + LongestWordInVideoTitle := VideoTitleArray[A_Index] + LongestWordInVideoTitle := StrReplace(LongestWordInVideoTitle, "_","-") + if(StrLen(LongestWordInVideoTitle) > 4) Break +} + + +*/ + + +; get longest word in video title to use for grabbing the share link from the raw page +RegExMatch(VideoTitle, "ms)\b\S+(?CFindLongestWordInString)\b(?R)", m) +LongestWordInVideoTitle := longestWord +; Msgbox % "LongestWordInVideoTitle: " LongestWordInVideoTitle + +; MsgBox, Longest word: %longestWord%`, #%wordLength% + + - ; MsgBox % VideoTitleArray[A_Index] -} loop, 7 { @@ -287,18 +365,16 @@ loop, 7 { try outerHTML := driver.executeScript(jsCheck) if(DevMode){ - Message = Looking for VideoTitleFirstWord: %VideoTitleFirstWord% `nwithin outerHTML + Message = Looking for LongestWordInVideoTitle: %LongestWordInVideoTitle% `nwithin outerHTML: %outerHTML% DevModeMsgBox(message) - Clipboard := outerHTML - DevModeMsgBox(outerHTML) + Clipboard := message + ; DevModeMsgBox(outerHTML) } + if(InStr(OuterHTML,LongestWordInVideoTitle)){ - ; msgbox % "outerHTML: " . outerHTML - - if(InStr(OuterHTML,VideoTitleFirstWord)){ ; @todo replace with regex - Message = %VideoTitleFirstWord% is in`n`n %OuterHTML% + Message = %LongestWordInVideoTitle% is in`n`n %OuterHTML% DevModeMsgBox(Message) Message = Found at at index: %A_index% @@ -328,19 +404,29 @@ loop, 7 { ShareLink := } -DevModeMsgBox(ShareLink) +if(ShareLink = ""){ + Message = Video was published succsessfully, but failed to grab Share Link. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + +; DevModeMsgBox(ShareLink) ; ShareLink := "Successful" Message = Upload Complete: %ShareLink% SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - +DevModeMsgBox(ShareLink) IniWrite, %ShareLink%, %VideoLinksIniFile%, URLs, LocalsURL AddToTotalVideosUploadedCount() SaveDriverURL() +; Set variable so that URL gets grabbed later in the upload +LocalsGrabURL := 1 + Return @@ -500,22 +586,22 @@ Loop, %Number_of_loops_to_Check_Upload_status% { VideoTitleArray := StrSplit(VideoTitle, " ") ; Iterate from 1 to the end of the array: Loop % VideoTitleArray.Length(){ - VideoTitleFirstWord := VideoTitleArray[A_Index] - VideoTitleFirstWord := StrReplace(VideoTitleFirstWord, "_","-") - if(StrLen(VideoTitleFirstWord) > 4) + LongestWordInVideoTitle := VideoTitleArray[A_Index] + LongestWordInVideoTitle := StrReplace(LongestWordInVideoTitle, "_","-") + if(StrLen(LongestWordInVideoTitle) > 4) Break ; MsgBox % VideoTitleArray[A_Index] } - ; DevModeMsgBox(VideoTitleFirstWord) + ; DevModeMsgBox(LongestWordInVideoTitle) - ; Message = VideoTitleFirstWord: %VideoTitleFirstWord% + ; Message = LongestWordInVideoTitle: %LongestWordInVideoTitle% ; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") - ; VideoTitleFirstWord := VideoTitleFirstWord[1] - ; Msgbox % "VideoTitleFirstWord: " VideoTitleFirstWord + ; LongestWordInVideoTitle := LongestWordInVideoTitle[1] + ; Msgbox % "LongestWordInVideoTitle: " LongestWordInVideoTitle /* ; Format the post title to remove all spaces and special characters to match with Locals Post ShareLinkFormatted := StrReplace(VideoTitle, " ", "-") @@ -547,9 +633,9 @@ Loop, %Number_of_loops_to_Check_Upload_status% { ; msgbox % "outerHTML: " . outerHTML - if(InStr(OuterHTML,VideoTitleFirstWord)){ + if(InStr(OuterHTML,LongestWordInVideoTitle)){ - Message = %VideoTitleFirstWord% is in %OuterHTML% + Message = %LongestWordInVideoTitle% is in %OuterHTML% ; DevModeMsgBox(Message) ; MsgBox, found match at %A_index% diff --git a/Modules/Miscellaneous-Functions.ahk b/Modules/Miscellaneous-Functions.ahk index b26a3e5..6b0c2f1 100644 --- a/Modules/Miscellaneous-Functions.ahk +++ b/Modules/Miscellaneous-Functions.ahk @@ -234,4 +234,20 @@ Check_For_Stuck_Video_Upload(Index_Number, Upload_Status){ } ProgressStatusArray.Push(Upload_Status) ; append current status to array } - } ; end of func \ No newline at end of file + } ; end of func + + +; Find the longest word in a string of words + FindLongestWordInString(m, calloutNumber, pos, haystack, pattern){ + Global wordLength, longestWord + + len := StrLen(m) + + If ( len > wordLength ) + { + wordLength := len + longestWord := m + + ; MsgBox, %m% + } + } \ No newline at end of file