From 6b9038b15a4eaa8e8905f9258bbd125a6f3b5e56 Mon Sep 17 00:00:00 2001 From: "James A. Pyrich" Date: Tue, 2 Jan 2024 13:04:08 -0700 Subject: [PATCH] #12, maybe also #13: change VideoTags parsing a bit to fix some minor issues with Brighteon --- Freedomain Video Uploader.ahk | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/Freedomain Video Uploader.ahk b/Freedomain Video Uploader.ahk index ec15eae..d67eba6 100644 --- a/Freedomain Video Uploader.ahk +++ b/Freedomain Video Uploader.ahk @@ -1155,15 +1155,29 @@ JSVideoDescription := FormatTextToJSText(VideoDescription) ; -------------------------------/Log Info To Text------------------------------- +; This should go somewhere appropriate +; fwiw this function comes straight from the docs: https://www.autohotkey.com/docs/v2/Functions.htm#Variadic +Join(sep, params*) { + For index, param in params + str .= param . sep + return SubStr(str, 1, -StrLen(sep)) +} ; Create an array out of the keywords to be used in different places -VideoTags := StrReplace(VideoTags, ", ",",") -VideoTags := StrReplace(VideoTags, " ,",",") -VideoTags := StrReplace(VideoTags, " ",",") - -KeywordsArray := StrSplit(VideoTags,",") - +KeywordsArray := Array() +For idx, val in StrSplit(VideoTags, ",") { + ; for each element in the split videotags array, trim leading & trailing spaces + val := Trim(val) + ; and remove any chars that are not a letter, number, or space (i = case-insensitive) + ; note: it would be better to replace accented chars w/ their pure latin equivalents but that seems a bit + ; beyond the scope of this change. here's a link talking about how to do that tho + ; https://www.autohotkey.com/boards/viewtopic.php?t=61626 + val := RegexReplace(val, "i)[^a-z0-9 ]", "") + KeywordsArray.InsertAt(idx, val) +} +; update VideoTags with sanitized keywords list +VideoTags := Join(",", KeywordsArray*) ; Call each sub one by one, if errors occur then an upload will be stopped and the next upload will then proceed