Compare commits

..

20 Commits

Author SHA1 Message Date
b378de8106 function add and expansion 2024-05-17 19:36:18 -04:00
ed307493b8 renamed lib 2024-05-17 18:40:09 -04:00
2860e4868f formatting and cleanup 2024-05-16 14:46:11 -04:00
0e02ae24bd small bug fixes and improvements 2024-05-09 21:48:29 -04:00
b19482e10d readme 2024-05-09 15:37:36 -04:00
d7d3ce039f formatting, added reusable lib for update checks 2024-05-09 15:36:35 -04:00
8395c5c367 generate date ordinals function 2024-05-08 13:59:06 -04:00
124a26c3b0 fixed broken function, bit o' organization 2024-05-04 14:55:54 -04:00
b5c3b4a606 error checkign and general msgbox window 2024-05-03 12:52:49 -04:00
Yuriy
43dd2c3f28 expanded function 2024-05-02 00:29:19 -04:00
Yuriy
88c48e133e expanded function 2024-05-02 00:29:11 -04:00
Yuriy
2e0c81f34f merged misc and general functions 2024-05-01 14:22:34 -04:00
Yuriy
b8ffb10db1 improved chrome update functionality 2024-04-26 19:41:40 -04:00
Yuriy
5671242faf modularization and addition of Locals Specific Functions 2024-04-25 19:57:26 -04:00
Yuriy
8a532ac787 removed duplicate function 2024-04-20 19:19:42 -04:00
Yuriy
f20332d6c6 merged in misc functions from video uploader, modularized lbry functions into it's own file 2024-04-19 18:58:15 -04:00
Yuriy
f625e782eb removed reusetabs variable. Set to always be enabled 2024-04-17 17:28:54 -04:00
Yuriy
c18e9897ee bug fixes for when there are no errorlog filepath or discord webhook 2024-04-17 17:09:32 -04:00
Yuriy
075859934a bug fixes for when there are no errorlog filepath or discord webhook 2024-04-17 17:09:08 -04:00
Yuriy
88b4b2c119 small cleanup 2024-04-16 22:49:45 -04:00
10 changed files with 890 additions and 264 deletions

View File

@@ -1,10 +1,13 @@
;---FUNCTIONS-----------------------------------------------------------------------
; Misc Functions that are called by both the Video and Social Media poster
; -------------------------------Discord-------------------------------
PostToDiscordChannel(Message,WebhookChannel){
; Don't try to post a message if there is no webhook url
if(WebhookChannel = "")
Return
; Msgbox % "Message: " Message
; Msgbox % "WebhookChannel: " WebhookChannel
@@ -28,8 +31,6 @@ PostToDiscordChannel(Message,WebhookChannel){
}
)
; Msgbox % "JsonString: " JsonString
;
try WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
try WebRequest.Open("POST", WebhookChannel, false)
try WebRequest.SetRequestHeader("Content-Type", "application/json")
@@ -50,14 +51,14 @@ TelegramMsgBox(Text:="", TelegramBotToken := "", TelegramBotChatID :=""){
; Replace all forbidden characters - https://www.ascii-code.com/
; Text := StrReplace(Text, "`%", "%25") ; percent with
Text := StrReplace(Text, "`n", "%0A") ; New Line
; Text := StrReplace(Text, "`n", "%0A") ; New Line
; Text := StrReplace(Text, " ", "%23") ; New Line
; Text :=
; Text := StrReplace(Text, "`n", "%0A") ; New Line
; Text := StrReplace(Text, "`%", "%25") ; percent with
; Msgbox % "Text: " Text
ErrorLoggingPath = %A_ScriptDir%\Lib\ErrorLogging\check.rups
@@ -93,6 +94,7 @@ TelegramMsgBox(Text:="", TelegramBotToken := "", TelegramBotChatID :=""){
; -------------------------------/TelegramAPI-------------------------------
; Telegram Message API
; https://core.telegram.org/bots/api
;------------------------------------------------
SendTelegramMessage(token, chatID, text := "", ParseMode := "MarkdownV2") ; you could add more options; compare the Telegram API docs
{
@@ -142,6 +144,7 @@ pre-formatted fixed-width code block written in the Python programming language
; -------------------------------Telegram Image Sending-------------------------------
; https://www.autohotkey.com/boards/viewtopic.php?t=68417
; https://core.telegram.org/bots/api
SendTelegramPhoto(token, chatID, file, caption := "", ParseMode := "MarkdownV2") ; you could add more options; compare the Telegram API docs
{

View File

@@ -21,6 +21,9 @@ global InstalledChromeVersion
; Chrome Related Functions
;------------------------------------------------
DownloadLatestChromium(){
Message = Checking Variables for Downloading Newest Chrome
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
if(ChromeFilepath = "")
ChromeFilepath := GetInstalledChromeFilepath()
@@ -90,9 +93,9 @@ DownloadLatestChromium(){
; close any open instances of Chromium
SetTitleMatchMode, 2 ; substring
; SetTitleMatchMode, 2 ; substring
/*
if(WinExist(" - Chromium")){
Message = Trying to close any open Chromium Windows
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
@@ -111,19 +114,65 @@ DownloadLatestChromium(){
MsgBox 0x10,, %Message%
return
}
*/
; make sure all instances of chrome are closed
Loop, {
ChromeOpen := WinExist("ahk_exe chrome.exe")
if(ChromeOpen) {
Message = Chrome is Open. Asking user to close instances before continuing.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
MsgBox 0x41, Chrome is Open, Please close all instances of Chrome and then click OK to continue with replacing Chrome with the newest version.
IfMsgBox OK, {
} Else IfMsgBox Cancel, {
return
}
}
else,
break
}
; msgbox
; make sure all instances of chromedriver.exe are closed
Message = Checking and killing any instances of the chromedriver.exe process
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Loop, 5 {
Process, Exist, chromedriver.exe
ChromedriverExists := ErrorLevel
if(ChromedriverExists){
Message = Chromedriver Exists on check number %A_Index%
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging")
Process, Close, chromedriver.exe
sleep, 5000 ; wait 5 seconds before checking again
continue
}
else,
break
Message = Chrome Update Failed. Unable to kill background chromedriver.exe process
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
return
}
FileGetTime, ChromeDriverExeOldCreationTime, %ChromeDriverProgramFilesExeFilepath%, C
Message = Downloading Chromedriver v%ChromeStableLatestVersion% to:`n%ChromeDriverDownloadZipFilepath%
Message = Downloading Chromedriver v%ChromeStableLatestVersion% `nFrom: %chromedriverDLURL64%`nTo: %ChromeDriverDownloadZipFilepath%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
UrlDownloadToFile, %chromedriverDLURL64%, %ChromeDriverDownloadZipFilepath%
Message = Downloading Chromium v%ChromeStableLatestVersion% to:`n%ChromeDownloadZipFilepath%
Message = Downloading Chromium v%ChromeStableLatestVersion% `nfrom: %chromeDLURL64% to:`n%ChromeDownloadZipFilepath%`n(This might take 1-2 minutes)
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
UrlDownloadToFile, %chromeDLURL64%, %ChromeDownloadZipFilepath%
@@ -132,6 +181,8 @@ DownloadLatestChromium(){
Message = Deleting Old Chromium Directory
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
FileRemoveDir, %ChromeExtractedDirectory%, 1
if(FileExist(ChromeExtractedDirectory)){
Message = Failed to delete the old Chromium. `nPlease manually delete the following directory and then run the Chrome Update again.`n`n %ChromeExtractedDirectory%
@@ -261,11 +312,11 @@ DownloadLatestChromium(){
ToolTip
return
}
}
CheckForChromeUpdates(ChromeFilepath := ""){
CheckForChromeUpdates(ChromeFilepath := ""){
if(ChromeFilepath = "")
ChromeFilepath := GetInstalledChromeFilepath()
@@ -279,10 +330,10 @@ CheckForChromeUpdates(ChromeFilepath := ""){
else, Return 0
}
}
GetInstalledChromeFilepath(){
GetInstalledChromeFilepath(){
; ChromeFilepath is global variable
if(ChromeFilepath = ""){
@@ -314,9 +365,9 @@ GetInstalledChromeFilepath(){
}
ToolTip
}
}
GetInstalledChromeVersion(){
GetInstalledChromeVersion(){
if(ChromeFilepath = ""){
GetInstalledChromeFilepath()
@@ -329,10 +380,10 @@ GetInstalledChromeVersion(){
InstalledChromeVersion := StrReplace(InstalledChromeVersion, "`r") ; replace any newline characters that powershell returns
return InstalledChromeVersion
}
}
GetLatestChromeStableVersion(){
GetLatestChromeStableVersion(){
; https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints
json_str := urldownloadtovar("https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json")
@@ -349,10 +400,10 @@ GetLatestChromeStableVersion(){
}
return ChromeStableLatestVersion
}
}
GetDownloadURLOfChromeAndDriver(InstalledChromeVersion){
GetDownloadURLOfChromeAndDriver(InstalledChromeVersion){
; Will return the download URL of Chrome for Testing and Chrome Driver, seperated by a ||
; https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints
@@ -399,4 +450,4 @@ GetDownloadURLOfChromeAndDriver(InstalledChromeVersion){
URLS = %chromeDLURL64%||%chromedriverDLURL64%
return URLS
}
}

View File

@@ -102,6 +102,11 @@ TimedToolTip(Text, x="", y="",RemoveAfterTime:=2000, SetWhichToolTip="") {
; -------------------------------LogErrorsToTextFile-------------------------------
Func_LogErrorsToTextFile(Text){
; Do not log if we do not have an errorlog filepath
if(ErrorLoggingFilePath = "")
return
; ErrorLoggingFile := Filepath
FormatTime, TodayDate , YYYYMMDDHH24MISS, yyyyMMdd_hhmmss
text =
@@ -132,6 +137,10 @@ CheckDirExistAndCreate(Path){
; -------------------------------/CheckDirExistAndCreate-------------------------------
; Script Updates
; ------------------------------------------------
CheckIfUpdateAvailable(Filepath, CurrentVersion){
FileRead, ScriptUpdateContents, %Filepath%
@@ -370,19 +379,6 @@ Return Var
}
; OnMsgbox Functions
;------------------------------------------------
OnMsgBoxUpdateAvailable() {
DetectHiddenWindows, On
Process, Exist
If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) {
ControlSetText Button1, Cancel
ControlSetText Button2, Install
}
}
SaveCurrentChromeVersionToIniFile(){
if(InstalledChromeVersion = "")
@@ -420,3 +416,254 @@ HasSubstringVal(haystack, needle)
; -------------------------------Functions-------------------------------
; 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))
}
LogErrorToTextFile(Error){
/* if(LogErrorsToTextFile != 1)
Return
*/
ErrorLoggingFile := VideoFolderDir . "\" . "ErrorLogging.txt"
FormatTime, TodayDate , YYYYMMDDHH24MISS, yyyyMMdd_hhmmss
text =
(
---------------%TodayDate%---------------
%CurrentSite%: %Error%
)
if(LogErrorsToMsgbox)
Msgbox % "Text: " Text
FileAppend, %Text%, %ErrorLoggingFile%
} ; End of Function
/*
*/
AddToTotalVideosUploadedCount(){
; IniRead, TotalVideosUploaded, %SettingsIniFilepath%, General, TotalVideosUploaded, %A_Space%
TotalVideosUploaded += 1
; IniWrite, %TotalVideosUploaded%, %SettingsIniFilepath%, General, TotalVideosUploaded
}
Check_For_Stuck_Video_Upload(Index_Number, Upload_Status){
if(A_index = 1){ ; Create a blank array
ProgressStatusArray := []
Return
}
Message = Upload Status: %Upload_Status%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip")
; if we reached the last loop number:
if(A_index = %Number_of_loops_to_Check_Upload_status%){
Message = Upload Most Likely Failed: Video Hasn't Finished Uploading after 1 hour.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return "Failed"
}
; If progress is still the same after a ten minute interval then error out
if(HasVal(Array_Index_Num_of_Upload_StatusChecks, A_index)){ ; if current index is in Array of index numbers to check status during
; Send a notification message of upload status
Message = Upload Status: %Upload_Status%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; if current upload_status is in the array of values that are updated every 10 mins
if(HasVal(ProgressStatusArray, Upload_Status)){
Message = Upload Failed (E#4508)`nUpload Stuck at same point for 10 minutes. Stuck Status: %ProgressStatus%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return "Failed"
}
ProgressStatusArray.Push(Upload_Status) ; append current status to array
}
} ; end of func
/*
*/
; Find the longest word in a string of words
FindLongestWordInString(m, calloutNumber, pos, haystack, pattern){
Global wordLength, longestWord
len := StrLen(m)
If ( len > wordLength )
{
wordLength := len
longestWord := 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 . "\. "
}
}
if (currentChunk != "")
chunks.Push(currentChunk)
return chunks
}
CreateErrorLoggingFiles(Directory := ""){
FormatTime, TodayDate, YYYYMMDDHH24MISS, yyyyMMdd_hhmmss
ErrorLoggingDirectory := Directory
if(ErrorLoggingDirectory = ""){
ErrorLoggingDirectory := A_ScriptDir . "\Lib\ErrorLogging"
; If directory for error logging doesn't exist, create it
if(!FileExist(ErrorLoggingDirectory))
FileCreateDir, %ErrorLoggingDirectory%
ErrorLoggingDirectory := ErrorLoggingDirectory . "\" . TodayDate . "_" . ScriptAbbreviatedName
}
; Msgbox % "ErrorLoggingDirectory: " ErrorLoggingDirectory
FileCreateDir, %ErrorLoggingDirectory%
; Create variables with filepaths that content will be saved to.
global ErrorLoggingFilePath := ErrorLoggingDirectory . "\" . "ErrorLogging.txt"
global StatusFileFilePath := ErrorLoggingDirectory . "\" . "PostStatus.ini"
global PostTitleFilePath := ErrorLoggingDirectory . "\" . "PostTitle.txt"
global PostBodyFilePath := ErrorLoggingDirectory . "\" . "PostBody.txt"
global PostTagsFilePath := ErrorLoggingDirectory . "\" . "PostTags.txt"
PostStatusesFilepath := ErrorLoggingDirectory . "\" . "Status.ini"
; Msgbox % "ErrorLoggingDirectory: " ErrorLoggingDirectory
Return
}
; if passed argument is .exe file, then script has just been updated and we need to delete the old .exe file
CheckIfUpdateInstalled(PassedInArgument :=""){
if(InStr(PassedInArgument,".exe")){
FileDelete, %PassedInArgument%
if(ErrorLevel){ ; most likely because the old version hasn't finished exiting yet
Message = Failed to Delete Old .exe file after Updating
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar")
}
}
}
; https://www.autohotkey.com/boards/viewtopic.php?t=59936
GetDateOrdinalSuffix(D) {
Static Special := {1: "st", 2: "nd", 3: "rd", 21: "st", 22: "nd", 23: "rd", 31: "st"}
Return D . ((S := Special[D]) ? S : "th")
}
; OnMsgbox - Custom Msgbox Screens
;------------------------------------------------
ConfirmBeforeSubmitMsgboxFunc(){
OnMessage(0x44, "OnMsgBoxUserConfirmation")
MsgBox 0x21, User Confirmation, Please check that all data was input correctly and fix any mistakes and then click PROCEED to finalize the Upload.`n`nClick STOP to cancel the rest of this Upload and move on to the next website.
OnMessage(0x44, "")
IfMsgBox OK, {
} Else IfMsgBox Cancel, {
Message = User Selected STOP button when asked for confirmation. Cancelling Rest of Site Upload.
Return %Message%
}
}
OnMsgBoxUpdateAvailable() {
DetectHiddenWindows, On
Process, Exist
If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) {
ControlSetText Button1, Cancel
ControlSetText Button2, Install
}
}
; Show a user confirmation msgbox with a PROCEED and STOP buttons
; Used by the "Confirm before Submit" checkbox
OnMsgBoxUserConfirmation() {
DetectHiddenWindows, On
Process, Exist
If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) {
ControlSetText Button1, PROCEED
ControlSetText Button2, STOP
}
}
OnMsgBoxConfirmChromiumOverwrite() {
DetectHiddenWindows, On
Process, Exist
If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) {
ControlSetText Button1, Cancel
ControlSetText Button2, Yes
}
}
OnMsgBoxPodcastFinish() {
DetectHiddenWindows, On
Process, Exist
If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) {
WinMove,, 0
}
}
OnMsgBoxSocialMediaPoster() {
DetectHiddenWindows, On
Process, Exist
If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) {
ControlSetText Button1, Yes
ControlSetText Button2, Not Now
}
}

149
LBRY-Functions.ahk Normal file
View File

@@ -0,0 +1,149 @@
CheckLBRYProcess(){
; Check if LBRY Process exists
Process, Exist,LBRY.exe
if(ErrorLevel = 0) ; if doesn't exist
{
Message = Not Running. Starting up LBRY.exe
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
LBRYExeFilepath = C:\Program Files\LBRY\LBRY.exe
if(!FileExist(LBRYExeFilepath)){
Message = Failed to Find LBRY.exe executable. LBRY not installed?
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
Message = Checking LBRY daemon_settings.yml file for Odysee Wallet Servers
SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,DiscordErrorLogging")
; FileRead, daemon_settingsFileContent, C:\Users\%A_UserName%\AppData\Local\lbry\lbrynet\daemon_settings.yml
; if(!InStr(daemon_settingsFileContent, "a-hub1.odysee.com")){
; Message = Odysee wallet server is not in daemon_settings.yml. Replacing File with required settings.
; SaveOrPostProgress(Message:=Message,PostType:=",DiscordErrorLogging")
; LBRYDaemonSettingsFP = C:\Users\%A_UserName%\AppData\Local\lbry\lbrynet\daemon_settings.yml
; LBRYDaemonSettingsBackupFP = C:\Users\%A_UserName%\AppData\Local\lbry\lbrynet\daemon_settings_BU.yml
; ; Msgbox % "daemon_settingsText: " daemon_settingsText
; FileMove, %LBRYDaemonSettingsFP%, %LBRYDaemonSettingsBackupFP%, 1 ; Dest [, Flag (1 = overwrite)]
; UrlDownloadToFile, https://freedomain.dev/yuriy/video-uploader/raw/branch/main/Assets/daemon_settings.yml , %LBRYDaemonSettingsFP%
; sleep, 1000
; if(!FileExist(LBRYDaemonSettingsFP)){
; Message = Failed to download the custom daemon_settings.yml file from git. Restoring Original File
; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,DiscordErrorLogging")
; FileMove,%LBRYDaemonSettingsBackupFP%,%LBRYDaemonSettingsFP%, 1
; }
; }
try run, "%LBRYExeFilepath%"
Message = Waiting 1 Minute for LBRY to start up
SaveOrPostProgress(Message:=Message,PostType:="Tooltip")
Sleep, 60000 ; 1 minute
Process, Exist,LBRY.exe
if(ErrorLevel = 0) ; if doesn't exist
{
Message = Failed to Start LBRY.exe after 60 seconds of waiting
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
WinMinimize, LBRY
}
Return
}
GetPermanentLBRYURL(UploadResult){
SingleQuotationmark = "
UploadResult := StrSplit(UploadResult, "`n") ; split results by new line
; Iterate through the array of the results
Loop % UploadResult.Length() {
PermanentURL := UploadResult[A_Index]
if(InStr(PermanentURL, "permanent_url"))
Break
}
; Starting Result: "permanent_url": "lbry://Test-Video-161-Numbered#c9ad9afe54c7178d6f870b59bbe129aef8efc3ff",
PermanentURL := StrSplit(PermanentURL, "lbry:")
PermanentURL := "lbry:" . PermanentURL[2]
PermanentURL := StrReplace(PermanentURL, ",", "")
PermanentURL := StrReplace(PermanentURL, SingleQuotationmark, "")
PermanentURL := StrReplace(PermanentURL, "`n", "")
PermanentURL := StrReplace(PermanentURL, "`r", "")
; End Result lbry://Test-Video-161-Numbered#c9ad9afe54c7178d6f870b59bbe129aef8efc3ff
Return PermanentURL
}
GetLBRYCanonicalURL(LBRYJSONObject){ ; input json string
; ResolveURL := StrSplit(LBRYResolveAPICommand, "lbry://")
; ResolveURL := "lbry://" . ResolveURL[2]
; StrReplace(Haystack, SearchText [, ReplaceText, OutputVarCount, Limit := -1])
LBRYPermanentURLJsonOBJ := StrReplace(LBRYJSONObject, LBRYPermanentURL, "LBRYPermanentURL")
; clipboard := LBRYPermanentURLJsonOBJ
; DevModeMsgBox(LBRYPermanentURLJsonOBJ)
try parsed := JSON.Load(LBRYPermanentURLJsonOBJ)
try LBRYCanonicalURL := parsed.LBRYPermanentURL.canonical_url
; DevModeMsgBox(LBRYCanonicalURL)
if(LBRYCanonicalURL = ""){
Return "" ; return blank
}
; otherwise return the LBRY url
LBRYCanonicalURL := StrReplace(LBRYCanonicalURL, "lbry://", "https://lbry.tv/")
Return LBRYCanonicalURL
}
LBRYCMDTextReplacement(LBRYURLSlug){
SingleQUote = "
LBRYURLSlug := StrReplace(LBRYURLSlug, " ", "_") ; replace all spaces with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, ":", "_") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, ",", "_") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "?", "") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "!", "") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "`;", "_") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "/", "_") ; replace all colons with dashes
; LBRYURLSlug := StrReplace(LBRYURLSlug, "?", "") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "<", "_") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, ">", "_") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, SingleQUote, "") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "'", "") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "=", "") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, ";", "") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, ")", "") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "(", "") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "___", "_") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "__", "_") ; replace all colons with dashes
LBRYURLSlug := StrReplace(LBRYURLSlug, "__", "_") ; replace all colons with dashes
Return LBRYURLSlug
}
GetLBRYAPIErrorFromString(UploadResult){
UploadResultArray := StrSplit(UploadResult, "message")
LBRYAPIError := UploadResultArray[2]
; LBRYAPIErrorStrLen := StrLen(LBRYAPIError)
; LBRYAPIErrorStrToTrim := LBRYAPIErrorStrLen - 3
; Msgbox % "LBRYAPIErrorStrToTrim: " LBRYAPIErrorStrToTrim
LBRYAPIError := SubStr(LBRYAPIError, 4)
LBRYAPIError := StrReplace(LBRYAPIError, "}", "")
; Msgbox % "LBRYAPIError: " LBRYAPIError
Return LBRYAPIError
}

50
Locals-Functions.ahk Normal file
View File

@@ -0,0 +1,50 @@
; Iterate over Locals posts on the home page until found post with title
; ------------------------------------------------
GrabLocalsPostURLUsingTitle(PostTitle){
Loop, 10 {
Message = Checking Post %A_index% on page for Post Titled`n%PostTitle%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
ToolTip, %A_Index%
; first two items can be skipped.
; new Post box and Create other forms of posts box
if(A_index < 3)
Continue
; Xpath for each post box on the main page
Xpath = //body/div/div/div/div/div/div[1]/div[%A_Index%]
try ElementInnerText := driver.findelementbyxpath(Xpath).Attribute("innerText") ;XPATH Inner Text
Try ElementOuterHTML := driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag
if(InStr(ElementInnerText, PostTitle)){
Message = Found Post Title in Element Number: %A_index%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; Pull Out the Post URL from the OuterHTML using RegEx
regexMatch := RegExMatch(ElementOuterHTML, "data-post-url=""([^""]+)""", match)
if (regexMatch)
{
PostURL := match1
Message = URL Pulled out from OuterHTML: %PostURL%
Return PostURL
}
else {
Message = Failed to Pull out URL from OuterHTML
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return "Failed"
}
}
}
Message = Failed to find New Post in the first 10 posts
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return "Failed"
}

View File

View File

@@ -1,3 +1,5 @@
Function Libraries used in the following Projects:
- [Freedomain Social Media Poster](https://freedomain.dev/yuriy/social-media-poster)
- [Freedomain Video Uploader](https://freedomain.dev/yuriy/video-uploader)
- [Freedomain Clips Uploader](https://freedomain.dev/yuriy/clips-uploader)
- [Freedomain Livestream Scheduler](https://freedomain.dev/yuriy/livestream-scheduler)

View File

@@ -73,7 +73,6 @@ CheckSeleniumDriver(){
}
DriverStatus := 1
if(ReuseTabs)
CreateArrayOfChromeTabs()
@@ -721,10 +720,28 @@ Selenium_LoopToSendValueByName(ElementName,NumOfLoops:=1,SleepLength:=1000,Strin
}
}
Selenium_LoopToSendValueToXpath(Xpath,NumOfLoops:=1,SleepLength:=1000,StringTextContent:=""){
Selenium_LoopToSendValueToXpath(Xpath,NumOfLoops:=1,SleepLength:=1000,StringTextContent:="",ClearElement:=0){
loop, %NumOfLoops% {
; ToolTip, Loop attempt: %A_index%
try driver.FindElementByXPath(Xpath).sendKeys(StringTextContent) ; Click on "upload image" button
if(ClearElement){
Loop, 3 { ; sometimes have to do it multiple times to make it trigger properly
Try PreviousValue := driver.findelementbyxpath(Xpath).Attribute("value") ;Xpath Value
try, driver.FindElementByXPath(Xpath).clear()
Try CurrentValue := driver.findelementbyxpath(Xpath).Attribute("value") ;Xpath Value
if(PreviousValue != CurrentValue){
break
}
sleep, 1000
; msgbox
}
}
try driver.FindElementByXPath(Xpath).sendKeys(StringTextContent) ; Input Text
catch e {
if(A_index = NumOfLoops){
Return "Failed"
@@ -779,17 +796,27 @@ Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath,NumOfLoops:=1,SleepLength:=1
}
Selenium_LoopToClearXpath(Xpath,NumOfLoops:=1,SleepLength:=1000){
loop, %NumOfLoops% {
Selenium_LoopToClearXpath(Xpath,NumberOfAttemps:=1,SleepLength:=1000){
loop, %NumberOfAttemps% {
try driver.FindElementByXPath(Xpath).clear()
catch e {
if(A_index = NumOfLoops){
Return "Failed"
}
sleep, %SleepLength%
Continue
try, InerText := driver.findelementbyxpath(Xpath).Attribute("value")
; Msgbox % "InerText: " InerText
if(InerText = "")
return
if(A_index = NumberOfAttemps){
return "Failed after %NumberOfAttemps"
}
Return
Continue
; Return
}
}
@@ -821,6 +848,38 @@ SaveDriverURLOFErrorPage(){ ; save the url of the result page. That way if a tab
}
GetHTMLValueFromXpathOuterHTML(XPATH, HTMLElementName){
Try ElementOuterHTML := driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag
; try Clipboard := driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag
; Try MsgBox,,Element OuterHTML: `n, % driver.findelementbyxpath(Xpath).Attribute("outerHTML") ;XPATH-ID & Tag
; Match string between quotes following the HTMLELEMENTNAME
RegexStatement = %HTMLElementName%="([^"]+)"
; regexMatch := RegExMatch(ElementOuterHTML, "value=""([^""]+)""", match)
regexMatch := RegExMatch(ElementOuterHTML, RegexStatement, match)
if (regexMatch)
{
ElementValue := match1
; Msgbox % "PostURL: " PostURL
; Message = URL Pulled out from OuterHTML: %PostURL%
Return ElementValue
}
else {
Message = Failed to Pull out value from OuterHTML
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return "Failed"
}
}
;---\Selenium---
;------------------------------------------------

41
Shared-GoTos.ahk Normal file
View File

@@ -0,0 +1,41 @@
; This #include needs to be at the bottom of the parent script
CheckForUpdates:
; The GUI buttons must have variable set to vUpdateAvailable and vChromeUpdateAvailable for button to get updated
; The following variables need to be set in the parent script
; GitReleasesAPIURL
; ChromeFilepath
Message = Checking for Updates
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
if(CheckForUpdates(GitReleasesAPIURL)){
GuiControl,,UpdateAvailable, Update Available!
}
if(CheckForChromeUpdates(ChromeFilepath)){
GuiControl,,ChromeUpdateAvailable, Chrome Update Available!
ChromeUpdateAvailable := 1
}
Return
PasteClipboardToEditBox:
if(A_GuiControl = "PasteClipboardToSMPBody"){
GuiControl,,PostBody, %Clipboard%
}
if(A_GuiControl = "PasteClipboardToSMPTitle"){
GuiControl,,PostTitle, %Clipboard%
}
Return

24
Update-Functions.ahk Normal file
View File

@@ -0,0 +1,24 @@
; This #include needs to be at the bottom of the parent script
CheckForUpdates:
; The GUI buttons must have variable set to vUpdateAvailable and vChromeUpdateAvailable for button to get updated
; The following variables need to be set in the parent script
; GitReleasesAPIURL
; ChromeFilepath
Message = Checking for Updates
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
if(CheckForUpdates(GitReleasesAPIURL)){
GuiControl,,UpdateAvailable, Update Available!
}
if(CheckForChromeUpdates(ChromeFilepath)){
GuiControl,,ChromeUpdateAvailable, Chrome Update Available!
ChromeUpdateAvailable := 1
}
Return