Last active
December 3, 2015 22:51
-
-
Save steventroughtonsmith/c24bb6b6a28c5b583008 to your computer and use it in GitHub Desktop.
WWDC 15 Session Video Lister
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.m | |
// wwcd15sessionlister | |
// | |
// Created by Steven Troughton-Smith on 10/06/2015. | |
// | |
#import <Foundation/Foundation.h> | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://devimages.apple.com.edgekey.net/wwdc-services/ftzj8e4h/6rsxhod7fvdtnjnmgsun/videos.json"]]; | |
NSData * d = [NSURLConnection sendSynchronousRequest:req returningResponse:nil error:nil]; | |
NSDictionary *wwdc = (NSDictionary *)[NSJSONSerialization JSONObjectWithData:d options:0 error:nil]; | |
NSArray *sessions = [wwdc valueForKeyPath:@"sessions"]; | |
sessions = [sessions sortedArrayWithOptions:0 usingComparator:^NSComparisonResult(NSDictionary *session1, NSDictionary *session2) { | |
if ([session1[@"id"] intValue] > [session2[@"id"] intValue]) | |
{ | |
return NSOrderedDescending; | |
} | |
return NSOrderedAscending; | |
}]; | |
for (NSDictionary *session in sessions) | |
{ | |
if ([[session[@"year"] stringValue] isEqualToString:@"2015"]) | |
{ | |
NSString *filename = [session[@"download_hd"] lastPathComponent]; | |
printf("%s - %s\n%s\n\n", [[session[@"id"] stringValue] UTF8String], [session[@"title"] UTF8String], [session[@"download_hd"] UTF8String] ); | |
} | |
} | |
} | |
return 0; | |
} |
Gross mini version in Swift 1.2
import Foundation
let data = NSData(contentsOfURL: NSURL(string:"https://devimages.apple.com.edgekey.net/wwdc-services/ftzj8e4h/6rsxhod7fvdtnjnmgsun/videos.json")!)!
let wwdc: AnyObject? = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.AllowFragments, error: nil)
print(wwdc!.valueForKeyPath("[email protected]_hd"))
I made a pyramidal swift version, but github didn't seem to like the abundance of emojis 😦
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
…and a gross mini version