From 44b343a0a7a8908d7fe7df68af6ac77236dea0e2 Mon Sep 17 00:00:00 2001 From: Yuriy Date: Fri, 10 May 2024 02:36:02 -0400 Subject: [PATCH] added auto update checks option and functionality --- Compile AHK to EXE - Vars.ahk | 84 ++++++++++++++++++++++++ Compile AHK to EXE.ahk | 4 +- Freedomain Livestream Scheduler.ahk | 48 +++++++++++--- Lib/Freedomain-Posters-Shared-Functions | 2 +- Modules/Rumble-Schedule.ahk | 31 +++++++-- Version.ini | Bin 100 -> 176 bytes 6 files changed, 152 insertions(+), 17 deletions(-) create mode 100644 Compile AHK to EXE - Vars.ahk diff --git a/Compile AHK to EXE - Vars.ahk b/Compile AHK to EXE - Vars.ahk new file mode 100644 index 0000000..0a6fe6c --- /dev/null +++ b/Compile AHK to EXE - Vars.ahk @@ -0,0 +1,84 @@ +;---ENVIRONMENT--------------------------------------------------------------------- +#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. +;#Warn ; Enable warnings to assist with detecting common errors. +;DetectHiddenWindows, On +#SingleInstance, Force +DetectHiddenWindows, ON +SendMode Input ; Recommended for new scripts due to its superior speed and reliability. +SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. +;SetKeyDelay, 500 +CoordMode, ToolTip, Screen +CoordMode, Mouse, Screen +; #NoTrayIcon +; Menu, Tray, Icon, RMScriptManager.ico + +;---Notes/Extra Info/#Includes------------------------------------------------------ + + +;---VARIABLES----------------------------------------------------------------------- +ScriptName = Freedomain Livestream Scheduler + +AHKFilepath = %A_ScriptDir%\%ScriptName%.ahk +Exefilepath = %A_ScriptDir%\%ScriptName%.exe +icopath = %A_ScriptDir%\Assets\Icon.ico +VersionIniFP = %A_ScriptDir%\Version.ini + + +;---MAIN SCRIPT--------------------------------------------------------------------- + +; Bump the version number in the version.ini file +IniRead, VersionNumber, %VersionIniFP%, %ScriptName%, Version, 0.0 ; , Filename, Section, Key [, Default] +VersionNumber += .01 +VersionNumber := SubStr(VersionNumber, 1, 4) + +IniWrite, %VersionNumber%, %VersionIniFP%,%ScriptName%, Version + + + +; Kill any active intances of the uploaders so the .exe file can be overwriten by the compilation +process, close, %ScriptName%.exe + +sleep, 1000 + +; Delete the .exe file so it can be repalced +if(FileExist(Exefilepath)){ + FileDelete, %Exefilepath% + if(ErrorLevel){ + msgbox, failed to delete Exe file. Please delete manually and re-run the compiler. + ExitApp + } +} + + +if(!FileExist(AHKFilepath)){ + msgbox, %AHKFilepath% does not exist`nExiting + ExitApp +} + + +if(!FileExist(icopath)){ + msgbox, %icopath% does not exist`nExiting + ExitApp +} + + +run, %comspec% /c ""C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe" /in "%AHKFilepath%" /out "%exefilepath%" /icon "%icopath%"" + + +; OldNotify(ScriptToCompile,"Compiled Successfully",5) +; sleep, 5000 +ExitApp + + + + + + + + + + + + + +;---FUNCTIONS----------------------------------------------------------------------- diff --git a/Compile AHK to EXE.ahk b/Compile AHK to EXE.ahk index 0a6fe6c..b1bc8c1 100644 --- a/Compile AHK to EXE.ahk +++ b/Compile AHK to EXE.ahk @@ -27,11 +27,11 @@ VersionIniFP = %A_ScriptDir%\Version.ini ;---MAIN SCRIPT--------------------------------------------------------------------- ; Bump the version number in the version.ini file -IniRead, VersionNumber, %VersionIniFP%, %ScriptName%, Version, 0.0 ; , Filename, Section, Key [, Default] +IniRead, VersionNumber, %VersionIniFP%, Livestream-Scheduler, Version, 0.0 ; , Filename, Section, Key [, Default] VersionNumber += .01 VersionNumber := SubStr(VersionNumber, 1, 4) -IniWrite, %VersionNumber%, %VersionIniFP%,%ScriptName%, Version +IniWrite, %VersionNumber%, %VersionIniFP%,Livestream-Scheduler, Version diff --git a/Freedomain Livestream Scheduler.ahk b/Freedomain Livestream Scheduler.ahk index d84524c..6c2c05d 100644 --- a/Freedomain Livestream Scheduler.ahk +++ b/Freedomain Livestream Scheduler.ahk @@ -105,12 +105,15 @@ FileInstall, Version.ini, %A_ScriptDir%\Lib\Version.ini, 1 IniRead, ScriptVersion, %A_ScriptDir%\Lib\Version.ini,%ScriptSettingsSection%, Version, 0.0 ; IniRead, ScriptName, %A_ScriptDir%\Lib\Version.ini,%ScriptSettingsSection%, Name, %ScriptSettingsSection% -global ScriptName := "Livestream Scheduler" +global ScriptName := "Freedomain Livestream Scheduler" global ScriptAbbreviatedName := "FLS" ; used for error logging FullScriptName := ScriptName . " - " . ScriptVersion +; Msgbox % "FullScriptName: " FullScriptName +global GitReleasesAPIURL +GitReleasesAPIURL = https://freedomain.dev/api/v1/repos/yuriy/livestream-scheduler/releases ; Read Info From Files @@ -145,13 +148,15 @@ LivestreamThumbnail := ThumbnailJPGFilepath if(FileExist(ThumbnailJPEGFilepath)) LivestreamThumbnail := ThumbnailJPEGFilepath - - } +; Read settings.ini +; ------------------------------------------------ +IniRead, ConfirmBeforeSubmit, %SettingsIniFilepath%, %ScriptSettingsSection%, ConfirmBeforeSubmit, 1 +IniRead, AutoUpdateCheck, %SettingsIniFilepath%, %ScriptSettingsSection%, AutoUpdateCheck, 1 @@ -227,11 +232,18 @@ Gui, Add, Picture, x%MarginSize% w%ThumbnailPreviewWidth% h-1 vThumbnailPreview, ; ------------------------------------------------ Gui, Font, s%GuiFontSize% Gui, Font, Bold -; Gui, Add, Text, , Settings Gui, Add, Text,y0 x%ColumnTwoXPosition%, Settings Gui, Font, Normal Gui, Font, s8 -Gui, Add, Checkbox, vConfirmBeforeSubmit checked, Confirm Before Submit +Gui, Add, Checkbox, vConfirmBeforeSubmit checked%ConfirmBeforeSubmit%, Confirm Before Submit +Gui, Add, Checkbox, vAutoUpdateCheck Checked%AutoUpdateCheck%, Auto Update Check + +if(UpdateAvailable){ + Gui, Add, Button, cRed w%ColumnTwoEditBoxWidth% gUpdateScript vUpdateAvailable center, Update Available! +} +else, { + Gui, Add, Button, w%ColumnTwoEditBoxWidth% gUpdateScript vUpdateAvailable center, No Updates Available +} Gui, Font, s%GuiFontSize% @@ -256,20 +268,32 @@ Gui, Font, Normal ; Gui, Add, Checkbox,, Dlive -Gui, Add, Checkbox, vOdysee, Odysee -Gui, Add, Checkbox, vLocals, Locals +Gui, Add, Checkbox,checked vOdysee, Odysee +Gui, Add, Checkbox,checked vLocals, Locals Gui, Add, Checkbox,checked vRumble, Rumble Gui, Font, Bold -Gui, Add, Button,gSchedulePost w%ColumnTwoEditBoxWidth% gSaveAsTemplate y+50, Save as Template + +Gui, Font, S10 +Gui, Add, Button,gSchedulePost w%ColumnTwoEditBoxWidth% gSaveAsTemplate y+%marginsize%, Save as Template Gui, Add, Button,gSchedulePost w%ColumnTwoEditBoxWidth% gLoadTemplate, Load Template Gui, Font, s15 Gui, Add, Button,gSchedulePost w%ColumnTwoEditBoxWidth% h40, Schedule Gui, Font, Normal -Gui, Show, h%GuiHeight% +Gui, Show, h%GuiHeight%, %FullScriptName% + + + +;---Check for Updates--- +;------------------------------------------------ +if(AutoUpdateCheck AND !UpdateAvailable){ + SetTimer, CheckForUpdates, -1000 +} + + Return @@ -350,6 +374,11 @@ SchedulePost: Gui, submit, NoHide +; Save Settings.ini +; ------------------------------------------------ +IniWrite, %ConfirmBeforeSubmit%, %SettingsIniFilepath%, %ScriptSettingsSection%, ConfirmBeforeSubmit +IniWrite, %AutoUpdateCheck%, %SettingsIniFilepath%, %ScriptSettingsSection%, AutoUpdateCheck + ; Re-use an existing errorlog or create new directory if(InStr(PassedInArgument, "\ErrorLogging\")) @@ -506,6 +535,7 @@ Return #Include %A_ScriptDir%\Modules\Odysee-Schedule.ahk #Include %A_ScriptDir%\Modules\Odysee-Grab-URL.ahk #Include %A_ScriptDir%\Modules\Rumble-Schedule.ahk +#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Update-Functions.ahk ; Misc diff --git a/Lib/Freedomain-Posters-Shared-Functions b/Lib/Freedomain-Posters-Shared-Functions index 124a26c..0e02ae2 160000 --- a/Lib/Freedomain-Posters-Shared-Functions +++ b/Lib/Freedomain-Posters-Shared-Functions @@ -1 +1 @@ -Subproject commit 124a26c3b03e5f1292691909c20a116f64957955 +Subproject commit 0e02ae24bd4d909df30a58ba61693cef321fcaaa diff --git a/Modules/Rumble-Schedule.ahk b/Modules/Rumble-Schedule.ahk index 74be055..baaddd0 100644 --- a/Modules/Rumble-Schedule.ahk +++ b/Modules/Rumble-Schedule.ahk @@ -174,6 +174,29 @@ if(Status){ ; Select each Secondary Platform checkbox ; ------------------------------------------------ +IniRead, RumbleSecondaryPlatformsList, %SettingsIniFilepath%, %ScriptSettingsSection%, RumbleSecondaryPlatforms, %A_Space% + +if(RumbleSecondaryPlatformsList = ""){ + ; if variable is empty, get all items in the list and write them to .ini file + Loop, 10 { + + IndexPlusOne := A_index + 1 + Xpath = (//div[@class='flex shrink-0 items-center gap-x-4'])[%A_index%] + XpathCheckbox = (//div[@class='relative shrink-0'])[%IndexPlusOne%] + + try SecondaryPlatformCheckboxName := driver.findelementbyxpath(Xpath).Attribute("innerText") ;XPATH Inner Text + + RumbleSecondaryPlatformsList .= SecondaryPlatformCheckboxName . "--" + + if(SecondaryPlatformCheckboxName = "Add new destination" OR SecondaryPlatformCheckboxName = ""){ + Break + } + } + IniWrite, %RumbleSecondaryPlatformsList%, %SettingsIniFilepath%, %ScriptSettingsSection%, RumbleSecondaryPlatformsList + MsgBox 0x40, Rumble Secondary Platforms List Generated, Rumble Secondary Platforms List was genearted and all the available options were added to it.`n`nPlease edit the settings.ini file and remove any platforms you do not need selected from the follwoing KEY:`n`n[%ScriptSettingsSection%]`nRumbleSecondaryPlatformsList= +} + + Loop, 10 { IndexPlusOne := A_index + 1 @@ -187,6 +210,9 @@ Loop, 10 { Break } + if(!InStr(RumbleSecondaryPlatformsList,SecondaryPlatformCheckboxName)) + Continue + Status := Selenium_LoopToClickXpath(Xpath:=XpathCheckbox,NumOfLoops:=2,SleepLength:=1000) if(Status){ Message = Failed to check off the checkbox for: %SecondaryPlatformCheckboxName% @@ -261,11 +287,6 @@ Loop, 5 { } - - - - - Xpath = (//h2[@class='video-title'])[1] RumbleURLSlug := GetHTMLValueFromXpathOuterHTML(XPATH, "href") diff --git a/Version.ini b/Version.ini index 8e1363ff901681938f52f1ad8b2a4a6a3b041ef4..c8f9bafece70013c131c2eaa488a0dadd4a03404 100644 GIT binary patch delta 53 zcmYekWOUCWze0dughV?V93DBz{N0;DGJU80CPJE At^fc4 delta 18 ZcmdnMn8Nh`-$cJC4g&^523`g(1^_;p1kL~e