[Play Counts] Fix counts for tracks with subsongs
Fix counts for tracks with subsongs from piling all the counts onto the first subsong seen, by using the URL fragment in the filename check and storage. Signed-off-by: Christopher Snowhill <kode54@gmail.com>swiftingly
parent
39be3ab962
commit
a57827f4da
|
@ -262,7 +262,7 @@ static void *playlistControllerContext = &playlistControllerContext;
|
|||
pc.album = pe.album;
|
||||
pc.artist = pe.artist;
|
||||
pc.title = pe.title;
|
||||
pc.filename = pe.filename;
|
||||
pc.filename = pe.filenameFragment;
|
||||
}
|
||||
|
||||
[self commitEditing];
|
||||
|
@ -278,7 +278,7 @@ static void *playlistControllerContext = &playlistControllerContext;
|
|||
pc.album = pe.album;
|
||||
pc.artist = pe.artist;
|
||||
pc.title = pe.title;
|
||||
pc.filename = pe.filename;
|
||||
pc.filename = pe.filenameFragment;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
+ (NSSet *_Nonnull)keyPathsForValuesAffectingLength;
|
||||
+ (NSSet *_Nonnull)keyPathsForValuesAffectingPath;
|
||||
+ (NSSet *_Nonnull)keyPathsForValuesAffectingFilename;
|
||||
+ (NSSet *_Nonnull)keyPathsForValuesAffectingFilenameFragment;
|
||||
+ (NSSet *_Nonnull)keyPathsForValuesAffectingStatus;
|
||||
+ (NSSet *_Nonnull)keyPathsForValuesAffectingStatusMessage;
|
||||
+ (NSSet *_Nonnull)keyPathsForValuesAffectingSpam;
|
||||
|
@ -33,6 +34,7 @@
|
|||
@property(nonatomic, retain, readonly) NSNumber *_Nonnull length;
|
||||
@property(nonatomic, readonly) NSString *_Nonnull path;
|
||||
@property(nonatomic, readonly) NSString *_Nonnull filename;
|
||||
@property(nonatomic, readonly) NSString *_Nonnull filenameFragment;
|
||||
|
||||
@property(nonatomic, readonly) NSString *_Nonnull spam;
|
||||
@property(nonatomic, readonly) NSString *_Nonnull indexedSpam;
|
||||
|
|
|
@ -51,6 +51,10 @@ extern NSMutableDictionary<NSString *, AlbumArtwork *> *kArtworkDictionary;
|
|||
return [NSSet setWithObject:@"url"];
|
||||
}
|
||||
|
||||
+ (NSSet *)keyPathsForValuesAffectingFilenameFragment {
|
||||
return [NSSet setWithObject:@"url"];
|
||||
}
|
||||
|
||||
+ (NSSet *)keyPathsForValuesAffectingStatus {
|
||||
return [NSSet setWithObjects:@"current", @"queued", @"error", @"stopAfter", nil];
|
||||
}
|
||||
|
@ -431,6 +435,15 @@ NSURL *_Nullable urlForPath(NSString *_Nullable path) {
|
|||
return [[self.url path] lastPathComponent];
|
||||
}
|
||||
|
||||
@dynamic filenameFragment;
|
||||
- (NSString *)filenameFragment {
|
||||
if([self.url fragment]) {
|
||||
return [[[self.url path] lastPathComponent] stringByAppendingFormat:@"#%@", [self.url fragment]];
|
||||
} else {
|
||||
return self.filename;
|
||||
}
|
||||
}
|
||||
|
||||
@dynamic status;
|
||||
- (NSString *)status {
|
||||
if(self.stopAfter) {
|
||||
|
@ -508,7 +521,7 @@ NSURL *_Nullable urlForPath(NSString *_Nullable path) {
|
|||
NSArray *results = [kPersistentContainer.viewContext executeFetchRequest:request error:&error];
|
||||
|
||||
if(!results || [results count] < 1) {
|
||||
NSPredicate *filenamePredicate = [NSPredicate predicateWithFormat:@"filename == %@", self.filename];
|
||||
NSPredicate *filenamePredicate = [NSPredicate predicateWithFormat:@"filename == %@", self.filenameFragment];
|
||||
|
||||
request = [NSFetchRequest fetchRequestWithEntityName:@"PlayCount"];
|
||||
request.predicate = filenamePredicate;
|
||||
|
|
Loading…
Reference in New Issue