fixed locals posting, errors if gitea is not reachable, results gui appearing at wrong position on screen

pull/2/head
Yuriy 1 year ago
parent 263fb222e9
commit edb3ad07c8

@ -24,7 +24,7 @@ Menu, Tray, Add, Restart with Last Project, RetryUpload
Menu, Tray, Default, Restart with Last Project Menu, Tray, Default, Restart with Last Project
global ScriptName global ScriptNameav
global ScriptVersion global ScriptVersion
global FullScriptName 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\RunCMD.ahk
#include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\StdOutToVar.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\Zip.ahk
#include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\URLDownloadToVar.ahk
;---ToDo--- ;---ToDo---
@ -425,7 +426,7 @@ OdyseeAudioThumbCheckStatus := 0
*/ */
(RumbleURL != "")?(RumbleCheckStatus := 0) : (RumbleCheckStatus := 1) (RumbleURL != "")?(RumbleCheckStatus := 0) : (RumbleCheckStatus := 1)
; if user tried to upload to locals already and still needs to grab the url, check ; 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) (BrighteonURL != "")?(BrighteonCheckStatus := 0) : (BrighteonCheckStatus := 1)
if(VideoFileSizeInMB > 6144){ if(VideoFileSizeInMB > 6144){
VideoFileSizeOver6GB := 1 VideoFileSizeOver6GB := 1
@ -654,8 +655,12 @@ Gui, Add, Button, x+5 yp+0 h%EditBoxHeight% gSelectVideoThumbFilepath, Select
Gui, Font, Bold Gui, Font, Bold
if(WavAudioFilepath = "") if(WavAudioFilepath = "")
Gui, Add, Text,cRed x%MarginSquared% y+15,WAV Filepath Gui, Add, Text,cRed x%MarginSquared% y+15,WAV Filepath
else, else, { ; change text depending on if WAV or FLAC file
Gui, Add, Text,x%MarginSquared% y+15,WAV Filepath 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, Font, Normal
Gui, Add, Edit, x%MarginSquared% y+2 w%FilePathEditBoxWidths% h%EditBoxHeight% gUpdateVars vWavAudioFilepath,%WavAudioFilepath% 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 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+%MarginSpaceTripled% yp+0 vLocals Checked%LocalsCheckStatus% gUpdateVars, Locals
} }
Gui, Add, Checkbox, x%GroupBoxCheckboxPos% y+%MarginSpace% vOdyseeVideo Checked%OdyseeVideoCheckStatus% gUpdateVars, Odysee Video
if(VideoFileSizeInMB < 50) 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+%MarginSpace% vOdyseeVideoThumb Checked%OdyseeVideoThumbCheckStatus%,Thumbnail
Gui, Add, Checkbox, x%GroupBoxCheckboxPos% y+%MarginSpace% vOdyseeAudio Checked%OdyseeAudioCheckStatus% gUpdateVars, Odysee Audio Gui, Add, Checkbox, x%GroupBoxCheckboxPos% y+%MarginSpace% vOdyseeAudio Checked%OdyseeAudioCheckStatus% gUpdateVars, Odysee Audio
; Gui, Add, Checkbox, x+%MarginSpace% vOdyseeAudioThumb Checked%OdyseeAudioThumbCheckStatus%, Thumbnail ; Gui, Add, Checkbox, x+%MarginSpace% vOdyseeAudioThumb Checked%OdyseeAudioThumbCheckStatus%, Thumbnail
@ -1150,9 +1156,9 @@ SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile")
Message := "TotalVideosUploaded: " TotalVideosUploaded Message := "TotalVideosUploaded: " TotalVideosUploaded
SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile")
; Convert Video Description into javascript text format for sending to selenium ; Convert Video Title and Description into javascript formatting for sending to pages through js instead of plain selenium
JSVideoDescription := FormatTextToJSText(VideoDescription)
JSVideoTitle := FormatTextToJSText(VideoTitle) JSVideoTitle := FormatTextToJSText(VideoTitle)
JSVideoDescription := FormatTextToJSText(VideoDescription)
; -------------------------------/Log Info To Text------------------------------- ; -------------------------------/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 ; 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) if(Telegram)
gosub, TelegramVideoUpload gosub, TelegramVideoUpload
@ -1253,7 +1251,11 @@ SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,Disc
DisplayResults: DisplayResults:
/*
; i forget why i have it get the window position here
WinGetPos, XPosition, YPosition, , , A 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 if(XPosition > 0 and YPosition > 0){ ; if gui doesn't exist, both are set to -8
; Msgbox % "XPosition: " XPosition ; Msgbox % "XPosition: " XPosition
@ -1263,6 +1265,7 @@ IniWrite, %YPosition%, %SettingsIniFilepath%, General, YPosition
} }
*/

@ -57,7 +57,7 @@ if(DevMode){
Return Return
} }
} }
/*
Message = Inputting Title Message = Inputting Title
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
@ -69,6 +69,45 @@ if(DevMode){
} }
sleep, 1000 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'] /*Xpath = //textarea[@id='body']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=VideoDescription) 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 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 Message = Uploading Video File
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
Xpath = //div[@class='uploadvideo-wrapper']//input[@name='Filedata'] 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" ; msgbox % AutoSubmitstatus = "-1"
if(AutoSubmitstatus = "-1"){ ; if checked YES if(AutoSubmitstatus = "-1"){ ; if checked YES
@ -254,26 +293,65 @@ Return
js = return document.querySelector("a[class='btn']").innerText; js = return document.querySelector("a[class='btn']").innerText;
try, status := driver.executeScript(js) try, status := driver.executeScript(js)
if(status){ 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. Message = Video is in Draft Mode. Publishing.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return ; 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 ; Get word that's longer than 4 characters in video title
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(){
VideoTitleFirstWord := VideoTitleArray[A_Index] LongestWordInVideoTitle := VideoTitleArray[A_Index]
VideoTitleFirstWord := StrReplace(VideoTitleFirstWord, "_","-") LongestWordInVideoTitle := StrReplace(LongestWordInVideoTitle, "_","-")
if(StrLen(VideoTitleFirstWord) > 4) if(StrLen(LongestWordInVideoTitle) > 4)
Break 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 { loop, 7 {
@ -287,18 +365,16 @@ loop, 7 {
try outerHTML := driver.executeScript(jsCheck) try outerHTML := driver.executeScript(jsCheck)
if(DevMode){ if(DevMode){
Message = Looking for VideoTitleFirstWord: %VideoTitleFirstWord% `nwithin outerHTML Message = Looking for LongestWordInVideoTitle: %LongestWordInVideoTitle% `nwithin outerHTML: %outerHTML%
DevModeMsgBox(message) DevModeMsgBox(message)
Clipboard := outerHTML Clipboard := message
DevModeMsgBox(outerHTML) ; DevModeMsgBox(outerHTML)
} }
if(InStr(OuterHTML,LongestWordInVideoTitle)){
; msgbox % "outerHTML: " . outerHTML
if(InStr(OuterHTML,VideoTitleFirstWord)){
; @todo replace with regex ; @todo replace with regex
Message = %VideoTitleFirstWord% is in`n`n %OuterHTML% Message = %LongestWordInVideoTitle% is in`n`n %OuterHTML%
DevModeMsgBox(Message) DevModeMsgBox(Message)
Message = Found at at index: %A_index% Message = Found at at index: %A_index%
@ -328,19 +404,29 @@ loop, 7 {
ShareLink := 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" ; ShareLink := "Successful"
Message = Upload Complete: %ShareLink% Message = Upload Complete: %ShareLink%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
DevModeMsgBox(ShareLink)
IniWrite, %ShareLink%, %VideoLinksIniFile%, URLs, LocalsURL IniWrite, %ShareLink%, %VideoLinksIniFile%, URLs, LocalsURL
AddToTotalVideosUploadedCount() AddToTotalVideosUploadedCount()
SaveDriverURL() SaveDriverURL()
; Set variable so that URL gets grabbed later in the upload
LocalsGrabURL := 1
Return Return
@ -500,22 +586,22 @@ Loop, %Number_of_loops_to_Check_Upload_status% {
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(){
VideoTitleFirstWord := VideoTitleArray[A_Index] LongestWordInVideoTitle := VideoTitleArray[A_Index]
VideoTitleFirstWord := StrReplace(VideoTitleFirstWord, "_","-") LongestWordInVideoTitle := StrReplace(LongestWordInVideoTitle, "_","-")
if(StrLen(VideoTitleFirstWord) > 4) if(StrLen(LongestWordInVideoTitle) > 4)
Break Break
; MsgBox % VideoTitleArray[A_Index] ; MsgBox % VideoTitleArray[A_Index]
} }
; DevModeMsgBox(VideoTitleFirstWord) ; DevModeMsgBox(LongestWordInVideoTitle)
; Message = VideoTitleFirstWord: %VideoTitleFirstWord% ; Message = LongestWordInVideoTitle: %LongestWordInVideoTitle%
; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") ; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile")
; VideoTitleFirstWord := VideoTitleFirstWord[1] ; LongestWordInVideoTitle := LongestWordInVideoTitle[1]
; Msgbox % "VideoTitleFirstWord: " VideoTitleFirstWord ; Msgbox % "LongestWordInVideoTitle: " LongestWordInVideoTitle
/* ; Format the post title to remove all spaces and special characters to match with Locals Post /* ; Format the post title to remove all spaces and special characters to match with Locals Post
ShareLinkFormatted := StrReplace(VideoTitle, " ", "-") ShareLinkFormatted := StrReplace(VideoTitle, " ", "-")
@ -547,9 +633,9 @@ Loop, %Number_of_loops_to_Check_Upload_status% {
; msgbox % "outerHTML: " . outerHTML ; msgbox % "outerHTML: " . outerHTML
if(InStr(OuterHTML,VideoTitleFirstWord)){ if(InStr(OuterHTML,LongestWordInVideoTitle)){
Message = %VideoTitleFirstWord% is in %OuterHTML% Message = %LongestWordInVideoTitle% is in %OuterHTML%
; DevModeMsgBox(Message) ; DevModeMsgBox(Message)
; MsgBox, found match at %A_index% ; MsgBox, found match at %A_index%

@ -235,3 +235,19 @@ Check_For_Stuck_Video_Upload(Index_Number, Upload_Status){
ProgressStatusArray.Push(Upload_Status) ; append current status to array ProgressStatusArray.Push(Upload_Status) ; append current status to array
} }
} ; end of func } ; 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%
}
}
Loading…
Cancel
Save