forked from cutbypham/snap-captions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSnap Captions.lua
2854 lines (2563 loc) · 126 KB
/
Snap Captions.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- Copyright (C) 2023 Orson Lord & Dan Knowlton
-- Updates by Asher Roland
--
-- Snap Captions V1.6.00
-- This tool automates the process of creating Text+ clips from subtitle
-- clips.
--
-- If you find this tool useful, please consider donating to support its
-- development: https://bit.ly/SnapCaptions
--
-- This software can not be redistributed or sold without the express
-- permission of the authors.
local DONATE_URL = "https://bit.ly/SnapCaptions" -- Donate to Snap Captions
local HUB_URL = "https://bit.ly/SC_Help_Hub" -- Get Help from the Hub
local noSnapPathFound = "https://bit.ly/46PfP3B" -- Snap Captions Current Path could not be found when Installing
local snapInstallFailed = "https://bit.ly/3WIv0XO" -- Snap Captions Could Not Install
local noUTF8File = "https://bit.ly/3M15NTp" -- UTF8 File not With Snap Captions File When Installing
local UTF8FailedInstall = "https://bit.ly/4fwWZSK" -- UTF8 File Could Not Install
local UTF8FailedLoad = "https://bit.ly/4dCmVur" -- UTF8 did not Load Properly
local noFusionCompInTemplate = "https://bit.ly/4cnJSAq" -- No Fusion Comp was Found in Chosen 'Template'
local noTextPlusInTemplate = "https://bit.ly/46O1Gnq" -- No Text+ Node was Found in Chosen Template's Comp
local noSubtitleTrack = "https://bit.ly/3WXVF41" -- There is No Subtitle Track When User Starts Generating
local AddTrackFailed = "https://bit.ly/3yyabpT" -- Could Not Add a New Video Track
local noTimeline = "https://bit.ly/4dFtxbl" -- No Timeline Opened and Active
local noTemplates = "https://bit.ly/4dihVvd" -- Video Link for When User Tries Generating Without any Text+ Templates
local noNewPacks = "https://bit.ly/4hnM7aW" -- No New Packs were Found in User's Selected Folder
local noCleanPack = "https://bit.ly/3Uz9CUJ" -- Clean Pack Not With Snap Captions File when Installing
local CleanFailedInstall = "https://bit.ly/3NPwATK" -- Clean Pack did not Install correctly
local PackMangagerTUT = "https://bit.ly/4dWaolc" -- Learn How to Use the Pack Manager (Could be slip between 'Your Library' and 'Add Packs')
local GetMorePacks = "https://bit.ly/3Q7FFZv" -- 📦 POWER UP With Premium Captions!
local REQUEST_URL = "https://bit.ly/4edlPFB" -- Settings Screen Request Feature Button
local hiddenIMGB64 = [[data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAACXBIWXMAAAsTAAALEwEAmpwYAAAq8UlEQVR42u1dB4AVxfn/Znffu144OI56NKmC9BqxxIJKTETUxBaNHWvUYIvGqGhCTIwtYhSTYIloYrB3JYAKCFIsgNS7gzuOOziut7c785++s6/d0ZL418V197bP95uvfzMPEULg27xEis6z6AYZK8gtiVrNBcW5h0RtUdTWPI/ZNtT72Rjio28rIBQIRihLrrZcHYPIjDCesWJ5q3m9HUVwHAWIFec8e5arnklBweZ3Od9i5lAEC9E1TNcUuVU0YYSK0LWFrq0GILZxvSP/NontGdfZBihYAtEsn8dWl3aMAKd8mwFRYKTc8vvKUYtXNM5uaiajzQvSUtG61BRr2YdP97xVEpMt4dNmlM7YXe2d2tCIR5rXZ6Rbq6cdn3kX21/wfv2d0efZkpqCVo4ZmnrjI78qWC1BMrnq2ymypLhiYKTRNXPSj4vfomAMS3R9x1z7r+/P63kHo9e0K0svKyqN3JGQ7RDg7Azrq5p6nPB5DJSlL/Y6ie42Mk6hHOJ92zkEyban3Pnw7vEMjLETRsCs++8MXLRjeylcfM7V0NiMx9M/05kIqmvAk9i53z10FwwfdUTg+mf/+jw885cXLQZGfuc8ePalp2JefN70i6GyomrMc6/Wdj73h9nbDR3z3wVE9tL/1qIUeOruvd4AdqBHz24xF+2p3MO36WlWueQmp6WV9ORck98x5voN6zbq/eEjh8acZwBTMCA91VpPwWiQYhP+I4DsB8Hbez05CM9V+iO1co/Hu3m/AX1jLtq2tYhvC7uG2E7O2g0tefWNeADr/T16dg9c29TUBCuWrYFwGDW3tpLU/oP6xTyvpGg73+ZmWxvjgXFIAEkCBDpAIPb3+niPsJVCr63HHInOnfNjriov28W3/XqG6ugmb/2WlsHs7959C2O5aXeV0jc1Oyvc1M4FnWOuqdhVIQGxdybqYM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ikUgkEolEIpFIJBKJRCKRSCQSiUTSMgD+D7mOzoTmBs7sAAAAAElFTkSuQmCC]]
local utf8 = string
local hasUtf8Support = false
local ui = fu.UIManager
local disp = bmd.UIDispatcher(ui)
local winID = "SnapCaptionsWin"
local ver = "V1.6.00"
local CleanPackName = "Snap Captions - Clean Pack V02.02.drb"
local projectManager = resolve:GetProjectManager()
local mediaStorage = resolve:GetMediaStorage()
local project = projectManager:GetCurrentProject()
local mediaPool = project:GetMediaPool()
local fusion_titles = {}
local TEXT_TEMPLATE_FOLDER = "Snap Captions"
local platform = (FuPLATFORM_WINDOWS and "Windows") or
(FuPLATFORM_MAC and "Mac") or
(FuPLATFORM_LINUX and "Linux")
local function script_path()
return arg[0]
end
local Scripts = app:MapPath('Scripts:/')
function removeFirstTwoItemsFromPath(path)
-- Check if the path starts with "/Users/"
if string.sub(path, 1, 7) ~= "/Users/" then
return path -- Return the original path if it doesn't start with "/Users/"
end
-- Find the third slash in the path
local start = 1
local count = 0
while count < 3 do
start = string.find(path, "/", start + 1)
if start == nil then
return path -- If there are not enough slashes, return the original path
end
count = count + 1
end
-- Remove everything up to the third slash
return string.sub(path, start + 1)
end
local function ScriptIsInstalled()
local script_path = script_path()
if platform == "Mac" then
Scripts = removeFirstTwoItemsFromPath(Scripts)
end
local match = script_path:find(Scripts)
return match ~= nil
end
local SCRIPT_INSTALLED = ScriptIsInstalled()
-- local function EndDispLoop()
-- local win = ui:FindWindow(winID)
-- if win ~= nil then
-- return
-- end
-- disp:ExitLoop()
-- end
local function CreateDialog(title, message, url, noOk, deleteButt, bin)
if not url then
url = ""
end
local dialog = disp:AddWindow({
ID = "SnapCaptionsDialog",
WindowTitle = "Snap Captions | Message",
WindowModality = "ApplicationModal",
Margin = 16,
ui:VGroup
{
FixedSize = {300, 150},
ID = "root",
Spacing = 4,
ui:Label
{
-- Weight = 0,
ID = "error_title",
Text = title,
Alignment = { AlignHCenter = true, AlignBottom = true},
WordWrap = true,
StyleSheet = [[
QLabel {
color: rgb(255, 255, 255);
font-size: 13px;
font-weight: bold;
}
]]
},
ui:Label
{
Weight = 1,
FixedSize = {300, 35},
ID = "error_message",
Text = message,
WordWrap = true,
Alignment = { AlignHCenter = true, AlignTop = true }
},
ui:VGap(0, 0.5),
ui:TextEdit
{
Weight = 0,
FixedSize = {300, 25},
ID = "LINK",
HTML = "",
WordWrap = true,
Alignment = { AlignHCenter = true, AlignVCenter = true },
ReadOnly = true,
Events = { AnchorClicked = true },
FrameStyle = 0,
},
ui:VGap(0, 0.5),
ui:HGroup
{
Weight = 0,
ui:Button{ ID = "Delete",
Text = "Delete",
Hidden = true,
StyleSheet = SECONDARY_ACTION_BUTTON_CSS
}
},
ui:HGroup
{
Weight = 0,
ui:Button{ ID = "OK",
Text = "OK",
StyleSheet = SECONDARY_ACTION_BUTTON_CSS
}
}
}
})
if deleteButt then
dialog:Find('Delete').Hidden = false
dialog:Find('OK').Text = "Don't Delete"
else
dialog:Find('Delete').Hidden = true
dialog:Find('OK').Text = "OK"
end
if noOk then
dialog:Find('OK').Hidden = true
else
dialog:Find('OK').Hidden = false
end
if url == "" then
dialog:Find('LINK').Hidden = true
elseif url ~= "" then
dialog:Find('LINK').Hidden = false
dialog:Find('LINK').HTML = "<center><b><a href='"..url.."'>Learn To Fix It Quick Here!</a></b></center>"
end
function dialog.On.Delete.Clicked(ev)
mediaPool:DeleteFolders({bin})
dialog:Hide()
dialog = nil
disp:ExitLoop()
end
function dialog.On.LINK.AnchorClicked(ev)
bmd.openurl(ev.URL)
end
function dialog.On.OK.Clicked(ev)
dialog:Hide()
dialog = nil
disp:ExitLoop()
end
function dialog.On.SnapCaptionsDialog.Close(ev)
dialog:Hide()
dialog = nil
disp:ExitLoop()
end
dialog:RecalcLayout()
return dialog
end
local function LoadUTF8Module()
-- Remove any previously loaded utf8 module.
package.loaded.utf8_snapcaptions = nil
hasUtf8Support, utf8 = pcall(require, "utf8_snapcaptions")
if not hasUtf8Support and SCRIPT_INSTALLED then
local dialog = CreateDialog("🛑 Uh Oh!",
"Resolve Couldn't Load My UTF8 Properly, I need this to caption languages other than english!", UTF8FailedLoad )
dialog:Show()
dialog:RecalcLayout()
utf8 = string
end
end
LoadUTF8Module()
local COLUMN_WIDTH = 130
local WINDOW_WIDTH = 320
local WINDOW_HEIGHT = 356
local COMBOBOX_ACTION_BUTTON_CSS = [[
QPushButton
{
border: 1px solid rgb(0,0,0);
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
border-left: 0px;
font-size: 22px;
min-height: 26px;
max-height: 26px;
min-width: 26px;
max-width: 26px;
background-color: rgb(31,31,31);
}
QPushButton:hover
{
color: rgb(255, 255, 255);
}
QPushButton:pressed
{
background-color: rgb(20,20,20);
}
]]
local SMALLER_TITLE_CSS = [[
QLabel
{
color: rgb(255, 255, 255);
font-size: 20px;
font-weight: bold;
}
QLabel:!enabled
{
color: rgb(150, 150, 150);
}
]]
local TITLE_CSS = [[
QLabel
{
color: rgb(255, 255, 255);
font-size: 30px;
font-weight: bold;
}
QLabel:!enabled
{
color: rgb(150, 150, 150);
}
]]
local START_LOGO_CSS = [[
QLabel
{
color: #fcfc03;
font-size: 20px;
font-weight: bold;
letter-spacing: 1px;
font-family: 'Readex Pro';
}
QLabel:!enabled
{
color: rgb(150, 150, 150);
}
]]
local END_LOGO_CSS = [[
QLabel
{
color: rgb(255, 255, 255);
font-size: 20px;
font-weight: bold;
letter-spacing: 1px;
font-family: 'Readex Pro';
}
QLabel:!enabled
{
color: rgb(150, 150, 150);
}
]]
local SECTION_TITLE_CSS = [[
QLabel
{
color: rgb(255, 255, 255);
font-size: 13px;
font-weight: bold;
}
QLabel:!enabled
{
color: rgb(150, 150, 150);
}
]]
local BANNER_ACTION_BUTTON_CSS = [[
QPushButton
{
max-height: 20px;
min-height: 20px;
color: rgb(200, 200, 200);
font-size: 12px;
min-width: 80px;
}
]]
local PRIMARY_ACTION_BUTTON_CSS = [[
QPushButton
{
border: 1px solid #141414;
max-height: 28px;
border-radius: 14px;
background-color: #1f1f1f;
color: #fcfc03;
min-height: 28px;
font-size: 13px;
font-family: Readex Pro;
font-weight: 600;
letter-spacing: 1px;
text-shadow: 0 0 3px #FF0000, 0 0 5px #0000FF;
}
QPushButton:hover
{
border: 2px solid rgb(50,50,50);
background-color: rgb(20,20,20);
}
QPushButton:pressed
{
border: 2px solid rgb(0,0,0);
background-color: rgb(0,0,0);
}
QPushButton:!enabled
{
border: 2px solid rgb(0,0,0);
background-color: rgb(0,0,0);
color: #fcfc03;
}
]]
local SECONDARY_ACTION_BUTTON_CSS = [[
QPushButton
{
max-height: 24px;
min-height: 24px;
}
]]
local FLAT_CSS = [[
QPushButton
{
color: rgb(255, 255, 255);
font-size: 13px;
font-weight: bold;
}
QPushButton:hover
{
font-size: 15px;
}
]]
local DIVIDER_CSS = [[
QFrame[frameShape="4"]
{
border: none;
background-color: rgb(30, 30, 30);
max-height: 1px;
}
]]
local TITLE_DIV_CSS = [[
QFrame[frameShape="4"]
{
border: none;
background-color: rgb(30, 30, 30);
max-height: 2px;
}
]]
local COMBOBOX_PLACEHOLDER_CSS = [[
QLabel
{
color: rgb(140, 140, 140);
font-size: 13px;
min-height: 26px;
max-height: 26px;
background-color: rgb(31,31,31);
border: 1px solid rgb(0,0,0);
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
padding-left: 4px;
}
]]
local timeline_type_names = {}
timeline_type_names["Timeline"] = true
timeline_type_names["タイムライン"] = true
timeline_type_names["时间线"] = true
timeline_type_names["Línea de tiempo"] = true
timeline_type_names["Linha de Tempo"] = true
timeline_type_names["Временная шкала"] = true
timeline_type_names["ไทม์ไลน์"] = true
timeline_type_names["타임라인"] = true
------------------------------------------------------------------------------
-- parseFilename() from bmd.scriptlib | Also can be found in LoaderFromSaver Script by Alexey Bogomolov
--
-- this is a great function for ripping a filepath into little bits
-- returns a table with the following
--
-- FullPath : The raw, original path sent to the function
-- Path : The path, without filename
-- FullName : The name of the clip w\ extension
-- Name : The name without extension
-- CleanName: The name of the clip, without extension or sequence
-- SNum : The original sequence string, or "" if no sequence
-- Number : The sequence as a numeric value, or nil if no sequence
-- Extension: The raw extension of the clip
-- Padding : Amount of padding in the sequence, or nil if no sequence
-- UNC : A true or false value indicating whether the path is a UNC path or not
------------------------------------------------------------------------------
function parseFilename(filename)
local seq = {}
seq.FullPath = filename
string.gsub(seq.FullPath, "^(.+[/\\])(.+)", function(path, name) seq.Path = path seq.FullName = name end)
string.gsub(seq.FullName, "^(.+)(%..+)$", function(name, ext) seq.Name = name seq.Extension = ext end)
if not seq.Name then -- no extension?
seq.Name = seq.FullName
end
string.gsub(seq.Name, "^(.-)(%d+)$", function(name, SNum) seq.CleanName = name seq.SNum = SNum end)
if seq.SNum then
seq.Number = tonumber( seq.SNum )
seq.Padding = string.len( seq.SNum )
else
seq.SNum = ""
seq.CleanName = seq.Name
end
if not seq.Extension then seq.Extension = "" end
seq.UNC = ( string.sub(seq.Path, 1, 2) == [[\\]] )
return seq
end
local username
if platform == 'Windows' then
username = os.getenv('USERPROFILE')
else
-- For Mac and Linux
username = os.getenv('HOME')
end
local nonWindowsBase = (platform == "Mac" and username.."/Library/Application Support") or (platform == "Linux" and username.."/.local/share") or (platform == "Windows" and app:MapPath('Scripts:/Comp/'))
if not bmd.direxists(nonWindowsBase) then
error("There was an issue getting the Application Support Folder!")
return
end
local installFolder = (platform == "Mac" and username.."/Library/Application Support/Snap Captions - Installed Packs") or (platform == "Linux" and username.."/.local/share/Snap Captions - Installed Packs") or (platform == "Windows" and app:MapPath('Scripts:/Comp/') .. "Snap Captions - Installed Packs")
local function OpenURL(url)
if bmd.openurl then
bmd.openurl(url)
print("[Opening URL] " .. url)
end
end
local function ClearTable(table)
for k in pairs(table) do
table[k] = nil
end
end
local function CopyFile(source, target)
if not source then
return false
end
local source_file = io.open(source, "r")
if not source_file then
return false
end
local contents = source_file:read("*a")
source_file:close()
local target_file = io.open(target, "w")
if not target_file then
return false
end
target_file:write(contents)
target_file:close()
return true
end
local function extractSnapCaptions(inputStr)
-- Extract the string after "Snap Captions "
local result = inputStr:match("Snap Captions (.+)")
if result then
-- Remove any non-letter and non-number characters that are not a period
result = result:gsub("[^%w%. ]", "")
-- Remove a space at the start of the string if one exists
result = result:gsub("^%s+", "")
end
return result
end
local function CopyDRB(source, destination)
local destPath = parseFilename(destination).Path
-- Ensure the destination directory exists
if not bmd.direxists(destPath) then
bmd.createdir(destPath)
end
-- Check if the source file exists
if not bmd.fileexists(source) then
error("Source file does not exist: " .. source)
return false
end
-- Use Lua's file handling in binary mode to copy the file
local file = io.open(source, "rb")
if not file then
error("Failed to open source file for reading: " .. source)
return false
end
-- Read the source file in binary mode
local content = file:read("*a")
file:close()
-- Write to the destination file in binary mode
local destFile = io.open(destination, "wb")
if not destFile then
error("Failed to open destination file for writing: " .. destination)
return false
end
destFile:write(content)
destFile:close()
return true
end
local function InstallScript()
local source_path = script_path()
local target_path = app:MapPath('Scripts:/Comp/')
local modules_path = app:MapPath('LuaModules:/')
local script_name = source_path:match(".*[/\\](.*)")
target_path = target_path .. script_name
if not bmd.fileexists(source_path) then
local dialog = CreateDialog("🛑 Uh Oh!",
"Snap Captions can’t find itself to install! WHAT AN EXISTENTIAL CRISIS 😱!?!", noSnapPathFound )
dialog:Show()
dialog:RecalcLayout()
return false
end
-- Copy the file.
local success = CopyFile(source_path, target_path)
if not success then
local dialog = CreateDialog("🛑 Uh Oh!",
"Snap Captions Can't Get Permission To Install Into Resolve! The Housing Crisis Even Affects Digital Plugin's Now 🥺", snapInstallFailed )
dialog:Show()
dialog:RecalcLayout()
return false
end
-- Also copy the utf8 modules to the Modules folder.
local utf8_source = source_path:match("(.*[/\\]).+$") .. "utf8_snapcaptions.lua"
local utf8_target = modules_path .. "utf8_snapcaptions.lua"
if not bmd.fileexists(utf8_source) then
local dialog = CreateDialog("🛑 Uh Oh!",
"The UTF8 File Is Missing! It should have been in the same folder as Snap Captions to ensure it get's included with Installation.", noUTF8File )
dialog:Show()
dialog:RecalcLayout()
return false
end
local success = CopyFile(utf8_source, utf8_target)
if success then
-- Reload the utf8 module.
LoadUTF8Module()
else
local dialog = CreateDialog("🛑 Uh Oh!",
"UTF8 File Failed To Install Into Snap Captions", UTF8FailedInstall )
dialog:Show()
dialog:RecalcLayout()
return false
end
if not bmd.direxists(installFolder) then
bmd.createdir(installFolder)
end
local cleanpack_source = source_path:match("(.*[/\\]).+$") .. CleanPackName
local cleanpack_target = installFolder .."/".. extractSnapCaptions(parseFilename(cleanpack_source).Name).."/"..parseFilename(cleanpack_source).FullName
if not bmd.fileexists(cleanpack_source) then
local dialog = CreateDialog("🛑 Uh Oh!",
"🤔 Snap Captions Can't Find The Clean Caption Template Pack To Install!", noCleanPack )
dialog:Show()
dialog:RecalcLayout()
return false
end
--Install the Clean Pack to the Packs Library
local success = CopyDRB(cleanpack_source, cleanpack_target)
if not success then
local dialog = CreateDialog("🛑 Uh Oh!",
"🤔 Snap Captions Couldn't Install Some Caption Templates To Get Started! 😱 We have no Caption Templates 😱", CleanFailedInstall )
dialog:Show()
dialog:RecalcLayout()
return false
end
print("[Snap Captions] Installed to " .. target_path)
print("[UTF8 Module] Installed to " .. utf8_target)
print("[Clean Pack] Installed to " .. cleanpack_target)
return true
end
local function PopulateSubtitleTracks(win)
local combobox = win:Find("subtitle_tracks")
local subtitle_stack = win:Find("subtitle_stack")
local subtitle_placeholder = win:Find("subtitle_placeholder")
combobox:Clear()
local timeline = project:GetCurrentTimeline()
local track_count = timeline:GetTrackCount("subtitle")
if track_count == 0 then
-- ASK TO GENERATE SUBS FOR USER
combobox:SetEnabled(false)
subtitle_stack:SetCurrentIndex(1)
combobox:SetVisible(false)
subtitle_placeholder:SetVisible(true)
return
end
subtitle_stack:SetCurrentIndex(0)
combobox:SetEnabled(true)
subtitle_placeholder:SetVisible(false)
combobox:SetVisible(true)
for i=1,track_count do
win:Find("subtitle_tracks"):AddItems(
{"[ST" .. i .. "] " .. timeline:GetTrackName("subtitle", i)})
end
end
-- Function to list all files in a folder
local function listFiles(folder)
local files = {}
-- Determine the command based on the platform
local command = platform == 'Windows' and ('dir "' .. folder .. '" /b /a-d') or ('ls -p "' .. folder .. '" | grep -v /')
-- Execute the command silently and capture the output
local handle = io.popen(command)
if handle then
for file in handle:lines() do
table.insert(files, folder .. "/" .. file)
end
handle:close()
end
if not files[1] then
error("NO FILE FOUND IN "..folder)
return nil
end
return files
end
-- Function to filter files based on the naming pattern
local function filterFilesByName(files)
local matchingFiles = {}
if #files > 0 then
for _, filePath in ipairs(files) do
if bmd.fileexists(filePath) then
-- Extract the filename from the full path
local fileName = filePath:match("^.+[\\/](.+)$") or filePath
-- Convert filename to lowercase for case-insensitive matching
local lowerFile = string.lower(fileName)
-- Updated pattern: removed the hyphen
if lowerFile:match("^snap captions .*%.drb$") then
table.insert(matchingFiles, parseFilename(filePath))
end
end
end
return matchingFiles
end
end
local function notInstalled(files)
local installedPacks = mediaStorage:GetSubFolderList(installFolder)
local newPacks = {}
for _, foundPack in ipairs(files) do
local isInstalled = false
for _, pack in ipairs(installedPacks) do
if #pack > 0 then
local drb = parseFilename(listFiles(pack)[1])
if foundPack.FullName == drb.FullName then
isInstalled = true
break
end
end
end
if not isInstalled then
table.insert(newPacks, foundPack)
end
end
return newPacks
end
-- Main function to get new packs
local function getNewPacks()
-- Retrieve the watch folder path
local watchFolder = app:GetData("SnapCaptions.WatchFolder")
-- List all files in the watch folder
local allFiles = listFiles(watchFolder)
-- Filter files based on the naming criteria
local matchingFiles = filterFilesByName(allFiles)
local newPacks = notInstalled(matchingFiles)
-- Return the matching files
if newPacks and #newPacks > 0 then
return newPacks
end
return nil
end
local function setNewWatchFolder()
local newPath = app:MapPath(app:RequestDir(
app:GetData("SnapCaptions.WatchFolder"),
{
FReqS_Title = 'Choose a Folder to Search In',
}
))
if newPath then
app:SetData("SnapCaptions.WatchFolder", newPath)
return true
end
return false
end
local function addToLib(dialog)
local addtoLib = disp:AddWindow({
ID = "AddToLib",
WindowTitle = "Snap Captions - Add to Library",
ui:VGroup{
ID = "root",
FixedSize = {325, 500},
ui:VGroup{
ID = "mainLabels",
Weight = 0,
Alignment = { AlignCenter = true },
ui:Label{ Text = "ADD TO LIBRARY", Alignment = { AlignCenter = true }, Weight = 0, StyleSheet = TITLE_CSS }
},
ui:HGroup{
Weight = 0,
ui:Button{ ID = "tutorial", Text = "Tutorial", Weight = 0.5 },
ui:Button{ ID = "get_Captions", Text = "Get More Text Packs", Weight = 0.5 },
},
ui:Label{ Text = "CAPTION PACKS FOUND", Alignment = { AlignCenter = true }, Weight = 0, StyleSheet = SMALLER_TITLE_CSS },
ui:VGroup{
ID = 'uninstalledFound',
Weight = 0.5,
ui:VGroup{
ID = "uninstalledPacks",
Weight = 0.5,
ui:Tree{ ID = "drbList", HeaderHidden = true, AlternatingRowColors = true, RootIsDecorated = false, Events = {ItemChanged = true}, Alignment = { AlignCenter = true } }
},
ui:Button{ ID = "Move", Text = "▼▼▼ ADD SELECTED PACKS ▼▼▼", Weight = 0, StyleSheet = PRIMARY_ACTION_BUTTON_CSS },
},
ui:Label{ Text = "YOUR LIBRARY", Alignment = { AlignCenter = true }, Weight = 0, StyleSheet = SMALLER_TITLE_CSS },
ui:VGroup{
ID = 'installedPackImport',
Weight = 0.5,
ui:VGroup{
ID = "installedPacks",
ui:Tree{ ID = "PackList", SelectionMode = false, HeaderHidden = true, AlternatingRowColors = true, RootIsDecorated = false, Alignment = { AlignCenter = true } }
}
}
}
})
local winItms = addtoLib:GetItems()
function addtoLib.On.tutorial.Clicked(ev)
OpenURL(PackMangagerTUT)
end
function addtoLib.On.get_Captions.Clicked(ev)
OpenURL(GetMorePacks)
end
function updatePacks(installedPacks, installPacks)
_G.packs = {}
winItms.PackList:Clear()
if installedPacks then
for i, folder in ipairs(installedPacks) do
local itrow2 = winItms.PackList:NewItem()
local packName = parseFilename(folder).FullName
itrow2.Text[0] = packName
winItms.PackList:AddTopLevelItem(itrow2)
table.insert(packs, listFiles(folder)[1])
end
end
_G.notinstalledPacks = {}
winItms.drbList:Clear()
if installPacks then
for _, drb in ipairs(installPacks) do
local itrow = winItms.drbList:NewItem()
local packName = drb.FullName
itrow.Text[0] = packName
itrow.CheckState[0] = false and "Checked" or "Unchecked"
winItms.drbList:AddTopLevelItem(itrow)
table.insert(notinstalledPacks, drb)
end
end
end
local success = true
function addtoLib.On.Move.Clicked(ev)
for row = 0, winItms.drbList:TopLevelItemCount() - 1 do
local item = winItms.drbList:TopLevelItem(row)
if item.CheckState[0] == "Checked" then
local packPath = notinstalledPacks[row+1]
CopyDRB(packPath.FullPath, installFolder .. "/" .. extractSnapCaptions(packPath.Name) .. "/" .. packPath.FullName)
table.insert(packs, row+1, packPath)
end
end
success = true
disp:ExitLoop()
end
local installedPacks = mediaStorage:GetSubFolderList(installFolder)
local newPacks = getNewPacks()
updatePacks(installedPacks, newPacks)
function addtoLib.On.AddToLib.Close(ev)
success = false
disp:ExitLoop()
end
dialog:Hide()
dialog = nil
addtoLib:RecalcLayout()
addtoLib:Show()
disp:RunLoop()
addtoLib:Hide()
return success
end
local function noPacksFound(dialog)
local function installPacks()
local yourLibrary = disp:AddWindow({
ID = "YourLibrary",
WindowTitle = "Snap Captions - Your Library",
ui:VGroup{
ID = "root",
FixedSize = {325, 500},
ui:VGroup{
ID = "mainLabels",
Weight = 0,
Alignment = { AlignCenter = true },
ui:Label{ Text = "YOUR LIBRARY", Alignment = { AlignCenter = true }, Weight = 0, StyleSheet = TITLE_CSS }
},
ui:HGroup{
Weight = 0,
ui:Button{ ID = "tutorial", Text = "Tutorial", Weight = 0.5 },
ui:Button{ ID = "add_Captions", Text = "Add to Your Library", Weight = 0.5 },
},
ui:VGroup{
ID = 'installedPackImport',
ui:VGroup{
ID = "installedPacks",
ui:Tree{ ID = "PackList", AlternatingRowColors = true, RootIsDecorated = false, Events = {ItemChanged = true}, Alignment = { AlignCenter = true } }
},
ui:Button{ ID = "Add", Text = "USE SELECTED PACK", Weight = 0.5, StyleSheet = PRIMARY_ACTION_BUTTON_CSS }
}
}
})
local winItms = yourLibrary:GetItems()
function yourLibrary.On.tutorial.Clicked(ev)
OpenURL(PackMangagerTUT)
end
winItms.PackList:SetHeaderLabels({"Pack Name"})
function yourLibrary.On.add_Captions.Clicked(ev)
local setFolder = setNewWatchFolder()
if setFolder then
local dialog = CreateDialog("I’m Looking 👀 For Compatible Captions",
"You may see Terminal windows, this is okay \n" ..
"Please Hold...", nil, true )
dialog:Show()
dialog:RecalcLayout()
if setFolder then
local newPacks = getNewPacks()
if newPacks then
yourLibrary:Hide()
local success = addToLib(dialog)
if success then
disp:ExitLoop()
installPacks()
disp:ExitLoop()
else
yourLibrary:Show()
end
else
dialog:Hide()
dialog = nil
local dialog = CreateDialog("🕵️♂️ A Mystery!",
"Snap Captions Can't Find Any Compatable Caption Packs",
noNewPacks)
dialog:RecalcLayout()
dialog:Show()
disp:RunLoop()
disp:ExitLoop()
end
end
else
yourLibrary:Show()
end
end
local selectedInstalled
function updatePacks(installedPacks)
_G.packs = {}
winItms.PackList:Clear()
local itrow1 = winItms.PackList:NewItem()
itrow1.Text[0] = "Create Empty Folder (BYO Templates 🍺)"
itrow1.CheckState[0] = true and "Checked" or "Unchecked"
winItms.PackList:AddTopLevelItem(itrow1)
selectedInstalled = winItms.PackList:ItemAt(0)
if installedPacks then
for i, folder in ipairs(installedPacks) do
local itrow2 = winItms.PackList:NewItem()
local packName = parseFilename(folder).FullName
itrow2.Text[0] = packName