You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
livestream-scheduler/Freedomain Livestream Sched...

428 lines
11 KiB
Plaintext

5 months ago
; ENVIRONMENT
;------------------------------------------------
#Requires AutoHotkey v1.0
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
;#Warn ; Enable warnings to assist with detecting common errors.
;DetectHiddenWindows, On
#SingleInstance, Force
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
; Customize the Toolbar Icon Menu
; ------------------------------------------------
Menu, tray, NoStandard
Menu, Tray, Add, Exit, KillScript
Menu, Tray, Add, Pause, PauseScript
; Menu, Tray, Add, Show Results, DisplayResults
Menu, Tray, Add, Schedule New Livestream, ReloadScript
Menu, Tray, Add, Restart with Last Item, RetryUpload
Menu, Tray, Default, Restart with Last Item
5 months ago
; Notes/Extra Info/#Includes
;------------------------------------------------
PassedInArgument = %1%
; Check if Update was just installed and delete the old .exe if so
CheckIfUpdateInstalled(PassedInArgument)
5 months ago
; Included Files and Libraries
; ------------------------------------------------
; These have to be included at the top for the Global variables to get registered early
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Locals-Functions.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\General-Functions.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Selenium-Functions.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Chrome-Functions.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Gitea-Functions.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\API-Functions.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\JSON.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\Zip.ahk
#include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\URLDownloadToVar.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Miscellaneous-Functions.ahk
5 months ago
; VARIABLES
;------------------------------------------------
;---Global Variables---
;------------------------------------------------
global ScriptNameav
global ScriptVersion
global FullScriptName
global PostStatusesFilepath
global ErrorLoggingDirectory
5 months ago
global DiscordErrorLoggingWebhookBotURL
global DiscordVideosWebhookURL
global VideoFolderDir
global LogErrorsToMsgbox
; global LogErrorsToTextFile
global CurrentSite
global Driver
global DriverStatus
global ChromeProfile
global ShowTooltipProgressCheckStatus
global ShowTooltipProgress
ShowTooltipProgress := 1
global ErrorLogSummary
global DiscordParlerWebhookURL
global ErrorLoggingFilePath
; global TotalTabLoops
global ErrorLogVar
ErrorLogVar :=
global DevMode
; Check if Lib folder exists and create it if not
LibFolder := A_ScriptDir . "\Lib"
ErrorLoggingFolder := A_ScriptDir . "\Lib\ErrorLogging"
FileCreateDir, %ErrorLoggingFolder%
; Set filepaths for different files and folders
global SettingsIniFilepath
SettingsIniFilepath := A_ScriptDir . "\Settings.ini"
global ScriptSettingsSection
ScriptSettingsSection := "Livestream-Scheduler"
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 ScriptAbbreviatedName := "FLS" ; used for error logging
5 months ago
FullScriptName := ScriptName . " - " . ScriptVersion
; Read Info From Files
; ------------------------------------------------
; For Templates and re-trying a failed previous run
if(StrLen(PassedInArgument) > 5 and !InStr(PassedInArgument, ".exe")){
/*FileAppend, %LivestreamTitle%, %PostTitleFilePath% ; save post content to txt file
FileAppend, %LivestreamDescription%, %PostBodyFilePath% ; save post content to txt file
FileAppend, %LivestreamTags%, %PostTagsFilePath% ; save post content to txt file
if(LivestreamThumbnail){ ; copy thumbnail into folder
SplitPath, LivestreamThumbnail, OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive
FileCopy, %LivestreamThumbnail%, %ErrorLoggingDirectory%\Thumbnail.%OutExtension%
}
*/
TemplateDirectory := PassedInArgument
FileRead, LivestreamTitle, %TemplateDirectory%\PostTitle.txt
FileRead, LivestreamDescription, %TemplateDirectory%\PostBody.txt
FileRead, LivestreamTags, %TemplateDirectory%\PostTags.txt
ThumbnailPNGFilepath = %TemplateDirectory%\Thumbnail.png
ThumbnailJPGFilepath = %TemplateDirectory%\Thumbnail.jpg
ThumbnailJPEGFilepath = %TemplateDirectory%\Thumbnail.jpg
if(FileExist(ThumbnailPNGFilepath))
LivestreamThumbnail := ThumbnailPNGFilepath
if(FileExist(ThumbnailJPGFilepath))
LivestreamThumbnail := ThumbnailJPGFilepath
if(FileExist(ThumbnailJPEGFilepath))
LivestreamThumbnail := ThumbnailJPEGFilepath
}
5 months ago
; GUI Variables
; ------------------------------------------------
MarginSize := 10
MarginSizeDoubled := MarginSize * 2
ButtonHeights := 30
5 months ago
ThumbnailPreviewWidth := 200
5 months ago
GuiHeight := 450
; Column One
ColumnOneWidth := 400
ColumnOneEditBoxWidth := ColumnOneWidth - (MarginSize * 2)
GuiFontSize = 10
; Column Two
ColumnTwoXPosition := ColumnOneWidth + (MarginSize * 2)
ColumnTwoEditBoxWidth := 200
; Results Screen
ResultButtonWidth := 150
ResultButtonEditWidth := 250
ResultButtonHeights := 30
; START OF GUI
; ------------------------------------------------
Gui, Font, s%GuiFontSize%
; Column One
5 months ago
;------------------------------------------------
Gui, Font, Bold
5 months ago
Gui, Add, Text,, Title
Gui, Font, Normal
Gui, Add, Edit,w%ColumnOneEditBoxWidth% vLivestreamTitle, %LivestreamTitle%
5 months ago
Gui, Font, Bold
5 months ago
Gui, Add, Text,, Description
Gui, Font, Normal
Gui, Add, Edit,w%ColumnOneEditBoxWidth% h150 vLivestreamDescription, %LivestreamDescription%
5 months ago
Gui, Font, Bold
Gui, Add, Text,, Tags
Gui, Font, Normal
Gui, Add, Edit,w%ColumnOneEditBoxWidth% vLivestreamTags, %LivestreamTags%
5 months ago
Gui, Font, Bold
Gui, Add, Text,, Thumbnail
Gui, Font, Normal
Gui, Add, Button, x+%MarginSize% yp-3 gSelectThumbnail, Select
Gui, Add, Picture, x%MarginSize% w%ThumbnailPreviewWidth% h-1 vThumbnailPreview, %LivestreamThumbnail%
5 months ago
; Gui, Add, Edit,w%ColumnOneEditBoxWidth% h150 vLivestreamDescription, This livestream is happening soon!
; Column Two
; ------------------------------------------------
Gui, Font, s%GuiFontSize%
Gui, Font, Bold
; Gui, Add, Text, , Settings
Gui, Add, Text,y0 x%ColumnTwoXPosition%, Settings
Gui, Font, Normal
Gui, Add, Checkbox, vConfirmBeforeSubmit checked, Confirm Before Submit
Gui, Font, s%GuiFontSize%
Gui, Font, Bold
; Gui, Add, Text, , Settings
Gui, Add, Text, y+%MarginSizeDoubled%, Date and Time of Livestream
Gui, Font, Normal
Gui, Add, DateTime, vLivestreamDate w%ColumnTwoEditBoxWidth%, MM/dd/yyyy
Gui, Add, DateTime, vLivestreamTime w%ColumnTwoEditBoxWidth%, Time
Gui, Font, Bold
Gui, Add, Text,y+%MarginSizeDoubled%, Platform to Schedule On
Gui, Font, Normal
; Gui, Add, Checkbox,, Dlive
Gui, Add, Checkbox, checked vLocals, Locals
; Gui, Add, Checkbox,checked vOdysee, Odysee
Gui, Font, Bold
Gui, Add, Button,gSchedulePost w%ColumnTwoEditBoxWidth% y+50 gSaveAsTemplate, Save as Template
Gui, Add, Button,gSchedulePost w%ColumnTwoEditBoxWidth% gLoadTemplate, Load Template
Gui, Font, s15
Gui, Add, Button,gSchedulePost w%ColumnTwoEditBoxWidth% h40 y+50, Schedule
Gui, Font, Normal
Gui, Show, h%GuiHeight%
5 months ago
Return
; Functions
;------------------------------------------------
SaveAsTemplate:
Gui, submit, NoHide ; Update variables for all modified fields
TemplateDirectory = %A_ScriptDir%\Lib\Templates-%ScriptAbbreviatedName%
if(!FileExist(TemplateDirectory)){
FileCreateDir, %TemplateDirectory%
}
InputBox, TemplateName, Input Name, Please Input Name for the Template:
if(ErrorLevel)
Return
TemplateDirectory = %TemplateDirectory%\%TemplateName%
ErrorLoggingDirectory := TemplateDirectory
; FileCreateDir, %TemplateDirectory%
CreateErrorLoggingFiles(ErrorLoggingDirectory)
; Save all the post settings to the Error Logging Directory
FileAppend, %LivestreamTitle%, %PostTitleFilePath% ; save post content to txt file
FileAppend, %LivestreamDescription%, %PostBodyFilePath% ; save post content to txt file
FileAppend, %LivestreamTags%, %PostTagsFilePath% ; save post content to txt file
if(LivestreamThumbnail){ ; copy thumbnail into folder
SplitPath, LivestreamThumbnail, OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive
FileCopy, %LivestreamThumbnail%, %ErrorLoggingDirectory%\Thumbnail.%OutExtension%
}
Return
LoadTemplate:
Message = Loading Template
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,DiscordErrorLogging")
ErrorLoggingDirectory = %A_ScriptDir%\Lib\Templates-%ScriptAbbreviatedName%\
FileSelectFolder, ErrorLoggingDirectory, %ErrorLoggingDirectory%
if(ErrorLevel){
Tooltip
Return
}
RetryUpload:
run, "%A_ScriptFullPath%" "%ErrorLoggingDirectory%"
ExitApp
SelectThumbnail:
FileSelectFile, LivestreamThumbnail,
GuiControl, , ThumbnailPreview, *w%ThumbnailPreviewWidth% *h-1 %LivestreamThumbnail%
Return
5 months ago
SchedulePost:
Gui, submit, NoHide
; Re-use an existing errorlog or create new directory
if(InStr(PassedInArgument, "\ErrorLogging\"))
CreateErrorLoggingFiles(PassedInArgument)
else, {
CreateErrorLoggingFiles()
5 months ago
; Save all the post settings to the Error Logging Directory
FileAppend, %LivestreamTitle%, %PostTitleFilePath% ; save post content to txt file
FileAppend, %LivestreamDescription%, %PostBodyFilePath% ; save post content to txt file
FileAppend, %LivestreamTags%, %PostTagsFilePath% ; save post content to txt file
5 months ago
if(LivestreamThumbnail){ ; copy thumbnail into folder
SplitPath, LivestreamThumbnail, OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive
FileCopy, %LivestreamThumbnail%, %ErrorLoggingDirectory%\Thumbnail.%OutExtension%
}
5 months ago
}
5 months ago
if(Odysee){
Gosub, OdyseeSchedule
}
if(Locals){
Gosub, LocalsSchedule
}
; msgbox, done!
; Gui, Add,
Gui, Destroy
5 months ago
; Results Screen
; ------------------------------------------------
IniRead, LocalsRTMPURL, %PostStatusesFilepath%, Livestream,LocalsRTMPURL, %A_Space%
IniRead, LocalsRTMPKey, %PostStatusesFilepath%, Livestream,LocalsRTMPKey, %A_Space%
; IniRead, OutputVar, Filename, Section, Key [, Default]
Gui, Font, Bold
Gui, Font, s%GuiFontSize%
Gui, Add, Button, x10 y+10 h%ResultButtonHeights% w%ResultButtonWidth%, Locals RTMP Key
Gui, Add, Edit, x+5 yp+0 h%ResultButtonHeights% w%ResultButtonEditWidth% vLocalsRTMPKey center, %LocalsRTMPKey%
Gui, Add, Button, x10 y+10 h%ResultButtonHeights% w%ResultButtonWidth%, Locals RTMP URL
Gui, Add, Edit, x+5 yp+0 h%ResultButtonHeights% w%ResultButtonEditWidth% vLocalsRTMPURL center, %LocalsRTMPURL%
Gui, Add, Button, gRetryUpload,Try Failed Again
Gui, Show
5 months ago
Return
; GoSubs
; ------------------------------------------------
KillScript:
ExitApp
ReloadScript:
Reload
PauseScript:
Pause
Return
#Include %A_ScriptDir%\Modules\Locals-Schedule.ahk
#Include %A_ScriptDir%\Modules\Odysee-Schedule.ahk
5 months ago
; Misc
;------------------------------------------------
; Escape::ExitApp