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.
video-uploader/Modules/Post-To-Discord.ahk

107 lines
3.8 KiB
Plaintext

PostToDiscord:
;------------------------------------------------
CurrentSite := "Discord"
if(!FileExist(VideoThumbFilepath)){
Message = Post Aborted.`nVideo Thumbnail not found at:`n%VideoThumbFilepath%
SaveOrPostProgress(Message,PostType:="ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
MsgBox 0x10,, %Message%
Return
}
Message = Posting Video Links to Discord
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
IniRead, DiscordVideosWebhookURL, %SettingsIniFilepath%, General, DiscordVideosWebhookURL, %A_Space%
if(DiscordVideosWebhookURL = ""){
Message = Unable to Grab DiscordVideosWebhookURL from %SettingsIniFilepath%.`nPlease input the URL and then try again.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Msgbox, Unable to Grab DiscordVideosWebhookURL from %SettingsIniFilepath%.`nPlease input the URL and then try again.
Return
}
; https://stackoverflow.com/questions/63160401/how-to-create-hyperlink-in-discord-in-an-embed-in-general
; clear out variables in case the button is clicked twice
VideoLinks :=
Message :=
DiscordVideoDescription :=
TooltipMessage = Checking Bitchute and Brighteon URL for Processing Status
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; check the status of the Bitchute URL to see if it's done processing
; shows "404 - Page not found" on page if not
if(BitChuteURL){
if(!InStr(URLDownloadToVar(BitChuteURL), "404 - Page not found")){
if(BitChuteURL != "")
VideoLinks .= "[BitChute](<" . BitChuteURL . ">) \| "
}
else, {
LogMessage = Bitchute URL skipped, URL Currently leads to: 404 - page not found
SaveOrPostProgress(Message:=LogMessage,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
}
}
; check the status of the Brighteon URL to see if it's done processing
; shows "404 - Page not found" on page if not
if(BrighteonURL){
if(!InStr(URLDownloadToVar(BrighteonURL), "SELECTED IS NOT CURRENTLY AVAILABLE")){
if(BrighteonURL != "")
VideoLinks .= "[Brighteon](<" . BrighteonURL . ">) \| "
}
else, {
ErrorLogMsg = Brighteon URL skipped, URL Currently leads to: 404 - page not found
SaveOrPostProgress(Message:=ErrorLogMsg,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
}
}
if(OdyseeVideoURL != "")
VideoLinks .= "[Odysee](<" . OdyseeVideoURL . ">) \| "
if(OdyseeAudioURL != "")
VideoLinks .= "[Odysee (Audio)](<" . OdyseeAudioURL . ">) \| "
if(RumbleURL != "")
VideoLinks .= "[Rumble](<" . RumbleURL . ">) \| "
if(DailyMotionURL != "")
VideoLinks .= "[DailyMotion](<" . DailyMotionURL . ">) \| "
if(PodcastTranscriptURL != "")
VideoLinks .= "[Video Transcript](<" . PodcastTranscriptURL . ">) \| "
if(PodcastNumber != "")
VideoLinks .= "[FDRPodcasts](<" . "https://fdrpodcasts.com/" . PodcastNumber . ">) \| "
; trim the video description if Title + Body + Links is longer than 2000 chars
if((StrLen(VideoTitle) + StrLen(VideoDescription) + StrLen(VideoLinks)) > 2000){
DiscordAPICharsLeft := 2000 - StrLen(VideoTitle) - StrLen(VideoLinks) - 15
DiscordVideoDescription := SubStr(VideoDescription, 1, DiscordAPICharsLeft) . "..."
}
else,
DiscordVideoDescription := VideoDescription
Message = VideoLinks variable contents:
Message := "**" . VideoTitle . "**" . "`n" . DiscordVideoDescription . "`n`n" . VideoLinks
Status := UploadImageToDiscord(DiscordVideosWebhookURL, Message, VideoThumbFilepath)
Message = API Response:`n%Status%
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile")
SaveOrPostProgress(Message:="Video Links posted to #Videos Successfully.",PostType:="Tooltip,ErrorLoggingTextFile")
GuiControl,, PostToDiscordButton, Discord - Posted Successfully
sleep, 2000
ToolTip
; Msgbox,,Success,Video Links posted to #Videos Successfully.
; ToolTip
Return
; -------------------------------/Discord-------------------------------