Added metadata reading to cue sheets.
parent
97e662208d
commit
b51d8aedb5
|
@ -55,7 +55,6 @@
|
|||
NSLog(@"Couldn't open source...");
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
[converterNode setOutputFormat:outputFormat];
|
||||
|
||||
|
|
|
@ -51,6 +51,12 @@
|
|||
|
||||
NSString *track = nil;
|
||||
NSString *path = nil;
|
||||
NSString *artist = nil;
|
||||
NSString *album = nil;
|
||||
NSString *title = nil;
|
||||
NSString *genre = nil;
|
||||
NSString *year = nil;
|
||||
|
||||
BOOL trackAdded = NO;
|
||||
|
||||
NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet];
|
||||
|
@ -73,7 +79,7 @@
|
|||
track = nil;
|
||||
trackAdded = NO;
|
||||
|
||||
if (![scanner scanString:@"\"" intoString:&command]) {
|
||||
if (![scanner scanString:@"\"" intoString:nil]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -112,8 +118,6 @@
|
|||
continue;
|
||||
}
|
||||
|
||||
NSLog(@"Index: %@", index);
|
||||
|
||||
[scanner scanCharactersFromSet:whitespace intoString:nil];
|
||||
|
||||
NSString *time = nil;
|
||||
|
@ -136,9 +140,67 @@
|
|||
[entries addObject:
|
||||
[CueSheetTrack trackWithURL:[self urlForPath:path relativeTo:filename]
|
||||
track: track
|
||||
time: seconds]];
|
||||
time: seconds
|
||||
artist:artist
|
||||
album:album
|
||||
title:title
|
||||
genre:genre
|
||||
year:year]];
|
||||
trackAdded = YES;
|
||||
}
|
||||
else if ([command isEqualToString:@"PERFORMER"])
|
||||
{
|
||||
if (![scanner scanString:@"\"" intoString:nil]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//Read in the path
|
||||
if (![scanner scanUpToString:@"\"" intoString:&artist]) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if ([command isEqualToString:@"TITLE"])
|
||||
{
|
||||
NSString **titleDest;
|
||||
if (!path) //Have not come across a file yet.
|
||||
titleDest = &album;
|
||||
else
|
||||
titleDest = &title;
|
||||
|
||||
if (![scanner scanString:@"\"" intoString:nil]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//Read in the path
|
||||
if (![scanner scanUpToString:@"\"" intoString:titleDest]) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if ([command isEqualToString:@"REM"]) //Additional metadata sometimes stored in comments
|
||||
{
|
||||
NSString *type;
|
||||
NSString **dest = NULL;
|
||||
|
||||
if (![scanner scanUpToCharactersFromSet:whitespace intoString:&type]) {
|
||||
continue;
|
||||
}
|
||||
if ([type isEqualToString:@"GENRE"])
|
||||
{
|
||||
dest = &genre;
|
||||
}
|
||||
else if ([type isEqualToString:@"DATE"])
|
||||
{
|
||||
dest = &year;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ![scanner scanUpToCharactersFromSet:whitespace intoString:dest]) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[scanner release];
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
17DA346E0CC04FCD0003F6B2 /* CueSheetMetadataReader.m in Sources */ = {isa = PBXBuildFile; fileRef = 17DA346D0CC04FCD0003F6B2 /* CueSheetMetadataReader.m */; };
|
||||
17F3BB680CBC560700864489 /* CueSheetPropertiesReader.m in Sources */ = {isa = PBXBuildFile; fileRef = 17F3BB670CBC560700864489 /* CueSheetPropertiesReader.m */; };
|
||||
8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; };
|
||||
8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; };
|
||||
|
@ -22,6 +23,8 @@
|
|||
089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
|
||||
1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
|
||||
17DA346C0CC04FCD0003F6B2 /* CueSheetMetadataReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CueSheetMetadataReader.h; sourceTree = "<group>"; };
|
||||
17DA346D0CC04FCD0003F6B2 /* CueSheetMetadataReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CueSheetMetadataReader.m; sourceTree = "<group>"; };
|
||||
17F3BB660CBC560700864489 /* CueSheetPropertiesReader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CueSheetPropertiesReader.h; sourceTree = "<group>"; };
|
||||
17F3BB670CBC560700864489 /* CueSheetPropertiesReader.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = CueSheetPropertiesReader.m; sourceTree = "<group>"; };
|
||||
32DBCF630370AF2F00C91783 /* CueSheet_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CueSheet_Prefix.pch; sourceTree = "<group>"; };
|
||||
|
@ -99,6 +102,8 @@
|
|||
8E8D424C0CBB11C600135C1B /* CueSheet.m */,
|
||||
8E8D43550CBB1AE900135C1B /* CueSheetTrack.h */,
|
||||
8E8D43560CBB1AE900135C1B /* CueSheetTrack.m */,
|
||||
17DA346C0CC04FCD0003F6B2 /* CueSheetMetadataReader.h */,
|
||||
17DA346D0CC04FCD0003F6B2 /* CueSheetMetadataReader.m */,
|
||||
);
|
||||
name = Classes;
|
||||
sourceTree = "<group>";
|
||||
|
@ -195,6 +200,7 @@
|
|||
8E8D424D0CBB11C600135C1B /* CueSheet.m in Sources */,
|
||||
8E8D43570CBB1AE900135C1B /* CueSheetTrack.m in Sources */,
|
||||
17F3BB680CBC560700864489 /* CueSheetPropertiesReader.m in Sources */,
|
||||
17DA346E0CC04FCD0003F6B2 /* CueSheetMetadataReader.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#import "CueSheetContainer.h"
|
||||
#import "CueSheetDecoder.h"
|
||||
#import "CueSheetPropertiesReader.h"
|
||||
#import "CueSheetMetadataReader.h"
|
||||
|
||||
@implementation CueSheetPlugin
|
||||
|
||||
|
@ -20,6 +21,7 @@
|
|||
kCogContainer, [CueSheetContainer className],
|
||||
kCogDecoder, [CueSheetDecoder className],
|
||||
kCogPropertiesReader, [CueSheetPropertiesReader className],
|
||||
kCogMetadataReader, [CueSheetMetadataReader className],
|
||||
nil];
|
||||
}
|
||||
|
||||
|
|
|
@ -12,16 +12,27 @@
|
|||
@interface CueSheetTrack : NSObject {
|
||||
NSString *track;
|
||||
NSURL *url;
|
||||
|
||||
NSString *artist;
|
||||
NSString *album;
|
||||
NSString *title;
|
||||
NSString *genre;
|
||||
NSString *year;
|
||||
|
||||
double time;
|
||||
}
|
||||
|
||||
+ (id)trackWithURL:(NSURL *)u track:(NSString *)t time:(double)t;
|
||||
- (id)initWithURL:(NSURL *)u track:(NSString *)t time:(double)t;
|
||||
+ (id)trackWithURL:(NSURL *)u track:(NSString *)t time:(double)s artist:(NSString *)a album:(NSString *)b title:(NSString *)l genre:(NSString *)g year:(NSString *)y;
|
||||
- (id)initWithURL:(NSURL *)u track:(NSString *)t time:(double)s artist:(NSString *)a album:(NSString *)b title:(NSString *)l genre:(NSString *)g year:(NSString *)y;
|
||||
|
||||
|
||||
- (NSString *)track;
|
||||
- (NSURL *)url;
|
||||
- (NSString *)artist;
|
||||
- (NSString *)album;
|
||||
- (NSString *)title;
|
||||
- (NSString *)genre;
|
||||
- (NSString *)year;
|
||||
|
||||
- (double)time;
|
||||
|
||||
|
|
|
@ -11,18 +11,24 @@
|
|||
|
||||
@implementation CueSheetTrack
|
||||
|
||||
+ (id)trackWithURL:(NSURL *)u track:(NSString *)t time:(double)s
|
||||
+ (id)trackWithURL:(NSURL *)u track:(NSString *)t time:(double)s artist:(NSString *)a album:(NSString *)b title:(NSString *)l genre:(NSString *)g year:(NSString *)y
|
||||
{
|
||||
return [[[CueSheetTrack alloc] initWithURL:u track:t time:s] autorelease];
|
||||
return [[[CueSheetTrack alloc] initWithURL:u track:t time:s artist:a album:b title:l genre:g year:y] autorelease];
|
||||
}
|
||||
|
||||
- (id)initWithURL:(NSURL *)u track:(NSString *)t time:(double)s
|
||||
- (id)initWithURL:(NSURL *)u track:(NSString *)t time:(double)s artist:(NSString *)a album:(NSString *)b title:(NSString *)l genre:(NSString *)g year:(NSString *)y
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
track = [t copy];
|
||||
url = [u copy];
|
||||
artist = [a copy];
|
||||
album = [b copy];
|
||||
title = [l copy];
|
||||
genre = [g copy];
|
||||
year = [y copy];
|
||||
|
||||
time = s;
|
||||
}
|
||||
|
||||
|
@ -44,4 +50,30 @@
|
|||
return time;
|
||||
}
|
||||
|
||||
- (NSString *)artist
|
||||
{
|
||||
return artist;
|
||||
}
|
||||
|
||||
- (NSString *)album
|
||||
{
|
||||
return album;
|
||||
}
|
||||
|
||||
- (NSString *)title
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
- (NSString *)genre
|
||||
{
|
||||
return genre;
|
||||
}
|
||||
|
||||
- (NSString *)year
|
||||
{
|
||||
return year;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue