//
// © 2018-2020 Qualcomm Technologies, Inc. and/or its subsidiaries. All rights reserved.
//

#import "LocalMusicLibraryCacheItemHelper.h"

@implementation LocalMusicLibraryCacheItemHelper

+ (NSDictionary<NSString *, id> *)propertiesForMediaItem:(MPMediaItem *)mediaItem
{
	NSSet<NSString *> *requiredProperties = [[NSSet alloc] initWithObjects:MPMediaItemPropertyPersistentID,
											 MPMediaItemPropertyTitle,
											 MPMediaItemPropertyArtist,
											 MPMediaItemPropertyArtistPersistentID,
											 MPMediaItemPropertyAlbumTitle,
											 MPMediaItemPropertyAlbumPersistentID,
											 MPMediaItemPropertyAlbumTrackNumber,
											 MPMediaItemPropertyGenre,
											 MPMediaItemPropertyGenrePersistentID,
											 MPMediaItemPropertyPlaybackDuration,
											 MPMediaItemPropertyHasProtectedAsset, nil];

	NSMutableDictionary<NSString *, id> *props = [[NSMutableDictionary alloc] init];
	[mediaItem enumerateValuesForProperties:requiredProperties
								 usingBlock:^(NSString * _Nonnull property, id  _Nonnull value, BOOL * _Nonnull stop) {
									 if (property && value) {
										 props[property] = value;
									 }
								 }];
	return props;

}

@end
