艦娘をちゅーちゅーします
Revisão | 7301616ca24a560a6f3a7164bc85da966c623cf3 (tree) |
---|---|
Hora | 2018-08-20 22:48:14 |
Autor | masakih <masakih@user...> |
Commiter | masakih |
艦これ2期用に改修
@@ -13,33 +13,15 @@ | ||
13 | 13 | F41A44D31F3A09C30066F83D /* ProgressPanelController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F41A44D51F3A09C30066F83D /* ProgressPanelController.xib */; }; |
14 | 14 | F41A44DC1F3B2B7F0066F83D /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = F41A44DE1F3B2B7F0066F83D /* InfoPlist.strings */; }; |
15 | 15 | F41A44E11F3B38C00066F83D /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = F41A44E01F3B38C00066F83D /* LICENSE */; }; |
16 | + F473F0442129243800EAC987 /* PickupInformation.swift in Sources */ = {isa = PBXBuildFile; fileRef = F473F0432129243800EAC987 /* PickupInformation.swift */; }; | |
16 | 17 | F4EAFCBE1F369E71007B7506 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4EAFCBD1F369E71007B7506 /* AppDelegate.swift */; }; |
17 | 18 | F4EAFCC01F369E71007B7506 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4EAFCBF1F369E71007B7506 /* ViewController.swift */; }; |
18 | 19 | F4EAFCC21F369E71007B7506 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F4EAFCC11F369E71007B7506 /* Assets.xcassets */; }; |
19 | 20 | F4EAFCC51F369E71007B7506 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F4EAFCC31F369E71007B7506 /* Main.storyboard */; }; |
20 | 21 | F4EAFCCD1F36A28C007B7506 /* pickup.rb in Resources */ = {isa = PBXBuildFile; fileRef = F4EAFCCC1F36A28B007B7506 /* pickup.rb */; }; |
21 | - F4EAFCCF1F36B8FE007B7506 /* PickUpSWF.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4EAFCCE1F36B8FE007B7506 /* PickUpSWF.swift */; }; | |
22 | - F4EAFCD61F36D786007B7506 /* KanColleGraphicDivider in Resources */ = {isa = PBXBuildFile; fileRef = F4EAFCD51F36D786007B7506 /* KanColleGraphicDivider */; }; | |
23 | - F4EAFCE01F36D9E5007B7506 /* ExtractKanmusu.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4EAFCDF1F36D9E5007B7506 /* ExtractKanmusu.swift */; }; | |
22 | + F4EAFCCF1F36B8FE007B7506 /* PickupPNG.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4EAFCCE1F36B8FE007B7506 /* PickupPNG.swift */; }; | |
24 | 23 | /* End PBXBuildFile section */ |
25 | 24 | |
26 | -/* Begin PBXContainerItemProxy section */ | |
27 | - F4EAFCDB1F36D7C7007B7506 /* PBXContainerItemProxy */ = { | |
28 | - isa = PBXContainerItemProxy; | |
29 | - containerPortal = F4EAFCD71F36D7C6007B7506 /* KanColleGraphicDivider.xcodeproj */; | |
30 | - proxyType = 2; | |
31 | - remoteGlobalIDString = F44C14B71D84F07300ADE497; | |
32 | - remoteInfo = KanColleGraphicDivider; | |
33 | - }; | |
34 | - F4EAFCDD1F36D7D7007B7506 /* PBXContainerItemProxy */ = { | |
35 | - isa = PBXContainerItemProxy; | |
36 | - containerPortal = F4EAFCD71F36D7C6007B7506 /* KanColleGraphicDivider.xcodeproj */; | |
37 | - proxyType = 1; | |
38 | - remoteGlobalIDString = F44C14B61D84F07300ADE497; | |
39 | - remoteInfo = KanColleGraphicDivider; | |
40 | - }; | |
41 | -/* End PBXContainerItemProxy section */ | |
42 | - | |
43 | 25 | /* Begin PBXFileReference section */ |
44 | 26 | F41A44C61F3710D10066F83D /* ProgressPanelController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressPanelController.swift; sourceTree = "<group>"; }; |
45 | 27 | F41A44CD1F38B8510066F83D /* ApplicationDirecrories.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApplicationDirecrories.swift; sourceTree = "<group>"; }; |
@@ -48,6 +30,7 @@ | ||
48 | 30 | F41A44D61F3B29990066F83D /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Main.strings; sourceTree = "<group>"; }; |
49 | 31 | F41A44DD1F3B2B7F0066F83D /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/InfoPlist.strings; sourceTree = "<group>"; }; |
50 | 32 | F41A44E01F3B38C00066F83D /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; }; |
33 | + F473F0432129243800EAC987 /* PickupInformation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickupInformation.swift; sourceTree = "<group>"; }; | |
51 | 34 | F4EAFCBA1F369E71007B7506 /* ExtractKanMusu.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExtractKanMusu.app; sourceTree = BUILT_PRODUCTS_DIR; }; |
52 | 35 | F4EAFCBD1F369E71007B7506 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; |
53 | 36 | F4EAFCBF1F369E71007B7506 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; }; |
@@ -55,11 +38,7 @@ | ||
55 | 38 | F4EAFCC41F369E71007B7506 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; }; |
56 | 39 | F4EAFCC61F369E71007B7506 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; |
57 | 40 | F4EAFCCC1F36A28B007B7506 /* pickup.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = pickup.rb; sourceTree = "<group>"; }; |
58 | - F4EAFCCE1F36B8FE007B7506 /* PickUpSWF.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PickUpSWF.swift; sourceTree = "<group>"; }; | |
59 | - F4EAFCD21F36D6C2007B7506 /* KanColleGraphicDivider */ = {isa = PBXFileReference; lastKnownFileType = text; name = KanColleGraphicDivider; path = KanColleGraphicDivider/build/Debug/KanColleGraphicDivider; sourceTree = "<group>"; }; | |
60 | - F4EAFCD51F36D786007B7506 /* KanColleGraphicDivider */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; path = KanColleGraphicDivider; sourceTree = BUILT_PRODUCTS_DIR; }; | |
61 | - F4EAFCD71F36D7C6007B7506 /* KanColleGraphicDivider.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = KanColleGraphicDivider.xcodeproj; path = KanColleGraphicDivider/KanColleGraphicDivider.xcodeproj; sourceTree = "<group>"; }; | |
62 | - F4EAFCDF1F36D9E5007B7506 /* ExtractKanmusu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExtractKanmusu.swift; sourceTree = "<group>"; }; | |
41 | + F4EAFCCE1F36B8FE007B7506 /* PickupPNG.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PickupPNG.swift; sourceTree = "<group>"; }; | |
63 | 42 | /* End PBXFileReference section */ |
64 | 43 | |
65 | 44 | /* Begin PBXFrameworksBuildPhase section */ |
@@ -76,8 +55,6 @@ | ||
76 | 55 | F4EAFCB11F369E71007B7506 = { |
77 | 56 | isa = PBXGroup; |
78 | 57 | children = ( |
79 | - F4EAFCD71F36D7C6007B7506 /* KanColleGraphicDivider.xcodeproj */, | |
80 | - F4EAFCD51F36D786007B7506 /* KanColleGraphicDivider */, | |
81 | 58 | F4EAFCBC1F369E71007B7506 /* ExtractKanMusu */, |
82 | 59 | F4EAFCBB1F369E71007B7506 /* Products */, |
83 | 60 | F4EAFCD11F36D6C1007B7506 /* Frameworks */, |
@@ -103,8 +80,8 @@ | ||
103 | 80 | F41A44D51F3A09C30066F83D /* ProgressPanelController.xib */, |
104 | 81 | F41A44D11F39E1450066F83D /* ChuuChuu.swift */, |
105 | 82 | F4EAFCCC1F36A28B007B7506 /* pickup.rb */, |
106 | - F4EAFCCE1F36B8FE007B7506 /* PickUpSWF.swift */, | |
107 | - F4EAFCDF1F36D9E5007B7506 /* ExtractKanmusu.swift */, | |
83 | + F4EAFCCE1F36B8FE007B7506 /* PickupPNG.swift */, | |
84 | + F473F0432129243800EAC987 /* PickupInformation.swift */, | |
108 | 85 | F4EAFCC11F369E71007B7506 /* Assets.xcassets */, |
109 | 86 | F4EAFCC61F369E71007B7506 /* Info.plist */, |
110 | 87 | F41A44DE1F3B2B7F0066F83D /* InfoPlist.strings */, |
@@ -116,19 +93,10 @@ | ||
116 | 93 | F4EAFCD11F36D6C1007B7506 /* Frameworks */ = { |
117 | 94 | isa = PBXGroup; |
118 | 95 | children = ( |
119 | - F4EAFCD21F36D6C2007B7506 /* KanColleGraphicDivider */, | |
120 | 96 | ); |
121 | 97 | name = Frameworks; |
122 | 98 | sourceTree = "<group>"; |
123 | 99 | }; |
124 | - F4EAFCD81F36D7C6007B7506 /* Products */ = { | |
125 | - isa = PBXGroup; | |
126 | - children = ( | |
127 | - F4EAFCDC1F36D7C7007B7506 /* KanColleGraphicDivider */, | |
128 | - ); | |
129 | - name = Products; | |
130 | - sourceTree = "<group>"; | |
131 | - }; | |
132 | 100 | /* End PBXGroup section */ |
133 | 101 | |
134 | 102 | /* Begin PBXNativeTarget section */ |
@@ -143,7 +111,6 @@ | ||
143 | 111 | buildRules = ( |
144 | 112 | ); |
145 | 113 | dependencies = ( |
146 | - F4EAFCDE1F36D7D7007B7506 /* PBXTargetDependency */, | |
147 | 114 | ); |
148 | 115 | name = ExtractKanMusu; |
149 | 116 | productName = ExtractKanMusu; |
@@ -177,12 +144,6 @@ | ||
177 | 144 | mainGroup = F4EAFCB11F369E71007B7506; |
178 | 145 | productRefGroup = F4EAFCBB1F369E71007B7506 /* Products */; |
179 | 146 | projectDirPath = ""; |
180 | - projectReferences = ( | |
181 | - { | |
182 | - ProductGroup = F4EAFCD81F36D7C6007B7506 /* Products */; | |
183 | - ProjectRef = F4EAFCD71F36D7C6007B7506 /* KanColleGraphicDivider.xcodeproj */; | |
184 | - }, | |
185 | - ); | |
186 | 147 | projectRoot = ""; |
187 | 148 | targets = ( |
188 | 149 | F4EAFCB91F369E71007B7506 /* ExtractKanMusu */, |
@@ -190,22 +151,11 @@ | ||
190 | 151 | }; |
191 | 152 | /* End PBXProject section */ |
192 | 153 | |
193 | -/* Begin PBXReferenceProxy section */ | |
194 | - F4EAFCDC1F36D7C7007B7506 /* KanColleGraphicDivider */ = { | |
195 | - isa = PBXReferenceProxy; | |
196 | - fileType = "compiled.mach-o.executable"; | |
197 | - path = KanColleGraphicDivider; | |
198 | - remoteRef = F4EAFCDB1F36D7C7007B7506 /* PBXContainerItemProxy */; | |
199 | - sourceTree = BUILT_PRODUCTS_DIR; | |
200 | - }; | |
201 | -/* End PBXReferenceProxy section */ | |
202 | - | |
203 | 154 | /* Begin PBXResourcesBuildPhase section */ |
204 | 155 | F4EAFCB81F369E71007B7506 /* Resources */ = { |
205 | 156 | isa = PBXResourcesBuildPhase; |
206 | 157 | buildActionMask = 2147483647; |
207 | 158 | files = ( |
208 | - F4EAFCD61F36D786007B7506 /* KanColleGraphicDivider in Resources */, | |
209 | 159 | F41A44DC1F3B2B7F0066F83D /* InfoPlist.strings in Resources */, |
210 | 160 | F4EAFCCD1F36A28C007B7506 /* pickup.rb in Resources */, |
211 | 161 | F4EAFCC21F369E71007B7506 /* Assets.xcassets in Resources */, |
@@ -224,8 +174,8 @@ | ||
224 | 174 | files = ( |
225 | 175 | F41A44CE1F38B8510066F83D /* ApplicationDirecrories.swift in Sources */, |
226 | 176 | F4EAFCC01F369E71007B7506 /* ViewController.swift in Sources */, |
227 | - F4EAFCCF1F36B8FE007B7506 /* PickUpSWF.swift in Sources */, | |
228 | - F4EAFCE01F36D9E5007B7506 /* ExtractKanmusu.swift in Sources */, | |
177 | + F4EAFCCF1F36B8FE007B7506 /* PickupPNG.swift in Sources */, | |
178 | + F473F0442129243800EAC987 /* PickupInformation.swift in Sources */, | |
229 | 179 | F41A44D21F39E1450066F83D /* ChuuChuu.swift in Sources */, |
230 | 180 | F4EAFCBE1F369E71007B7506 /* AppDelegate.swift in Sources */, |
231 | 181 | F41A44C81F3710D10066F83D /* ProgressPanelController.swift in Sources */, |
@@ -234,14 +184,6 @@ | ||
234 | 184 | }; |
235 | 185 | /* End PBXSourcesBuildPhase section */ |
236 | 186 | |
237 | -/* Begin PBXTargetDependency section */ | |
238 | - F4EAFCDE1F36D7D7007B7506 /* PBXTargetDependency */ = { | |
239 | - isa = PBXTargetDependency; | |
240 | - name = KanColleGraphicDivider; | |
241 | - targetProxy = F4EAFCDD1F36D7D7007B7506 /* PBXContainerItemProxy */; | |
242 | - }; | |
243 | -/* End PBXTargetDependency section */ | |
244 | - | |
245 | 187 | /* Begin PBXVariantGroup section */ |
246 | 188 | F41A44D51F3A09C30066F83D /* ProgressPanelController.xib */ = { |
247 | 189 | isa = PBXVariantGroup; |
@@ -18,9 +18,16 @@ protocol MessageObserver: class { | ||
18 | 18 | func increse() |
19 | 19 | } |
20 | 20 | |
21 | +private enum ImageType: String { | |
22 | + | |
23 | + case full | |
24 | + | |
25 | + case full_dmg | |
26 | +} | |
27 | + | |
21 | 28 | class ChuuChuu { |
22 | 29 | |
23 | - static let chuchu = "ちゅーちゅー" | |
30 | + static let chuchu = "ちゅーちゅー2" | |
24 | 31 | static let tempDirName = "___temp_chu-chu-_ship___" |
25 | 32 | |
26 | 33 | let observer: MessageObserver |
@@ -42,23 +49,6 @@ class ChuuChuu { | ||
42 | 49 | destinationDir = destination |
43 | 50 | } |
44 | 51 | |
45 | - | |
46 | - private func createTempDir() throws { | |
47 | - | |
48 | - let tempURL = originalDir.appendingPathComponent(ChuuChuu.tempDirName) | |
49 | - | |
50 | - try FileManager.default | |
51 | - .createDirectory(at: tempURL, withIntermediateDirectories: true, attributes: nil) | |
52 | - | |
53 | - } | |
54 | - | |
55 | - private func deleteTempDir() throws { | |
56 | - | |
57 | - let tempURL = originalDir.appendingPathComponent(ChuuChuu.tempDirName) | |
58 | - | |
59 | - try FileManager.default.removeItem(at: tempURL) | |
60 | - } | |
61 | - | |
62 | 52 | private func createDestDir() throws { |
63 | 53 | |
64 | 54 | let destURL = destinationDir.appendingPathComponent(ChuuChuu.chuchu) |
@@ -68,67 +58,79 @@ class ChuuChuu { | ||
68 | 58 | |
69 | 59 | } |
70 | 60 | |
71 | - private func moveSWF(from originalDir: URL, to destinationDir: URL) { | |
61 | + private func movePNG(from originalDir: URL, to destinationDir: URL) { | |
72 | 62 | |
73 | - observer.message = "Picking up SWF file from Cache Directory." | |
63 | + observer.message = "Checking Cache Directory." | |
74 | 64 | |
75 | 65 | do { |
76 | 66 | |
77 | - try pickUpSWF(from: originalDir, to: destinationDir) | |
67 | + let informations = try getPickUpInformations(from: originalDir) | |
78 | 68 | |
79 | - } catch { | |
69 | + observer.message = "Picking up PNG file from Cache Directory." | |
80 | 70 | |
81 | - print("Can not pickup.", terminator: " : ") | |
71 | + observer.count = informations.count | |
82 | 72 | |
83 | - guard let error = error as? PickUPSWFError else { | |
84 | - | |
85 | - print("Unkown error.") | |
86 | - return | |
73 | + let fm = FileManager.default | |
74 | + | |
75 | + try informations | |
76 | + .compactMap { info -> (URL, URL)? in | |
77 | + | |
78 | + observer.increse() | |
79 | + | |
80 | + let url = info.url | |
81 | + let name = url.deletingPathExtension().lastPathComponent | |
82 | + guard let type = url.deletingPathExtension().pathComponents.dropLast().last else { return nil } | |
83 | + guard let _ = ImageType(rawValue: type) else { return nil } | |
84 | + guard let id = Int(name.prefix(4)), id < 1500 else { return nil } | |
85 | + | |
86 | + let destFilename: String | |
87 | + if let query = url.query { | |
88 | + | |
89 | + destFilename = type + "-" + name + "_" + query | |
90 | + | |
91 | + } else { | |
92 | + | |
93 | + destFilename = type + "-" + name | |
94 | + } | |
95 | + | |
96 | + let destination = destinationDir | |
97 | + .appendingPathComponent(ChuuChuu.chuchu) | |
98 | + .appendingPathComponent(destFilename) | |
99 | + .appendingPathExtension("png") | |
100 | + | |
101 | + let original = originalDir | |
102 | + .appendingPathComponent("fsCachedData") | |
103 | + .appendingPathComponent(info.filename) | |
104 | + | |
105 | + return (destination, original) | |
106 | + | |
107 | + } | |
108 | + .filter { destination, _ in | |
109 | + | |
110 | + (try? !destination.checkResourceIsReachable()) ?? true | |
111 | + | |
112 | + } | |
113 | + .forEach { destination, original in | |
114 | + | |
115 | + try fm.copyItem(at: original, to: destination) | |
87 | 116 | } |
88 | 117 | |
118 | + } catch let error as PickupPNGError { | |
119 | + | |
89 | 120 | switch error { |
90 | 121 | case .scriptNotFound: print("Script not found.") |
91 | 122 | |
92 | 123 | case let .commandFail(status): print("Command faile status \(status).") |
93 | 124 | } |
94 | - } | |
95 | - } | |
96 | - | |
97 | - private func extractKanmusus(swfs: [URL], to destURL: URL) { | |
98 | - | |
99 | - observer.message = "Extracting KanMusu Image from SWF file." | |
100 | - | |
101 | - let semaphone = DispatchSemaphore(value: useCoreCount) | |
102 | - let group = DispatchGroup() | |
103 | - let queue = DispatchQueue(label: "extract", attributes: .concurrent) | |
104 | - | |
105 | - swfs.forEach { swf in | |
106 | 125 | |
107 | - queue.async(group: group) { | |
108 | - | |
109 | - semaphone.wait() | |
110 | - | |
111 | - do { | |
112 | - | |
113 | - try extractKanmusu(swf: swf, to: destURL) | |
114 | - | |
115 | - } catch { | |
116 | - | |
117 | - print(error) | |
118 | - } | |
119 | - | |
120 | - semaphone.signal() | |
121 | - | |
122 | - self.observer.increse() | |
123 | - | |
124 | - } | |
126 | + } catch { | |
127 | + | |
128 | + print("Can not pickup.", terminator: " : ") | |
125 | 129 | |
130 | + print("Unkown error.", error) | |
126 | 131 | } |
127 | - | |
128 | - group.wait() | |
129 | 132 | } |
130 | 133 | |
131 | - | |
132 | 134 | func execute(maxPower: Bool, completeHandler: @escaping () -> Void) { |
133 | 135 | |
134 | 136 | guard let existOriginalDir = try? originalDir.checkResourceIsReachable(), |
@@ -152,23 +154,9 @@ class ChuuChuu { | ||
152 | 154 | |
153 | 155 | do { |
154 | 156 | |
155 | - try self.createTempDir() | |
156 | 157 | try self.createDestDir() |
157 | 158 | |
158 | - self.moveSWF(from: self.originalDir, to: self.destinationDir) | |
159 | - | |
160 | - let tempURL = self.originalDir.appendingPathComponent(ChuuChuu.tempDirName) | |
161 | - let destURL = self.destinationDir.appendingPathComponent(ChuuChuu.chuchu) | |
162 | - | |
163 | - let swfs = try FileManager.default | |
164 | - .contentsOfDirectory(at: tempURL, includingPropertiesForKeys: nil) | |
165 | - .filter { $0.pathExtension.lowercased() == "swf" } | |
166 | - | |
167 | - self.observer.count = swfs.count | |
168 | - | |
169 | - self.extractKanmusus(swfs: swfs, to: destURL) | |
170 | - | |
171 | - try self.deleteTempDir() | |
159 | + self.movePNG(from: self.originalDir, to: self.destinationDir) | |
172 | 160 | |
173 | 161 | } catch { |
174 | 162 |
@@ -1,47 +0,0 @@ | ||
1 | -// | |
2 | -// ExtractKanmusu.swift | |
3 | -// ExtractKanMusu | |
4 | -// | |
5 | -// Created by Hori,Masaki on 2017/08/06. | |
6 | -// Copyright © 2017年 Hori,Masaki. All rights reserved. | |
7 | -// | |
8 | - | |
9 | -import Foundation | |
10 | - | |
11 | - | |
12 | -enum ExtractKanmusu: Error { | |
13 | - | |
14 | - case commandNotFound | |
15 | - | |
16 | - case commandError(Int32) | |
17 | -} | |
18 | - | |
19 | -func extractKanmusu(swf: URL, to dir: URL) throws { | |
20 | - | |
21 | - guard let divider = Bundle.main.path(forResource: "KanColleGraphicDivider", ofType: nil) | |
22 | - else { | |
23 | - | |
24 | - throw ExtractKanmusu.commandNotFound | |
25 | - } | |
26 | - | |
27 | - let process = Process() | |
28 | - process.launchPath = divider | |
29 | - | |
30 | - process.arguments = [ | |
31 | - "-s", | |
32 | - "-o", | |
33 | - "\(dir.path)", | |
34 | - "-c", | |
35 | - "17,19", | |
36 | - swf.path | |
37 | - ] | |
38 | - | |
39 | - process.launch() | |
40 | - | |
41 | - process.waitUntilExit() | |
42 | - | |
43 | - guard process.terminationStatus == 0 else { | |
44 | - | |
45 | - throw ExtractKanmusu.commandError(process.terminationStatus) | |
46 | - } | |
47 | -} |
@@ -1,36 +0,0 @@ | ||
1 | -// | |
2 | -// PickUpSWF.swift | |
3 | -// ExtractKanMusu | |
4 | -// | |
5 | -// Created by Hori,Masaki on 2017/08/06. | |
6 | -// Copyright © 2017年 Hori,Masaki. All rights reserved. | |
7 | -// | |
8 | - | |
9 | -import Foundation | |
10 | - | |
11 | - | |
12 | -enum PickUPSWFError: Error { | |
13 | - | |
14 | - case scriptNotFound | |
15 | - case commandFail(Int32) | |
16 | -} | |
17 | - | |
18 | - | |
19 | -func pickUpSWF(from origin: URL, to copy: URL) throws { | |
20 | - | |
21 | - let pickup = Bundle.main.path(forResource: "pickup", ofType: "rb") | |
22 | - guard let pickupPath = pickup | |
23 | - else { throw PickUPSWFError.scriptNotFound } | |
24 | - | |
25 | - let process = Process() | |
26 | - process.currentDirectoryPath = origin.path | |
27 | - process.launchPath = "/usr/bin/ruby" | |
28 | - process.arguments = [pickupPath] | |
29 | - | |
30 | - process.launch() | |
31 | - process.waitUntilExit() | |
32 | - | |
33 | - guard process.terminationStatus == 0 | |
34 | - else { throw PickUPSWFError.commandFail(process.terminationStatus) } | |
35 | - | |
36 | -} |
@@ -0,0 +1,26 @@ | ||
1 | +// | |
2 | +// PickupInformation.swift | |
3 | +// ExtractKanMusu | |
4 | +// | |
5 | +// Created by Hori,Masaki on 2018/08/19. | |
6 | +// Copyright © 2018年 Hori,Masaki. All rights reserved. | |
7 | +// | |
8 | + | |
9 | +import Foundation | |
10 | + | |
11 | +struct PickupInformation: Codable { | |
12 | + | |
13 | + let urlString: String | |
14 | + let filename: String | |
15 | + | |
16 | + var url: URL { | |
17 | + | |
18 | + return URL(string: urlString)! | |
19 | + } | |
20 | + | |
21 | + enum CodingKeys: String, CodingKey { | |
22 | + | |
23 | + case urlString = "url" | |
24 | + case filename | |
25 | + } | |
26 | +} |
@@ -0,0 +1,45 @@ | ||
1 | +// | |
2 | +// PickupPNG.swift | |
3 | +// ExtractKanMusu | |
4 | +// | |
5 | +// Created by Hori,Masaki on 2017/08/06. | |
6 | +// Copyright © 2017年 Hori,Masaki. All rights reserved. | |
7 | +// | |
8 | + | |
9 | +import Foundation | |
10 | + | |
11 | + | |
12 | +enum PickupPNGError: Error { | |
13 | + | |
14 | + case scriptNotFound | |
15 | + case commandFail(Int32) | |
16 | +} | |
17 | + | |
18 | + | |
19 | +func getPickUpInformations(from origin: URL) throws -> [PickupInformation] { | |
20 | + | |
21 | + let pickup = Bundle.main.path(forResource: "pickup", ofType: "rb") | |
22 | + guard let pickupPath = pickup else { throw PickupPNGError.scriptNotFound } | |
23 | + | |
24 | + let process = Process() | |
25 | + process.currentDirectoryPath = origin.path | |
26 | + process.launchPath = "/usr/bin/ruby" | |
27 | + process.arguments = [pickupPath] | |
28 | + | |
29 | + let pipe = Pipe() | |
30 | + process.standardOutput = pipe | |
31 | + | |
32 | + process.launch() | |
33 | + | |
34 | + let data = pipe.fileHandleForReading.readDataToEndOfFile() | |
35 | + | |
36 | + process.waitUntilExit() | |
37 | + | |
38 | + guard process.terminationStatus == 0 else { | |
39 | + | |
40 | + throw PickupPNGError.commandFail(process.terminationStatus) | |
41 | + } | |
42 | + | |
43 | + return try JSONDecoder().decode([PickupInformation].self, from: data) | |
44 | + | |
45 | +} |
@@ -1,33 +1,21 @@ | ||
1 | - | |
2 | - | |
3 | - | |
4 | -require 'rubygems' | |
5 | 1 | require 'sqlite3' |
6 | -require 'uri' | |
7 | - | |
8 | -db = SQLite3::Database.new("Cache.db") | |
9 | - | |
10 | -cursor = db.execute("select request_key, receiver_data from cfurl_cache_response INNER JOIN cfurl_cache_receiver_data ON cfurl_cache_response.entry_ID = cfurl_cache_receiver_data.entry_ID where cfurl_cache_response.request_key LIKE '%resources/swf/ships/%';") | |
11 | 2 | |
3 | +db = SQLite3::Database.new("Cache.db") | |
12 | 4 | |
13 | -currentPath = File.expand_path('fsCachedData/') | |
14 | -tempDir = File.expand_path('___temp_chu-chu-_ship___') | |
5 | +cursor = db.execute("SELECT request_key, receiver_data FROM cfurl_cache_response INNER JOIN cfurl_cache_receiver_data ON cfurl_cache_response.entry_ID = cfurl_cache_receiver_data.entry_ID where cfurl_cache_response.request_key LIKE '%resources/ship/%' AND NOT cfurl_cache_response.request_key LIKE '%album_status%';") | |
15 | 6 | |
7 | +print "[\n" | |
16 | 8 | cursor.each do |row| |
17 | - aURI = URI.split(row[0]) | |
18 | -# p aURI | |
19 | - fullpath = aURI[5] | |
20 | - dir, file = File::split(fullpath) | |
21 | - param = aURI[7] | |
22 | - unless param | |
23 | - filename = file | |
24 | - else | |
25 | - filename = param + "_" + file | |
26 | - end | |
27 | - | |
28 | - original = File.expand_path(row[1], currentPath) | |
29 | - copy = File.expand_path(filename, tempDir) | |
30 | - | |
31 | - command = 'cp ' + '"' + original + '"' + " " + '"' + copy + '"' | |
32 | - system(command) | |
9 | + print "\t{\n" | |
10 | + | |
11 | + print "\t\t\"url\": \"" | |
12 | + print row[0] | |
13 | + print "\",\n" | |
14 | + | |
15 | + print "\t\t\"filename\": \"" | |
16 | + print row[1] | |
17 | + print "\"\n" | |
18 | + | |
19 | + print "\t},\n" | |
33 | 20 | end |
21 | +print "]\n" |