diff --git a/Classes/OCRManager.swift b/Classes/OCRManager.swift index 761d642..e70cd33 100644 --- a/Classes/OCRManager.swift +++ b/Classes/OCRManager.swift @@ -159,7 +159,7 @@ final class OCRManager { OCRLanguage(langCode: "kk", name: "kaz.traineddata"), OCRLanguage(langCode: "km", name: "khm.traineddata"), OCRLanguage(langCode: "ky", name: "kir.traineddata"), -// OCRLanguage(langCode: "kmr", name: "kmr.traineddata"), + OCRLanguage(langCode: "ku", name: "kmr.traineddata"), OCRLanguage(langCode: "ko", name: "kor.traineddata"), // OCRLanguage(langCode: "kor_vert", name: "kor_vert.traineddata"), OCRLanguage(langCode: "lo", name: "lao.traineddata"), @@ -229,16 +229,16 @@ final class OCRManager { NotificationCenter.default.post(name: OCRManager.updateNotification, object: self) } - private func destinationURL() -> URL? { - return FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first?.appendingPathComponent("Subler", isDirectory: true).appendingPathComponent("tessdata", isDirectory: true) - } + private lazy var destinationURL = { + return FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first?.appendingPathComponent("Subler", isDirectory: true).appendingPathComponent("tessdata", isDirectory: true).appendingPathComponent("v4", isDirectory: true) + }() - private func baseURL() -> URL? { - return URL(string: "https://github.com/tesseract-ocr/tessdata_fast/raw/master/") - } + private lazy var baseURL = { + return URL(string: "https://github.com/tesseract-ocr/tessdata/raw/master/") + }() func download(item: OCRLanguage) { - if let baseURL = baseURL(), let destURL = destinationURL() { + if let baseURL = baseURL, let destURL = destinationURL { _ = item.startDownload(from: baseURL, to: destURL, completionHandler: { _ in self.postNotification() }) postNotification() } @@ -249,7 +249,7 @@ final class OCRManager { } func removeDownload(item: OCRLanguage) throws { - if let destURL = destinationURL() { + if let destURL = destinationURL { try item.remove(destURL) postNotification() } @@ -258,7 +258,8 @@ final class OCRManager { // MARK: read/write private func load() throws { - if let destinationURL = destinationURL() { + if let destinationURL = destinationURL { + try FileManager.default.createDirectory(at: destinationURL, withIntermediateDirectories: true, attributes: [:]) languages.forEach { $0.checkIfDownloaded(destinationURL) } } } diff --git a/MP42Foundation b/MP42Foundation index 1a90880..4d5fdd8 160000 --- a/MP42Foundation +++ b/MP42Foundation @@ -1 +1 @@ -Subproject commit 1a908808976c386f244e520a8a6f22127b98976f +Subproject commit 4d5fdd893f082903477cb23a7c795a25e2120720 diff --git a/Subler.xcodeproj/project.pbxproj b/Subler.xcodeproj/project.pbxproj index afc3548..7f13df7 100644 --- a/Subler.xcodeproj/project.pbxproj +++ b/Subler.xcodeproj/project.pbxproj @@ -289,7 +289,6 @@ A97D99D922A0240C001FA3A7 /* OCRManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = OCRManager.swift; path = Classes/OCRManager.swift; sourceTree = ""; }; A97FBE3B21FC7F1C00F1FD35 /* QueueController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = QueueController.swift; path = Classes/QueueController.swift; sourceTree = ""; }; A983E80A22365B5400221BAE /* MovieViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MovieViewController.swift; path = Classes/PropertyView/MovieViewController.swift; sourceTree = ""; }; - A984DB4A0F52D644001A20B2 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Sparkle.framework; sourceTree = ""; }; A984DB730F52DD4B001A20B2 /* dsa_pub.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = dsa_pub.pem; sourceTree = ""; }; A98542D620D197D300EB9803 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/ArtworkSelector.xib; sourceTree = ""; }; A98542D820D197DF00EB9803 /* ArtworkSelector.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ArtworkSelector.swift; path = Classes/ArtworkSelector.swift; sourceTree = ""; }; @@ -404,7 +403,6 @@ children = ( A9ED7B21180067A2008FD3A8 /* IOKit.framework */, 2A37F4C5FDCFA73011CA2CEA /* Foundation.framework */, - A984DB4A0F52D644001A20B2 /* Sparkle.framework */, 1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */, ); name = "Linked Frameworks";