From 4beb83caa6a37f8940f6ffe64fe064b0fe952ff8 Mon Sep 17 00:00:00 2001 From: yuriy Date: Fri, 21 Jun 2024 17:37:43 -0400 Subject: [PATCH] reworked discord message formatting, code cleanup --- Freedomain Video Uploader.ahk | 13 ----------- Lib/Freedomain-Posters-Shared-Functions | 2 +- Modules/GUI-Main-Window.ahk | 2 +- Modules/Post-To-Discord.ahk | 30 +++++++++++++------------ Version.ini | 2 +- 5 files changed, 19 insertions(+), 30 deletions(-) diff --git a/Freedomain Video Uploader.ahk b/Freedomain Video Uploader.ahk index d080b23..cd6adcc 100644 --- a/Freedomain Video Uploader.ahk +++ b/Freedomain Video Uploader.ahk @@ -618,19 +618,6 @@ Return */ -CreateDescriptionForSocialMedia(){ - SplitText = Free Documentaries: - - SocialMediaDescription := StrSplit(VideoDescription, SplitText) - SocialMediaDescription := SocialMediaDescription[1] - - if(strlen(SocialMediaDescription) > 1400){ - SocialMediaDescription := SubStr(SocialMediaDescription, 1, 1400) - SocialMediaDescription .= "..." - } - - Return -} ; -------------------------------Upload Video Functionality------------------------------- StartScript: WinGetPos, XPosition, YPosition, , , A diff --git a/Lib/Freedomain-Posters-Shared-Functions b/Lib/Freedomain-Posters-Shared-Functions index a3d89a9..6bf7233 160000 --- a/Lib/Freedomain-Posters-Shared-Functions +++ b/Lib/Freedomain-Posters-Shared-Functions @@ -1 +1 @@ -Subproject commit a3d89a989282e2c852b72b7e6d02a1a88ee53ee4 +Subproject commit 6bf72336d0af0aa57064fc40c267677bb27577f3 diff --git a/Modules/GUI-Main-Window.ahk b/Modules/GUI-Main-Window.ahk index 382b226..23be0c9 100644 --- a/Modules/GUI-Main-Window.ahk +++ b/Modules/GUI-Main-Window.ahk @@ -432,7 +432,7 @@ Gui, Add, Button, x%MarginSize% w%ResultsEditAndCopyButtonWidth% h%SecondaryButt ; Error Log Column ; ------------------------------------------------ Gui, Font, s%GuiFontSize% -Gui, Add, Button, x+%MarginSize% y%MarginSize% w%ErrorLogEditBoxWidth% h%ButtonHeights% y%MarginSize%, Error Log +Gui, Add, Button, x+%MarginSize% y%MarginSize% w%ErrorLogEditBoxWidth% h%ButtonHeights% y%MarginSize% gOpenErrorLog, Error Log (Click to Open Detailed Log) Gui, Add, Edit,x%ErrorLogEditBoxXPos% h%ErrorLogEditBoxHeight% w%ErrorLogEditBoxWidth% y+10, %ErrorLogVar% gui, font, Normal diff --git a/Modules/Post-To-Discord.ahk b/Modules/Post-To-Discord.ahk index 8c5d6fc..6ef4784 100644 --- a/Modules/Post-To-Discord.ahk +++ b/Modules/Post-To-Discord.ahk @@ -13,22 +13,10 @@ if(DiscordVideosWebhookURL = ""){ Msgbox, Unable to Grab DiscordVideosWebhookURL from %SettingsIniFilepath%.`nPlease input the URL and then try again. Return } - -/* -; If description is longer than 2k chars, then API will error out. goto section that will allow user to edit video description to shorten it for posting -if(StrLen(SocialMediaDescription) > 2000 AND VideoDescriptionForVideosChannel = ""){ - Goto, CreateDescriptionForVideosPosting -} - -*/ -if(SocialMediaDescription = ""){ - CreateDescriptionForSocialMedia() -} +; https://stackoverflow.com/questions/63160401/how-to-create-hyperlink-in-discord-in-an-embed-in-general -SubmitDescriptionForDiscordVideosChannel: -Message := "**" . VideoTitle . "**" . "`n" . SocialMediaDescription . "`n" -; https://stackoverflow.com/questions/63160401/how-to-create-hyperlink-in-discord-in-an-embed-in-general +Message := if(BitChuteURL != "") Message .= "[BitChute](<" . BitChuteURL . ">) \| " @@ -55,6 +43,20 @@ if(PodcastNumber != "") Message .= "[FDRPodcasts](<" . "https://fdrpodcasts.com/" . PodcastNumber . ">) \| " +; StrLenOfDiscordMessage := + +; trim the video description if Title + Body + Links is longer than 2000 chars +if((StrLen(VideoTitle) + StrLen(VideoDescription) + StrLen(Message)) > 2000){ + + DiscordAPICharsLeft := 2000 - StrLen(VideoTitle) - StrLen(Message) - 15 + + DiscordVideoDescription := SubStr(VideoDescription, 1, DiscordAPICharsLeft) . "..." +} +else, +DiscordVideoDescription := VideoDescription + +Message := "**" . VideoTitle . "**" . "`n" . DiscordVideoDescription . "`n" . Message + Status := UploadImageToDiscord(DiscordVideosWebhookURL, Message, VideoThumbFilepath) Message = API Response:`n%Status% SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile") diff --git a/Version.ini b/Version.ini index 02e4983..5d200c2 100644 --- a/Version.ini +++ b/Version.ini @@ -1,3 +1,3 @@ [Video-Uploader] -Version=3.37 +Version=3.39 Name=Freedomain Video Uploader