From f66ada0635c76f00ae6160755d1f57359ad65ce0 Mon Sep 17 00:00:00 2001 From: yuriy Date: Sun, 17 Sep 2023 14:26:44 -0400 Subject: [PATCH] code cleanup, added statistic for number of mouse clicks made by selenium --- Freedomain Video Uploader.ahk | 90 ++++--------------------- Lib/Freedomain-Posters-Shared-Functions | 2 +- Modules/Miscellaneous-Functions.ahk | 90 ++++++++++++------------- 3 files changed, 59 insertions(+), 123 deletions(-) diff --git a/Freedomain Video Uploader.ahk b/Freedomain Video Uploader.ahk index b21109d..bc32624 100644 --- a/Freedomain Video Uploader.ahk +++ b/Freedomain Video Uploader.ahk @@ -52,22 +52,16 @@ UStartTime := A_TickCount ; start time ;---ToDo--- ;------------------------------------------------ ; @todo: Update Locals Share link grabbing - -; @todo: finish show results functionality on line 430 ; @todo: fix uploader saying there's been failures b/c there was no lbry audio upload ; @todo: finish telegram multi-message split functionality. ; @todo: add different icon when update is available ; @todo: fix telegram post getting cut off if too long instead of splitting into 2 -; @todo: fix ping always saying that there was failures ; @todo: let user make last minute changes to text before submitting to telegram and discord ; @todo: replace all .Attribute("innerText") with js ; @todo: Fix locals not grabbing url if a post is pinned ; @todo: Add an input box for sources in the new frontend -; @todo: Fix bitchute title getting input twice ; @todo: Add login check for each website and ability to auto login ; @todo: ; add to statistics in statusbar - length of philosophy uploaded... total hours uploaded? - -; @todo: add support for unauthorized.tv ; @todo: Bitchute has a 5k char limit for description as well. split description to remove reocurring bits and Add freedomainpodcasts.com/podcast/# link if still not big enough ; @todo: Split long discord/telegram messages into multiple messages ; @todo: Redo Discord posting with "PostErrors" function from social media poster @@ -145,11 +139,6 @@ ScriptSettingsSection := "VideoUploader" IniRead, ShowTooltipProgress, %SettingsIniFilepath%, General, ShowTooltipProgress, 1 (ShowTooltipProgress)?(ShowTooltipProgressCheckStatus := 1) : (ShowTooltipProgressCheckStatus := 0) - -; Message = Reading Settings from .ini files -; ToolTip, reading settings -; SaveOrPostProgress(Message:=Message,PostType:="Tooltip") - IniRead, XPosition, %SettingsIniFilepath%, General, XPosition IniRead, YPosition, %SettingsIniFilepath%, General, YPosition @@ -157,22 +146,15 @@ IniRead, YPosition, %SettingsIniFilepath%, General, YPosition IniRead, RootDirToStartIn, %SettingsIniFilepath%, General, RootDirToStartIn IniRead, LogErrorsToMsgbox, %SettingsIniFilepath%, General, LogErrorsToMsgbox, %A_Space% IniRead, UpdateAvailable, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable, 0 -; Msgbox % "SettingsIniFilepath: " SettingsIniFilepath -; Msgbox % "UpdateAvailable: " UpdateAvailable IniRead, DevMode, %SettingsIniFilepath%, General, DevMode, 0 IniRead, TotalVideosUploaded, %SettingsIniFilepath%, General, TotalVideosUploaded, 0 +IniRead, MouseClicksSaved, %SettingsIniFilepath%, General, MouseClicksSaved, 0 ; Checkbox Settings IniRead, ShowTooltipProgress, %SettingsIniFilepath%, General, ShowTooltipProgress, 1 (ShowTooltipProgress)?(ShowTooltipProgressCheckStatus := 1) : (ShowTooltipProgressCheckStatus := 0) -/* -@todo delete later -IniRead, ReuseTabs, %SettingsIniFilepath%, General, ReuseTabs, 1 -(ReuseTabs)?(ReuseTabsCheckStatus := 1) : (ReuseTabsCheckStatus := 0) -*/ -; ReuseTabs is permanantly on. There is never a time where you want to create new tabs for every website -ReuseTabs := 1 +ReuseTabs := 1 ; ReuseTabs is permanantly on. There is never a time where you want to create new tabs for every website IniRead, AutoUpdateCheck, %SettingsIniFilepath%, General, AutoUpdateCheck, 1 (AutoUpdateCheck)?(AutoUpdateCheckCheckStatus := 1) : (AutoUpdateCheckCheckStatus := 0) @@ -491,10 +473,9 @@ if(DevMode){ ; Menu, Tray, Add, Reload to Results, ReloadToResults } -; Msgbox % "PassedParameter: " PassedParameter -; Msgbox % "PassedParameter: " PassedParameter + + if(PassedParameter = "ShowResults"){ - msgbox, we are showing results goto, DisplayResults } @@ -815,8 +796,8 @@ Gui, Add, Picture, xp+10 yp+20 w%ThumbnailPreviewWidth% h-1, %VideoThumbFilepath gui, Font, Normal gui, font, s7 -Gui, Add, StatusBar,Center, Total Videos Uploaded: %TotalVideosUploaded% -; SB_SetText("There are " . RowCount . " rows selected.") +Gui, Add, StatusBar,Center, Total Videos Uploaded: %TotalVideosUploaded% | Total Clicks Saved: %MouseClicksSaved% + ; Show GUI to the user Gui, +Resize +MaximizeBox @@ -827,16 +808,8 @@ else, Gui, Show,, %FullScriptName% - Upload Settings - %BodyTextFilePath% ControlFocus, Edit4, %FullScriptName% - ToolTip -; Gui, Maximize -; Gui, Show, w%GuiWidth% h%GuiHeight%, %ScriptName% - -if(SkipToDBInfo){ - gui, submit - goto, DisplayResults -} ; Write current project to ini file for easy reloading IniWrite, %BodyTextFilePath%, %SettingsIniFilepath%, %ScriptSettingsSection%, LastPost @@ -866,11 +839,6 @@ if(AutoUpdateCheck AND !UpdateAvailable){ ; calculate run time and convert to seconds URunTime2 := round(((A_TickCount - UStartTime) / 1000), 2) -; Msgbox % "URunTime1: " URunTime1 - -; Msgbox % "URunTime2: " URunTime2 -; Msgbox % "URunTime: " URunTime - Return ; -------------------------------GUI GoSubs------------------------------- @@ -1293,9 +1261,12 @@ SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,Disc DisplayResults: -Gui, Destroy -; @todo: Add a way to check if uploads finished with or without errors Tooltip ; Remove all tooltips + +Gui, Destroy ; destroy GUI in case we're going from the main screen to results without uploading. + + +IniRead, MouseClicksSaved, %SettingsIniFilepath%, General, MouseClicksSaved, %A_Space% IniRead, TotalVideosUploaded, %SettingsIniFilepath%, General, TotalVideosUploaded, %A_Space% ; IniRead, StreamanityURL, %VideoLinksIniFile%, URLs, StreamanityURL, %A_Space% IniRead, BitChuteURL, %VideoLinksIniFile%, URLs, BitChuteURL, %A_Space% @@ -1339,63 +1310,37 @@ Gui, Font, Bold Gui, Add, Button, x10 y+%Marginspace% h%ButtonHeights% w%CopyButtonWidths% gCopyPodcastNumber, Podcast # Gui, Font, Normal Gui, Add, Edit, x+5 yp+0 h%ButtonHeights% w%ResultEditBoxWidths% gUpdateVars vPodcastNumber, %PodcastNumber% -; Gui, Add, Edit, x+5 h200 w200, This is some text that goes here! - -; Gui, Add, Text,x10 y+20, Title: -; Gui, Font, Bold -; Gui, Add, Button, x10 y+%Marginspace% h%ButtonHeights% w%CopyButtonWidths% gCopyVideoTitle, Title -; Gui, Font, Normal -; Gui, Add, Edit, x+5 yp+0 h%ButtonHeights% w%ResultEditBoxWidths% gUpdateVars vVideoTitle, %VideoTitle% -; Gui, Add, Button, x+1 w20, Copy Title - -; Gui, Add, Text,x10 y+20, Bitchute: Gui, Font, Bold Gui, Add, Button, x10 y+%Marginspace% h%ButtonHeights% w%CopyButtonWidths% gCopyBitChuteURL, Bitchute Gui, Font, Normal Gui, Add, Edit, x+5 yp+0 h%ButtonHeights% vBitChuteURL w%ResultEditBoxWidths% gUpdateVars , %BitChuteURL% -; Gui, Add, Edit, x+5 yp+0 w%ResultLBRYThumbEditBoxWidth% gUpdateVars, Facebook: %FacebookURL% -; Gui, Add, Button, x+1 w20, Copy BitChute - -; Gui, Add, Text,x10 y+20, Brighteon: Gui, Font, Bold Gui, Add, Button, x10 y+%Marginspace% h%ButtonHeights% w%CopyButtonWidths% gCopyBrighteonURL, Brighteon Gui, Font, Normal Gui, Add, Edit, x+5 yp+0 h%ButtonHeights% vBrighteonURL w%ResultEditBoxWidths% gUpdateVars , %BrighteonURL% -; Gui, Add, Text,x10 y+20, DailyMotion: Gui, Font, Bold Gui, Add, Button, x10 y+10 h%ButtonHeights% w%CopyButtonWidths% gCopyDailyMotionURL, DailyMotion Gui, Font, Normal Gui, Add, Edit, x+5 yp+0 h%ButtonHeights% vDailyMotionURL w%ResultEditBoxWidths% gUpdateVars , %DailyMotionURL% -; Gui, Add, Text,x10 y+20, Odysee: Gui, Font, Bold Gui, Add, Button, x10 y+10 h%ButtonHeights% w%CopyButtonWidths% gCopyOdyseeVideoURL, Odysee Video Gui, Font, Normal Gui, Add, Edit, x+5 yp+0 h%ButtonHeights% vOdyseeVideoURL w%ResultEditBoxWidths% gUpdateVars, %OdyseeVideoURL% -; Gui, Add, Button, x+5 yp+0, Thumb -; Gui, Add, Edit, x+5 yp+0 h%ButtonHeights% vOdyseeVideoThumb w%ResultLBRYThumbEditBoxWidth% gUpdateVars, Thumb: %OdyseeVideoThumb% Gui, Font, Bold Gui, Add, Button, x10 y+10 h%ButtonHeights% w%CopyButtonWidths% gCopyOdyseeAudioURL, Odysee Audio Gui, Font, Normal Gui, Add, Edit, x+5 yp+0 h%ButtonHeights% vOdyseeAudioURL w%ResultEditBoxWidths% gUpdateVars , %OdyseeAudioURL% -; Gui, Add, Button, x+5 yp+0, Thumb -; Gui, Add, Edit, x+5 yp+0 vOdyseeAudioThumb w%ResultLBRYThumbEditBoxWidth% gUpdateVars, Thumb: %OdyseeAudioThumb% Gui, Font, Bold Gui, Add, Button, x10 y+10 h%ButtonHeights% w%CopyButtonWidths% gCopyRumbleURL, Rumble Gui, Font, Normal Gui, Add, Edit, x+5 yp+0 h%ButtonHeights% vRumbleURL w%ResultEditBoxWidths% gUpdateVars , %RumbleURL% -/*Gui, Font, Bold -Gui, Add, Button, x10 y+10 h%ButtonHeights% w%CopyButtonWidths% gCopyStreamanityURL, Streamanity -Gui, Font, Normal -Gui, Add, Edit, x+5 yp+0 h%ButtonHeights% vStreamanityURL w%ResultEditBoxWidths% gUpdateVars , %StreamanityURL% - -*/ Gui, Font, Bold Gui, Add, Button, x10 y+10 h%ButtonHeights% w%CopyButtonWidths%, Locals Gui, Font, Normal @@ -1426,12 +1371,10 @@ Gui, Add, Button, x%ResultEditBoxXPos% y+%MarginSpace% w%ResultEditBoxThirdsWidt Gui, Add, Button, x+5 w%ResultEditBoxThirdsWidths% gPostToTelegram vPostToTelegramButton, Post to Telegram Gui, Add, Button, x+5 w%ResultEditBoxThirdsWidths% gStartSocialMediaPoster, Start Social Media Poster - Gui, Font, Bold Gui, Add, Button, x%ResultEditBoxXPos% y+%MarginSpace% w%ResultEditBoxHalfWidths%gSendErrorLoggingThroughTelegram, Send Errorlog Through Telegram Gui, Add, Button, x+%MarginSpace% w%ResultEditBoxHalfWidths% gRetryUpload, Try Failed Again - Gui, Add, Button, x%ResultEditBoxXPos% w%ResultEditBoxHalfWidths% gOpenLBRYBlobFilesFolder %ButtonWidths% , Open LBRY Blob Files Folder Gui, Add, Button, x+%MarginSpace% w%ResultEditBoxHalfWidths% gCancelPost %ButtonWidths% , Close ; Gui, Add, Button, x+%MarginSpace% w%ResultEditBoxHalfWidths% gKillScript %ButtonWidths% , Close @@ -1443,7 +1386,7 @@ Gui, Add, Edit,x%ErrorLogEditBoxXPos% h%ErrorLogEditBoxHeight% w%ErrorLogEditBox gui, font, Normal gui, font, s7 -Gui, Add, StatusBar,, Total Videos Uploaded: %TotalVideosUploaded% +Gui, Add, StatusBar,, Total Videos Uploaded: %TotalVideosUploaded% | Total Clicks Saved: %MouseClicksSaved% Gui, +Resize +MaximizeBox OriginalVideoDescription := VideoDescription @@ -1495,7 +1438,7 @@ if(SocialMediaPosterFilepath = "" or !FileExist(SocialMediaPosterFilepath)){ Return /* -Indent Reset +Sublime Indent Reset */ ; -------------------------------CopyThis------------------------------- @@ -1556,14 +1499,7 @@ sleep, 1000 ToolTip Return -/*CopyStreamanityURL: -Clipboard := StreamanityURL -SaveOrPostProgress(Message:=StreamanityURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") -sleep, 1000 -ToolTip -Return -*/ CopyVideoTags: Clipboard := VideoTags SaveOrPostProgress(Message:=VideoTags "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") diff --git a/Lib/Freedomain-Posters-Shared-Functions b/Lib/Freedomain-Posters-Shared-Functions index 1c00018..ca7145f 160000 --- a/Lib/Freedomain-Posters-Shared-Functions +++ b/Lib/Freedomain-Posters-Shared-Functions @@ -1 +1 @@ -Subproject commit 1c000184df1a048998e0a68f1698d3f6499f1c28 +Subproject commit ca7145fa8258665bfb4ee6615467ee042e58fe34 diff --git a/Modules/Miscellaneous-Functions.ahk b/Modules/Miscellaneous-Functions.ahk index d263c69..b26a3e5 100644 --- a/Modules/Miscellaneous-Functions.ahk +++ b/Modules/Miscellaneous-Functions.ahk @@ -171,67 +171,67 @@ LogErrorToTextFile(Error){ FileAppend, %Text%, %ErrorLoggingFile% } ; End of Function +/* +*/ +AddToTotalVideosUploadedCount(){ + ; IniRead, TotalVideosUploaded, %SettingsIniFilepath%, General, TotalVideosUploaded, %A_Space% + TotalVideosUploaded += 1 + ; IniWrite, %TotalVideosUploaded%, %SettingsIniFilepath%, General, TotalVideosUploaded +} - SaveDriverURL() - 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 + } +} - 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 } +} - 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" + } - Check_For_Stuck_Video_Upload(Index_Number, Upload_Status){ - if(A_index = 1){ ; Create a blank array - ProgressStatusArray := [] - Return - } + ; 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") + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - ; 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. + ; 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" } - - ; 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 - } + ProgressStatusArray.Push(Upload_Status) ; append current status to array + } } ; end of func \ No newline at end of file