forked from koush/ROMManagerManifest
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcleaner.rb
45 lines (38 loc) · 1.05 KB
/
cleaner.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
require 'rubygems'
require 'json'
require 'open-uri'
data = File.open('manual_manifests.js').read
parsed_data = JSON.parse(data)
manifests = parsed_data['manifests']
threads = []
for manifest in manifests:
threads << Thread.new(manifest) { |myManifest|
url = myManifest['manifest']
begin
test = open(url).read
parsed_test = JSON.parse(test)
myManifest['visible'] = true
rescue
begin
test = open('http://dirtyjson.deployfu.com?url=' + url).read
parsed_test = JSON.parse(test)
myManifest['visible'] = true
rescue
puts url + ' failed to parse'
myManifest['visible'] = false
end
end
}
end
threads.each { |aThread| aThread.join }
new_manifests = []
for manifest in manifests:
if manifest['visible'] then
new_manifests << manifest
manifest.delete('visible')
else
puts "Nuking: " + manifest['developer'] + " " + manifest['manifest']
end
end
parsed_data['manifests'] = new_manifests
File.open('manual_manifests.js', 'w').write(JSON.pretty_generate(parsed_data))