diff --git a/source/AirlineLogoScraper.xcodeproj/project.pbxproj b/source/AirlineLogoScraper.xcodeproj/project.pbxproj new file mode 100644 index 0000000..eb031bd --- /dev/null +++ b/source/AirlineLogoScraper.xcodeproj/project.pbxproj @@ -0,0 +1,278 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 48; + objects = { + +/* Begin PBXBuildFile section */ + 2E7EA60C1F84684500B0D340 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E7EA60B1F84684500B0D340 /* main.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 2E7EA6061F84684500B0D340 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 2E7EA6081F84684500B0D340 /* AirlineLogoScraper */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = AirlineLogoScraper; sourceTree = BUILT_PRODUCTS_DIR; }; + 2E7EA60B1F84684500B0D340 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 2E7EA6051F84684500B0D340 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 2E7EA5FF1F84684500B0D340 = { + isa = PBXGroup; + children = ( + 2E7EA60A1F84684500B0D340 /* AirlineLogoScraper */, + 2E7EA6091F84684500B0D340 /* Products */, + ); + sourceTree = ""; + }; + 2E7EA6091F84684500B0D340 /* Products */ = { + isa = PBXGroup; + children = ( + 2E7EA6081F84684500B0D340 /* AirlineLogoScraper */, + ); + name = Products; + sourceTree = ""; + }; + 2E7EA60A1F84684500B0D340 /* AirlineLogoScraper */ = { + isa = PBXGroup; + children = ( + 2E7EA60B1F84684500B0D340 /* main.swift */, + ); + path = AirlineLogoScraper; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 2E7EA6071F84684500B0D340 /* AirlineLogoScraper */ = { + isa = PBXNativeTarget; + buildConfigurationList = 2E7EA60F1F84684500B0D340 /* Build configuration list for PBXNativeTarget "AirlineLogoScraper" */; + buildPhases = ( + 2E7EA6041F84684500B0D340 /* Sources */, + 2E7EA6051F84684500B0D340 /* Frameworks */, + 2E7EA6061F84684500B0D340 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = AirlineLogoScraper; + productName = AirlineLogoScraper; + productReference = 2E7EA6081F84684500B0D340 /* AirlineLogoScraper */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 2E7EA6001F84684500B0D340 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0900; + LastUpgradeCheck = 0900; + ORGANIZATIONNAME = "iOS Club"; + TargetAttributes = { + 2E7EA6071F84684500B0D340 = { + CreatedOnToolsVersion = 9.0; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 2E7EA6031F84684500B0D340 /* Build configuration list for PBXProject "AirlineLogoScraper" */; + compatibilityVersion = "Xcode 8.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 2E7EA5FF1F84684500B0D340; + productRefGroup = 2E7EA6091F84684500B0D340 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 2E7EA6071F84684500B0D340 /* AirlineLogoScraper */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 2E7EA6041F84684500B0D340 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2E7EA60C1F84684500B0D340 /* main.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 2E7EA60D1F84684500B0D340 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.12; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 2E7EA60E1F84684500B0D340 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.12; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + }; + name = Release; + }; + 2E7EA6101F84684500B0D340 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; + }; + name = Debug; + }; + 2E7EA6111F84684500B0D340 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 2E7EA6031F84684500B0D340 /* Build configuration list for PBXProject "AirlineLogoScraper" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2E7EA60D1F84684500B0D340 /* Debug */, + 2E7EA60E1F84684500B0D340 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2E7EA60F1F84684500B0D340 /* Build configuration list for PBXNativeTarget "AirlineLogoScraper" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2E7EA6101F84684500B0D340 /* Debug */, + 2E7EA6111F84684500B0D340 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 2E7EA6001F84684500B0D340 /* Project object */; +} diff --git a/source/AirlineLogoScraper.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/source/AirlineLogoScraper.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..ee88903 --- /dev/null +++ b/source/AirlineLogoScraper.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/source/AirlineLogoScraper.xcodeproj/project.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate b/source/AirlineLogoScraper.xcodeproj/project.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..a818ceb Binary files /dev/null and b/source/AirlineLogoScraper.xcodeproj/project.xcworkspace/xcuserdata/cal.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/source/AirlineLogoScraper.xcodeproj/xcuserdata/cal.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/source/AirlineLogoScraper.xcodeproj/xcuserdata/cal.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..fe2b454 --- /dev/null +++ b/source/AirlineLogoScraper.xcodeproj/xcuserdata/cal.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,5 @@ + + + diff --git a/source/AirlineLogoScraper.xcodeproj/xcuserdata/cal.xcuserdatad/xcschemes/xcschememanagement.plist b/source/AirlineLogoScraper.xcodeproj/xcuserdata/cal.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..14b96d5 --- /dev/null +++ b/source/AirlineLogoScraper.xcodeproj/xcuserdata/cal.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + AirlineLogoScraper.xcscheme + + orderHint + 0 + + + + diff --git a/source/AirlineLogoScraper/main.swift b/source/AirlineLogoScraper/main.swift new file mode 100644 index 0000000..e75d06f --- /dev/null +++ b/source/AirlineLogoScraper/main.swift @@ -0,0 +1,60 @@ +// +// main.swift +// AirlineLogoScraper +// +// Created by Cal Stephens on 10/3/17. +// Copyright © 2017 iOS Club. All rights reserved. +// + +import Foundation +import AppKit + +let documents = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first! +let airlineLogosFolder = URL(fileURLWithPath: documents.appending("/Airline Logos")) +try! FileManager.default.createDirectory(at: airlineLogosFolder, withIntermediateDirectories: true, attributes: nil) + +let letters = ["A", "B", "C", "D", "E", + "F", "G", "H", "I", "J", "K", "L", + "M", "N", "O", "P", "Q", "R", "S", + "T", "U", "V", "W", "X", "Y", "Z"] + +let numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + +let characters = letters + numbers + +func downloadLogo(_ icaoCode: String) { + let semaphore = DispatchSemaphore(value: 0) + + let logoFetchUrl = URL(string: "https://flightaware.com/images/airline_logos/90p/\(icaoCode).png")! + let logoFileUrl = airlineLogosFolder.appendingPathComponent("/\(icaoCode).png") + + URLSession.shared.dataTask(with: logoFetchUrl, completionHandler: { (data, _, _) -> Void in + defer { + semaphore.signal() + } + + guard let data = data, + NSImage(data: data) != nil else + { + print("nothing for \(icaoCode)") + return + } + + print("downloaded \(icaoCode)") + try? data.write(to: logoFileUrl, options: []) + }).resume() + + semaphore.wait() +} + +for firstLetter in characters { + downloadLogo("\(firstLetter)") + for secondLetter in characters { + downloadLogo("\(firstLetter)\(secondLetter)") + for thirdLetter in characters { + downloadLogo("\(firstLetter)\(secondLetter)\(thirdLetter)") + } + } +} + +