Skip to content

Commit

Permalink
Add source for AirlineLogoScraper
Browse files Browse the repository at this point in the history
  • Loading branch information
calda committed Oct 4, 2017
1 parent 86143a6 commit 9ff8e31
Show file tree
Hide file tree
Showing 6 changed files with 364 additions and 0 deletions.
278 changes: 278 additions & 0 deletions source/AirlineLogoScraper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -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 = "<group>"; };
/* 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 = "<group>";
};
2E7EA6091F84684500B0D340 /* Products */ = {
isa = PBXGroup;
children = (
2E7EA6081F84684500B0D340 /* AirlineLogoScraper */,
);
name = Products;
sourceTree = "<group>";
};
2E7EA60A1F84684500B0D340 /* AirlineLogoScraper */ = {
isa = PBXGroup;
children = (
2E7EA60B1F84684500B0D340 /* main.swift */,
);
path = AirlineLogoScraper;
sourceTree = "<group>";
};
/* 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 */;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>AirlineLogoScraper.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
60 changes: 60 additions & 0 deletions source/AirlineLogoScraper/main.swift
Original file line number Diff line number Diff line change
@@ -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)")
}
}
}


0 comments on commit 9ff8e31

Please sign in to comment.