-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetupSmugmugCollections.lua
More file actions
125 lines (106 loc) · 4.09 KB
/
SetupSmugmugCollections.lua
File metadata and controls
125 lines (106 loc) · 4.09 KB
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
local LrDialogs = import 'LrDialogs'
local LrLogger = import 'LrLogger'
local LrErrors = import 'LrErrors'
local LrApplication = import "LrApplication"
local myLogger = LrLogger( 'libraryLogger' )
local LrTasks = import 'LrTasks'
local LrFunctionContext = import 'LrFunctionContext'
myLogger:enable( "print" ) -- or "logfile"
MyHWExportItem = {}
function table_print (tt, indent, done)
done = done or {}
indent = indent or 0
if type(tt) == "table" then
local sb = {}
for key, value in pairs (tt) do
table.insert(sb, string.rep (" ", indent)) -- indent it
if type (value) == "table" and not done [value] then
done [value] = true
table.insert(sb, "{\n");
table.insert(sb, table_print (value, indent + 2, done))
table.insert(sb, string.rep (" ", indent)) -- indent it
table.insert(sb, "}\n");
elseif "number" == type(key) then
table.insert(sb, string.format("\"%s\"\n", tostring(value)))
else
table.insert(sb, string.format(
"%s = \"%s\"\n", tostring (key), tostring(value)))
end
end
return table.concat(sb)
else
return tt .. "\n"
end
end
function to_string( tbl )
if "nil" == type( tbl ) then
return tostring(nil)
elseif "table" == type( tbl ) then
return table_print(tbl)
elseif "string" == type( tbl ) then
return tbl
else
return tostring(tbl)
end
end
function MyHWExportItem.setup_smugmug_collections()
local catalog = LrApplication.activeCatalog()
local all_services = catalog:getPublishServices(nil)
local names = {}
for k, v in pairs(all_services) do
names[v:getName()] = v
end
local target_service = names['scottgorlin']
local collection_sets = target_service:getChildCollectionSets()
local set_names = {}
for k, v in pairs(collection_sets) do
set_names[v:getName()] = v
end
local archive = set_names['Archive']
--LrDialogs.message("ExportMenuItem Selected", to_string(archive:getCollectionSetInfoSummary()['collectionSettings']), "helloworld info")
local months = {"01", "02", "03", '04', '05', '06', '07', '08', '09', '10', '11', '12'}
local years = {'2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020'}
for yi, year in pairs(years) do
catalog:withWriteAccessDo('create_smugmug', function( )
year_set = target_service:createPublishedCollectionSet(tostring(year), archive, true)
for ki, month in pairs(months) do
local my = year .. '-' .. month
local searchDesc = {
{
criteria = "keywords",
operation = "noneOf",
value = "PRIVATE",
},
{
criteria = "keywords",
operation = "noneOf",
value = "PROFESSIONALS",
},
{
criteria = "pick",
operation = '!=',
value = -1,
},
{
criteria = "captureTime",
operation = "in",
value = my .. '-01',
value2 = my .. '-32',
},
{
criteria = "labelColor",
operation = "==",
value = 'none',
},
combine = "intersect",
}
month_collection = target_service:createPublishedSmartCollection(my, searchDesc, year_set, true )
month_collection:setSearchDescription(searchDesc)
--summary = month_collection:getCollectionInfoSummary()
--settings = summary.collectionSettings
--LrDialogs.message("ExportMenuItem Selected", to_string(settings), "helloworld info")
end
end )
end
end
LrTasks.startAsyncTask(MyHWExportItem.setup_smugmug_collections)