-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert.rb
98 lines (90 loc) · 2.84 KB
/
convert.rb
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
require 'csv'
## Edit only if you do not use the default locations.
CSV_FILE = 'mod_list.csv'
SMC_FILE = 'smc_list.csv'
MERGED_FILE = 'merged_list.csv'
HTML_FILE = 'mod_list.html'
##
mods = []
total_mods = 0
audio_mods = 8
utility_mods = 19
visual_mods = 90
abort 'CSV file not found!' unless File.exist?(CSV_FILE)
puts ''
puts '=== processing CSV file'
CSV.foreach(CSV_FILE, headers: true) do |row|
mods << {
nexus_id: row[0],
name: row[1].gsub('&', '&'),
version: row[2]
}
end
mods.uniq! { |mod| mod[:name] }
mods.sort_by! { |mod| mod[:name] }
open(HTML_FILE, 'w') do |f|
count = 0
f.puts '<h2>Activated Mods (Merged Mods Not Included)</h2>'
f.puts '<ul>'
mods.each do |mod|
next if mod[:name][0] == '!'
next if mod[:name][0..9] == 'Unmanaged:'
next if mod[:name][0..2].downcase == 'smc'
count += 1
version = mod[:version][0] == 'd' ? '' : " <i>(#{mod[:version].chomp})</i>"
if mod[:nexus_id] == '0'
f.puts "<li>#{mod[:name].gsub('&', '&')}#{version}</li>"
else
f.puts "<li><a href='http://www.nexusmods.com/skyrim/mods/#{mod[:nexus_id]}/?'>#{mod[:name].chomp.gsub('&', '&')}</a>#{version}</li>"
end
end
f.puts '</ul>'
total_mods += count
puts "=== #{count} activated mods added to list"
if File.exist?(MERGED_FILE)
categorized = []
CSV.foreach(MERGED_FILE) do |row|
categorized << {
category: row[0],
name: row[1],
nexus_id: row[2],
version: row[3]
}
end
f.puts ''
f.puts '<h2>Merged Mods (Merge File -- Mod Name)</h2>'
f.puts '<ul>'
categorized.each do |mod|
version = mod[:version][0] == '' ? '' : " <i>(#{mod[:version].chomp})</i>"
if mod[:nexus_id] == '0' || mod[:nexus_id] == ''
f.puts "<li>#{mod[:category].gsub('&', '&')} -- #{mod[:name].gsub('&', '&')}#{version}</li>"
else
f.puts "<li>#{mod[:category].gsub('&', '&')} -- <a href='http://www.nexusmods.com/skyrim/mods/#{mod[:nexus_id]}/?'>#{mod[:name].chomp.gsub('&', '&')}</a>#{version}</li>"
end
visual_mods += 1 if mod[:category] == 'Visuals'
end
f.puts '</ul>'
total_mods += categorized.count
puts "=== #{categorized.count} merged mods added to list"
end
if File.exist?(SMC_FILE)
count = 0
count += 1
f.puts ''
f.puts '<h2>Mods Merged by Skyrim Mod Combiner</h2>'
f.puts '<ul>'
CSV.foreach(SMC_FILE) do |row|
count += 1
visual_mods += 1
f.puts "<li>#{row[0].gsub('&', '&')}</li>"
end
f.puts '</ul>'
total_mods += count
puts "=== #{count} SMC mods added to list"
end
end
puts "=== conversion complete"
puts "=== Your list contains #{total_mods} total mods."
puts "=== Your list contains #{audio_mods} audio mods."
puts "=== Your list contains #{visual_mods} visual mods."
puts "=== Your list contains #{utility_mods} utility mods."