From 658a424e84c5a18c7945d1055c423f680f9254ab Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Wed, 25 Nov 2015 16:52:19 +0100 Subject: [PATCH] Use the public TimeFromString function in SBChapterDB --- Classes/MetadataImporters/SBChapterDB.m | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Classes/MetadataImporters/SBChapterDB.m b/Classes/MetadataImporters/SBChapterDB.m index 5137c5f..93fd7bf 100644 --- a/Classes/MetadataImporters/SBChapterDB.m +++ b/Classes/MetadataImporters/SBChapterDB.m @@ -9,7 +9,8 @@ #import "SBChapterDB.h" #import "SBChapterResult.h" -#import +#import +#import #define API_KEY @"ETET7TXFJH45YNYW0I4A" @@ -24,7 +25,7 @@ NSXMLDocument *xml = [[NSXMLDocument alloc] initWithData:xmlData options:0 - error:nil]; + error:NULL]; NSMutableArray *resultsArray = [[[NSMutableArray alloc] init] autorelease]; @@ -47,7 +48,7 @@ return filteredArray; } } - + return resultsArray; } @@ -92,7 +93,7 @@ NSArray *tag = [node nodesForXPath:@"./*:source/*:duration" error:NULL]; NSString *durationString = tag.firstObject.stringValue; if (durationString) { - return ParseSubTime(durationString.UTF8String, 1000, NO); + return (NSUInteger)TimeFromString(durationString, 1000); } return 0; } @@ -108,6 +109,8 @@ NSArray *times = [child nodesForXPath:@"./*:chapters/*:chapter/@time" error:NULL]; NSArray *names = [child nodesForXPath:@"./*:chapters/*:chapter/@name" error:NULL]; + MP42Duration currentTime = 0; + if (times && names) { for (NSInteger i = 0; i < times.count && i < names.count; i++) { @@ -116,7 +119,14 @@ NSString *timestamp = times[i].stringValue; if (name && timestamp) { - unsigned time = ParseSubTime(timestamp.UTF8String, 1000, NO); + MP42Duration time = TimeFromString(timestamp, 1000); + + if (time < currentTime) { + break; + } + else { + currentTime = time; + } MP42TextSample *chapter = [[MP42TextSample alloc] init]; chapter.title = name;