diff --git a/Freedomain Video Uploader.ahk b/Freedomain Video Uploader.ahk index 0dd99c6..c3a2bf0 100644 --- a/Freedomain Video Uploader.ahk +++ b/Freedomain Video Uploader.ahk @@ -296,7 +296,7 @@ Loop, files, %VideoFolderDir%\*.*, F ; loop through the files in the director } - if(FileExt = "png" OR FileExt = "jpg"){ + if(FileExt = "png" OR FileExt = "jpg" OR FileExt = "jpeg"){ VideoThumbFilepath := A_LoopFileFullPath } } @@ -348,8 +348,8 @@ Loop, files, %VideoFolderDir%\*.mp3, F ; loop through the files in the direct VideoLinksIniFile = %VideoFolderDir%\VideoLinks.ini if(FileExist(VideoLinksIniFile)){ - ; IniRead, StreamanityURL, %VideoLinksIniFile%, URLs, StreamanityURL, %A_Space% IniRead, BitChuteURL, %VideoLinksIniFile%, URLs, BitChuteURL, %A_Space% + ; LBRY IniRead, LBRYURLSlug, %VideoLinksIniFile%, Misc, LBRYURLSlug, %A_Space% if(LBRYURLSlug = ""){ @@ -377,7 +377,8 @@ if(FileExist(VideoLinksIniFile)){ IniRead, DailyMotionURL, %VideoLinksIniFile%, URLs, DailyMotionURL, %A_Space% IniRead, PodcastNumber, %VideoLinksIniFile%, Misc, PodcastNumber, %A_Space% IniRead, LocalsURL, %VideoLinksIniFile%, URLs, LocalsURL, %A_Space% - IniRead, FacebookURL, %VideoLinksIniFile%, URLs, FacebookURL, %A_Space% + IniRead, PodcastTranscriptURL, %VideoLinksIniFile%, URLs, PodcastTranscriptURL, %A_Space% + ; MISC IniRead, ErrorLoggingFilePath, %VideoLinksIniFile%, Misc, ErrorLoggingFilePath, %A_Space% @@ -1026,9 +1027,10 @@ if(SocialMediaPosterFilepath = "" or !FileExist(SocialMediaPosterFilepath)){ ; ------------------------------------------------ ; @todo: this can be converted into 1 gosub, with if/else statements based on the button clicked -CopyPodcastNumber: -Clipboard := PodcastNumber -SaveOrPostProgress(Message:=PodcastNumber "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") +CopyPodcastTranscriptURL: +Clipboard := PodcastTranscriptURL +Message := PodcastTranscriptURL . "`nCopied to Clipboard" +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") sleep, 1000 ToolTip Return @@ -1108,7 +1110,7 @@ Return ; @todo: Add thumbnail status to this ; @todo: add podcast tags to this UpdateINI: -IniWrite, %PodcastNumber%, %VideoLinksIniFile%, URLs, PodcastNumber +IniWrite, %PodcastTranscriptURL%, %VideoLinksIniFile%, URLs, PodcastTranscriptURL IniWrite, %VideoTitle%, %VideoLinksIniFile%, Misc, VideoTitle IniWrite, %LocalsURL%, %VideoLinksIniFile%, URLs, LocalsURL IniWrite, %RumbleURL%, %VideoLinksIniFile%, URLs, RumbleURL diff --git a/Modules/GUI-Main-Window.ahk b/Modules/GUI-Main-Window.ahk index a0606c8..6aff8d8 100644 --- a/Modules/GUI-Main-Window.ahk +++ b/Modules/GUI-Main-Window.ahk @@ -253,7 +253,7 @@ Gui, Font, Bold ; Settings Section Gui, Add, GroupBox,r5 y+0 x%PageTwoXStartPos% w%PageTwoGroupBoxWidth%,Settings Gui, Add, Checkbox, xp+10 yp+20 vAutoUpdateCheck gUpdateVars Checked%AutoUpdateCheckCheckStatus%, Auto Update Check -Gui, Add, Checkbox, vShowTooltipProgress Checked%ShowTooltipProgressCheckStatus% gUpdateVars,Show Tooltip Progress +Gui, Add, Checkbox, vShowTooltipProgress Checked%ShowTooltipProgressCheckStatus% gUpdateVars,Show Tooltip of Actions Gui, Add, Checkbox, vKillLBRYAfterUpload Checked%KillLBRYAfterUploadCheckStatus%, Kill LBRY After Uploading Gui, Add, Checkbox, vAutoLogin gUpdateVars Checked%AutoLoginCheckStatus%, Try to Login Automatically Gui, Add, Checkbox, vPingOnCompletion gUpdateVars Checked%PingOnCompletionCheckStatus%, Discord Ping Upon Completion diff --git a/Modules/GUI-Results-Window.ahk b/Modules/GUI-Results-Window.ahk index eada9a0..be8e561 100644 --- a/Modules/GUI-Results-Window.ahk +++ b/Modules/GUI-Results-Window.ahk @@ -1,10 +1,9 @@ Gui, Font, s%GuiFontSize% Gui, Font, Bold -; Gui, Add, Text,x10 y+10, Podcast #: -Gui, Add, Button, x10 y+%Marginspace% h%ButtonHeights% w%CopyButtonWidths% gCopyPodcastNumber, Podcast # +Gui, Add, Button, x10 y+%Marginspace% h%ButtonHeights% w%CopyButtonWidths% gCopyPodcastTranscriptURL,Transcript URL Gui, Font, Normal -Gui, Add, Edit, x+5 yp+0 h%ButtonHeights% w%ResultEditBoxWidths% gUpdateVars vPodcastNumber, %PodcastNumber% +Gui, Add, Edit, x+5 yp+0 h%ButtonHeights% w%ResultEditBoxWidths% gUpdateVars vPodcastTranscriptURL, %PodcastTranscriptURL% Gui, Font, Bold Gui, Add, Button, x10 y+%Marginspace% h%ButtonHeights% w%CopyButtonWidths% gCopyBitChuteURL, Bitchute diff --git a/Modules/Miscellaneous-Functions.ahk b/Modules/Miscellaneous-Functions.ahk index 02e6a36..307d7a3 100644 --- a/Modules/Miscellaneous-Functions.ahk +++ b/Modules/Miscellaneous-Functions.ahk @@ -13,7 +13,7 @@ OnMsgBoxConfirmChromiumOverwrite() { ; https://www.autohotkey.com/docs/v2/Functions.htm#Variadic Join(sep, params*) { For index, param in params - str .= param . sep + str .= param . sep return SubStr(str, 1, -StrLen(sep)) } @@ -254,18 +254,54 @@ Check_For_Stuck_Video_Upload(Index_Number, Upload_Status){ } } ; end of func - +/* +*/ ; Find the longest word in a string of words - FindLongestWordInString(m, calloutNumber, pos, haystack, pattern){ - Global wordLength, longestWord +FindLongestWordInString(m, calloutNumber, pos, haystack, pattern){ + Global wordLength, longestWord - len := StrLen(m) + len := StrLen(m) - If ( len > wordLength ) - { - wordLength := len - longestWord := m + If ( len > wordLength ) + { + wordLength := len + longestWord := m + + ; MsgBox, %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 . "\. " } - } \ No newline at end of file + } + + if (currentChunk != "") + chunks.Push(currentChunk) + + return chunks +} + diff --git a/Modules/Post-To-Discord.ahk b/Modules/Post-To-Discord.ahk index 949ff07..9a256f8 100644 --- a/Modules/Post-To-Discord.ahk +++ b/Modules/Post-To-Discord.ahk @@ -25,13 +25,10 @@ if(SocialMediaDescription = ""){ CreateDescriptionForSocialMedia() } -; Msgbox % "SocialMediaDescription: " SocialMediaDescription SubmitDescriptionForDiscordVideosChannel: Message := "**" . VideoTitle . "**" . "`n" . SocialMediaDescription . "`n" ; https://stackoverflow.com/questions/63160401/how-to-create-hyperlink-in-discord-in-an-embed-in-general -; Do this with an array!! -; if(BitChuteURL != "") Message .= "[BitChute](<" . BitChuteURL . ">) \| " @@ -44,23 +41,18 @@ Message .= "[Odysee](<" . OdyseeVideoURL . ">) \| " if(OdyseeAudioURL != "") Message .= "[Odysee (Audio)](<" . OdyseeAudioURL . ">) \| " -/* -if(OdyseeVideoURL != "") -Message .= "[Odysee](<" . OdyseeVideoURL . ") \| " -if(OdyseeAudioURL != "") -Message .= "[Odysee Audio](<" . OdyseeAudioURL . ") \| " - -*/ if(RumbleURL != "") Message .= "[Rumble](<" . RumbleURL . ">) \| " -/*if(StreamanityURL != "" AND InStr(StreamanityURL, "streamanity.com")) -Message .= "[Streamanity](<" . StreamanityURL . ">) \| " - -*/ if(DailyMotionURL != "") -Message .= "[DailyMotion](<" . DailyMotionURL . ">)" +Message .= "[DailyMotion](<" . DailyMotionURL . ">) \| " + +if(PodcastTranscriptURL != "") +Message .= "[Video Transcript](<" . PodcastTranscriptURL . ">) \| " + +if(PodcastNumber != "") +Message .= "[FDRPodcasts](<" . "https://fdrpodcasts.com/" . PodcastNumber . ">) \| " UploadImageToDiscord(DiscordVideosWebhookURL, Message, VideoThumbFilepath) diff --git a/Modules/Post-To-Telegram.ahk b/Modules/Post-To-Telegram.ahk index 23e646d..50dbe6d 100644 --- a/Modules/Post-To-Telegram.ahk +++ b/Modules/Post-To-Telegram.ahk @@ -56,24 +56,19 @@ VideoLinks .= "[Odysee](" . OdyseeVideoURL . ") \| " if(OdyseeAudioURL != "") VideoLinks .= "[Odysee \(Audio\)](" . OdyseeAudioURL . ") \| " -/* -if(OdyseeVideoURL != "") -VideoLinks .= "[Odysee](" . OdyseeVideoURL . ") \| " -if(OdyseeAudioURL != "") -VideoLinks .= "[Odysee Audio](" . OdyseeAudioURL . ") \| " - -*/ if(RumbleURL != "") VideoLinks .= "[Rumble](" . RumbleURL . ") \| " -/* -if(InStr(StreamanityURL, "https://streamanity.com/video/")) -VideoLinks .= "[Streamanity](" . StreamanityURL . ") \| " -*/ if(DailyMotionURL != "") VideoLinks .= "[DailyMotion](" . DailyMotionURL . ") \| " +if(PodcastTranscriptURL != "") +VideoLinks .= "[Video Transcript](" . PodcastTranscriptURL . ") \| " + +if(PodcastNumber != "") +VideoLinks .= "[FDRPodcasts](" . "https://fdrpodcasts.com/" . PodcastNumber . ") \| " + TelegramMessage := TelegramVideoTitle . "`n" . TelegramBodymessage . "`n" . VideoLinks @@ -83,86 +78,73 @@ StrLenOfMessageAndVideoLinks := StrLen(TelegramVideoTitle) + StrLen(TelegramBody ; DevModeMsgBox(StrLenOfMessageAndVideoLinks) -if(StrLenOfMessageAndVideoLinks > 1024){ - ; Telegram SendMessage is limited to 4096 characters - if(StrLenOfMessageAndVideoLinks < 4096){ ; split into sendphoto and 1 sendmessage - ; DevModeMsgBox("Less than 4096 chars") - ; Photo and Video Title go into SendPhoto - TelegramVideoTitle := TelegramVideoTitle . "`n" . VideoLinks - Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, VideoThumbFilepath, caption := TelegramVideoTitle ) ; you could add more options; compare the Telegram API docs - - ; Video Description goes into TelegramMessage - Status2 := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBodymessage) - - } ; split into 2 SendMessages - else if (StrLenOfMessageAndVideoLinks > 4096 AND StrLenOfMessageAndVideoLinks < 8192){ ; Split into 2 parts - TelegramVideoTitle := TelegramVideoTitle . "`n" . VideoLinks - Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, VideoThumbFilepath, caption := TelegramVideoTitle ) ; you could add more options; compare the Telegram API docs +; If Length of Title, Video Links and Message is less than 1024 characters: +; ------------------------------------------------ +if(StrLenOfMessageAndVideoLinks < 1024) { + Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, VideoThumbFilepath, caption := TelegramMessage ) ; you could add more options; compare the Telegram API docs + if(InStr(Status, "error_code")){ + Message = Telegram Post Failed due to an API Issue. Error was saved to ErrorLogging file. Please send it to Yuriy. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - TelegramBodymessagePiece := SubStr(TelegramBodymessage, 1, 4096) - Status2 := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBodymessagePiece) + ; SaveOrPostProgress(Message:=Status,PostType:=",ErrorLoggingTextFile") + Message = Telegram Error: %Status% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - TelegramBodymessagePiece := SubStr(TelegramBodymessage, 4097, 8192) - Status3 := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBodymessagePiece) + ToolTip + Return + } +} - } ; split into 3 sendMessages - else if (StrLenOfMessageAndVideoLinks > 8192 AND StrLenOfMessageAndVideoLinks < 12288){ ; Split into 3 parts - TelegramVideoTitle := TelegramVideoTitle . "`n" . VideoLinks - Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, VideoThumbFilepath, caption := TelegramVideoTitle ) ; you could add more options; compare the Telegram API docs - TelegramBodymessagePiece := SubStr(TelegramBodymessage, 1, 4096) - msgbox % StrLen(TelegramBodymessagePiece) - Status2 := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBodymessagePiece) +; If Title, Links and Message are longer than 1024, but less than 4096, split into 2 pieces: sendphoto and sendmessage +; ------------------------------------------------ +if(StrLenOfMessageAndVideoLinks < 4096){ + ; Photo and Video Title go into SendPhoto + TelegramVideoTitle := TelegramVideoTitle . "`n" . VideoLinks + Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, VideoThumbFilepath, caption := TelegramVideoTitle ) ; you could add more options; compare the Telegram API docs + ; Video Description goes into TelegramMessage + Status2 := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBodymessage) - TelegramBodymessagePiece := SubStr(TelegramBodymessage, 4097, 8192) - msgbox % StrLen(TelegramBodymessagePiece) - DevModeMsgBox(TelegramBodymessagePiece) - Status3 := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBodymessagePiece) +} else, { +; If Title, links and message are longer than 4096 chars, we need to split them into multiple messages +; ------------------------------------------------ +TelegramVideoTitle := TelegramVideoTitle . "`n" . VideoLinks +Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, VideoThumbFilepath, caption := TelegramVideoTitle ) ; you could add more options; compare the Telegram API docs - ; TelegramBodymessagePiece := SubStr(TelegramBodymessage, 8193, 12288) - ; Status3 := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBodymessagePiece) - } +; Split the Description into 4096 character chunks while preserving sentences +; Used 4095 because a ". " has to be put in at the end of the chunk. +VideoDescriptionChunks := SplitStringWithSentences(TelegramBodymessage, 4094) - } else, { ; if less than 1024 characters, send normally - Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, VideoThumbFilepath, caption := TelegramMessage ) ; you could add more options; compare the Telegram API docs - if(InStr(Status, "error_code")){ - Message = Telegram Post Failed due to an API Issue. Error was saved to ErrorLogging file. Please send it to Yuriy. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - ; SaveOrPostProgress(Message:=Status,PostType:=",ErrorLoggingTextFile") - Message = Telegram Error: %Status% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") +; go through array and post each chunk as new message +Loop % VideoDescriptionChunks.Length(){ + ; ArrayItem := ARRAY[A_Index] + Description := VideoDescriptionChunks[A_Index] - ToolTip - Return - } - } - ; Msgbox % "SizeOfCaption: " SizeOfCaption - ; SizeOfCaption := SizeOfCaption + - ; Message .= VideoLinks - ; msgbox % StrLen(VideoLinks) + SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := Description) + ; Clipboard := Description + ; msgbox % Description - ; Message := StrReplace(Message, "`n", LineBreakChar) ; replace all new line characters with the global charater +} - ; msgbox % StrLen(Message) - ; SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordVideos") +} - ; SaveOrPostProgress(Message:="Video Links posted to #Videos Successfully.",PostType:="Tooltip,ErrorLoggingTextFile") - Message = Video Links Posted to Telegram Successfully - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - GuiControl,, PostToTelegramButton, Telegram - Posted Successfully +; SaveOrPostProgress(Message:="Video Links posted to #Videos Successfully.",PostType:="Tooltip,ErrorLoggingTextFile") +Message = Video Links Posted to Telegram Successfully +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") +GuiControl,, PostToTelegramButton, Telegram - Posted Successfully - ; sleep, 2000 +; sleep, 2000 - ToolTip - CurrentSite := - Return - ; -------------------------------/Telegram------------------------------- +ToolTip +CurrentSite := +Return +; -------------------------------/Telegram------------------------------- diff --git a/Version.ini b/Version.ini index 836e2e7..234fcf9 100644 --- a/Version.ini +++ b/Version.ini @@ -1,3 +1,3 @@ [Video-Uploader] -Version=3.33 +Version=3.34 Name=Freedomain Video Uploader