merged misc and general functions
parent
b8ffb10db1
commit
2e0c81f34f
@ -1,158 +0,0 @@
|
||||
|
||||
; -------------------------------Functions-------------------------------
|
||||
|
||||
OnMsgBoxConfirmChromiumOverwrite() {
|
||||
DetectHiddenWindows, On
|
||||
Process, Exist
|
||||
If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) {
|
||||
ControlSetText Button1, Cancel
|
||||
ControlSetText Button2, Yes
|
||||
}
|
||||
}
|
||||
|
||||
; https://www.autohotkey.com/docs/v2/Functions.htm#Variadic
|
||||
Join(sep, params*) {
|
||||
For index, param in params
|
||||
str .= param . sep
|
||||
return SubStr(str, 1, -StrLen(sep))
|
||||
}
|
||||
|
||||
|
||||
|
||||
LogErrorToTextFile(Error){
|
||||
/* if(LogErrorsToTextFile != 1)
|
||||
Return
|
||||
*/
|
||||
ErrorLoggingFile := VideoFolderDir . "\" . "ErrorLogging.txt"
|
||||
FormatTime, TodayDate , YYYYMMDDHH24MISS, yyyyMMdd_hhmmss
|
||||
text =
|
||||
(
|
||||
|
||||
|
||||
---------------%TodayDate%---------------
|
||||
%CurrentSite%: %Error%
|
||||
|
||||
|
||||
)
|
||||
if(LogErrorsToMsgbox)
|
||||
Msgbox % "Text: " Text
|
||||
|
||||
FileAppend, %Text%, %ErrorLoggingFile%
|
||||
} ; End of Function
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
AddToTotalVideosUploadedCount(){
|
||||
; IniRead, TotalVideosUploaded, %SettingsIniFilepath%, General, TotalVideosUploaded, %A_Space%
|
||||
TotalVideosUploaded += 1
|
||||
; IniWrite, %TotalVideosUploaded%, %SettingsIniFilepath%, General, TotalVideosUploaded
|
||||
}
|
||||
|
||||
|
||||
|
||||
OnMsgBoxPodcastFinish() {
|
||||
DetectHiddenWindows, On
|
||||
Process, Exist
|
||||
If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) {
|
||||
WinMove,, 0
|
||||
}
|
||||
}
|
||||
|
||||
OnMsgBoxSocialMediaPoster() {
|
||||
DetectHiddenWindows, On
|
||||
Process, Exist
|
||||
If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) {
|
||||
ControlSetText Button1, Yes
|
||||
ControlSetText Button2, Not Now
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Check_For_Stuck_Video_Upload(Index_Number, Upload_Status){
|
||||
if(A_index = 1){ ; Create a blank array
|
||||
ProgressStatusArray := []
|
||||
Return
|
||||
}
|
||||
|
||||
Message = Upload Status: %Upload_Status%
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip")
|
||||
|
||||
; if we reached the last loop number:
|
||||
if(A_index = %Number_of_loops_to_Check_Upload_status%){
|
||||
Message = Upload Most Likely Failed: Video Hasn't Finished Uploading after 1 hour.
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
SaveDriverURLOFErrorPage()
|
||||
Return "Failed"
|
||||
}
|
||||
|
||||
; If progress is still the same after a ten minute interval then error out
|
||||
if(HasVal(Array_Index_Num_of_Upload_StatusChecks, A_index)){ ; if current index is in Array of index numbers to check status during
|
||||
|
||||
; Send a notification message of upload status
|
||||
Message = Upload Status: %Upload_Status%
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||
|
||||
; if current upload_status is in the array of values that are updated every 10 mins
|
||||
if(HasVal(ProgressStatusArray, Upload_Status)){
|
||||
Message = Upload Failed (E#4508)`nUpload Stuck at same point for 10 minutes. Stuck Status: %ProgressStatus%
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
SaveDriverURLOFErrorPage()
|
||||
Return "Failed"
|
||||
}
|
||||
ProgressStatusArray.Push(Upload_Status) ; append current status to array
|
||||
}
|
||||
} ; 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%
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
; Split a long string into multiple pieces based on the string lengtht you want and return an array with all strings
|
||||
SplitStringWithSentences(text, maxChunkSize) {
|
||||
sentences := StrSplit(text, "\. ") ; split at period with space after it
|
||||
|
||||
currentChunk := ""
|
||||
chunks := []
|
||||
|
||||
Loop, % sentences.Length()
|
||||
{
|
||||
sentence := sentences[A_Index]
|
||||
CurrentChunkAndSentence := currentChunk . sentence
|
||||
; Msgbox % "CurrentChunkAndSentence: " CurrentChunkAndSentence
|
||||
; msgbox % StrLen(CurrentChunkAndSentence)
|
||||
|
||||
if (StrLen(CurrentChunkAndSentence) <= maxChunkSize)
|
||||
{
|
||||
currentChunk .= sentence . "\. "
|
||||
}
|
||||
else
|
||||
{
|
||||
chunks.Push(currentChunk)
|
||||
currentChunk := sentence . "\. "
|
||||
}
|
||||
}
|
||||
|
||||
if (currentChunk != "")
|
||||
chunks.Push(currentChunk)
|
||||
|
||||
return chunks
|
||||
}
|
||||
|
Loading…
Reference in New Issue