Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSDictionary *deserializeSaurikDepiction(NSString *ID) {
- NSString *depiction = [NSString stringWithFormat:@"http://cydia.saurik.com/info/%@/", ID]; /* trailing slash important /-!-\ */
- NSData *depictionData = makeURLRequest(depiction);
- NSError *error;
- HTMLParser *parser = [[HTMLParser alloc] initWithData:depictionData error:&error];
- if (error) {
- NSLog(@"Error: %@", [error localizedDescription]);
- return nil;
- }
- HTMLNode *head = [parser head];
- HTMLNode *body = [parser body];
- NSString *name = @"", *new = @"", *description = @"", *lastUpdated = @"";
- NSMutableArray *screenshots = [NSMutableArray array];
- name = [[[[head findChildTag:@"title"] allContents] componentsSeparatedByString:@" ยท "] objectAtIndex:0];
- HTMLNode *panel = [body findChildTag:@"panel"];
- description = [[[NSAttributedString alloc] initWithData:[[[[panel findChildTag:@"block"] findChildTag:@"p"] allContents] dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: [NSNumber numberWithInt:NSUTF8StringEncoding]} documentAttributes:nil error:nil] string];
- for (HTMLNode *img in [panel findChildTags:@"img"]) {
- if (![[img getAttributeNamed:@"class"] isEqualToString:@"icon"]) {
- [screenshots addObject:[img getAttributeNamed:@"src"]];
- }
- }
- //----------------------------//
- NSData *changelog = makeURLRequest([depiction stringByAppendingString:@"changelog.html"]);
- //[parser release];
- parser = [[HTMLParser alloc] initWithData:changelog error:&error];
- if (error) {
- NSLog(@"Error: %@", [error localizedDescription]);
- }
- body = [parser body];
- panel = [body findChildTag:@"panel"];
- lastUpdated = [[[[[panel findChildTag:@"label"] findChildTag:@"p"] allContents] componentsSeparatedByString:@": "] objectAtIndex:1];
- new = [[[NSAttributedString alloc] initWithData:[[panel rawContents] dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: [NSNumber numberWithInt:NSUTF8StringEncoding]} documentAttributes:nil error:&error] string];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:name forKey:@"name"];
- [dict setObject:description forKey:@"description"];
- [dict setObject:lastUpdated forKey:@"lastUpdated"];
- [dict setObject:new forKey:@"whatsnew"];
- [dict setObject:screenshots forKey:@"screenshots"];
- //[parser release];
- return dict;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement