Commit 5d00ca40 authored by Felix Paul Kühne's avatar Felix Paul Kühne
Browse files

thumbnail cache: remove very bad had hack to handle album art as this is...

thumbnail cache: remove very bad had hack to handle album art as this is correctly done by MLKit now
parent 843f92b0
......@@ -769,7 +769,7 @@
_albumName = metaDict[VLCMetaInformationAlbum];
trackNumber = [metaDict[VLCMetaInformationTrackNumber] numberValue];
if (_mediaIsAudioOnly)
_artworkImage = [VLCThumbnailsCache thumbnailForMediaItemWithTitle:_title Artist:_artist andAlbumName:_albumName];
_artworkImage = [VLCThumbnailsCache thumbnailForManagedObject:item];
}
}
......
......@@ -16,8 +16,6 @@
+ (UIImage *)thumbnailForManagedObject:(NSManagedObject *)object;
+ (UIImage *)thumbnailForMediaItemWithTitle:(NSString *)title Artist:(NSString*)artist andAlbumName:(NSString*)albumname;
+ (UIImage *)thumbnailForManagedObject:(NSManagedObject *)object toFitRect:(CGRect)rect shouldReplaceCache:(BOOL)replaceCache;
@end
......@@ -72,54 +72,6 @@
return sharedThumbnailCache;
}
- (NSString *)_md5FromString:(NSString *)string
{
const char *ptr = [string UTF8String];
unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH];
CC_MD5(ptr, (unsigned int)strlen(ptr), md5Buffer);
NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++)
[output appendFormat:@"%02x",md5Buffer[i]];
return [NSString stringWithString:output];
}
+ (UIImage *)thumbnailForMediaItemWithTitle:(NSString *)title Artist:(NSString*)artist andAlbumName:(NSString*)albumname
{
return [UIImage imageWithContentsOfFile:[[VLCThumbnailsCache sharedThumbnailCache] artworkPathForMediaItemWithTitle:title Artist:artist andAlbumName:albumname]];
}
- (NSString *)artworkPathForMediaItemWithTitle:(NSString *)title Artist:(NSString*)artist andAlbumName:(NSString*)albumname
{
NSString *artworkURL;
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cacheDir = searchPaths[0];
cacheDir = [cacheDir stringByAppendingFormat:@"/%@", [[NSBundle mainBundle] bundleIdentifier]];
if (artist.length == 0 || albumname.length == 0) {
/* Use generated hash to find art */
artworkURL = [cacheDir stringByAppendingFormat:@"/art/arturl/%@/art.jpg", [self _md5FromString:title]];
} else {
/* Otherwise, it was cached by artist and album */
artworkURL = [cacheDir stringByAppendingFormat:@"/art/artistalbum/%@/%@/art.jpg", artist, albumname];
}
return artworkURL;
}
- (NSString *)_getArtworkPathFromMedia:(MLFile *)file
{
NSString *artist, *album, *title;
if (file.isAlbumTrack) {
artist = file.albumTrack.artist;
album = file.albumTrack.album.name;
}
title = file.title;
return [self artworkPathForMediaItemWithTitle:title Artist:artist andAlbumName:album];
}
+ (UIImage *)thumbnailForManagedObject:(NSManagedObject *)object
{
UIImage *thumbnail;
......@@ -177,9 +129,6 @@
if (displayedImage)
return displayedImage;
if (mediaFile.isAlbumTrack || mediaFile.isShowEpisode)
displayedImage = [UIImage imageWithContentsOfFile:[self _getArtworkPathFromMedia:mediaFile]];
if (!displayedImage)
displayedImage = mediaFile.computedThumbnail;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment