Commit 191e7405 authored by Felix Paul Kühne's avatar Felix Paul Kühne

de-duplicate time to string code

parent 19b63342
...@@ -174,7 +174,7 @@ ...@@ -174,7 +174,7 @@
for (NSManagedObject *mo in allMedia) { for (NSManagedObject *mo in allMedia) {
if ([mo isKindOfClass:[MLFile class]]) { if ([mo isKindOfClass:[MLFile class]]) {
duration = [self timeFormatted:[[(MLFile *)mo duration] integerValue]]; duration = [[VLCTime timeWithNumber:[(MLFile *)mo duration]] stringValue];
[mediaInHtml addObject:[NSString stringWithFormat: [mediaInHtml addObject:[NSString stringWithFormat:
@"<div style=\"background-image:url('thumbnail/%@.png')\"> \ @"<div style=\"background-image:url('thumbnail/%@.png')\"> \
<a href=\"download/%@\" class=\"inner\"> \ <a href=\"download/%@\" class=\"inner\"> \
...@@ -206,7 +206,7 @@ ...@@ -206,7 +206,7 @@
[(MLShow *)mo name], [(MLShow *)mo name],
[episodes count]]]; [episodes count]]];
for (MLShowEpisode *showEp in episodes) { for (MLShowEpisode *showEp in episodes) {
duration = [self timeFormatted:[[(MLFile *)[[showEp files] anyObject] duration] integerValue]]; duration = [[VLCTime timeWithNumber:[(MLFile *)[[showEp files] anyObject] duration]] stringValue];
[mediaInHtml addObject:[NSString stringWithFormat: [mediaInHtml addObject:[NSString stringWithFormat:
@"<div style=\"background-image:url('thumbnail/%@.png')\"> \ @"<div style=\"background-image:url('thumbnail/%@.png')\"> \
<a href=\"download/%@\" class=\"inner\"> \ <a href=\"download/%@\" class=\"inner\"> \
...@@ -241,7 +241,7 @@ ...@@ -241,7 +241,7 @@
[(MLLabel *)mo name], [(MLLabel *)mo name],
[folderItems count]]]; [folderItems count]]];
for (MLFile *file in folderItems) { for (MLFile *file in folderItems) {
duration = [self timeFormatted:[[file duration] integerValue]]; duration = [[VLCTime timeWithNumber:[file duration]] stringValue];
[mediaInHtml addObject:[NSString stringWithFormat: [mediaInHtml addObject:[NSString stringWithFormat:
@"<div style=\"background-image:url('thumbnail/%@.png')\"> \ @"<div style=\"background-image:url('thumbnail/%@.png')\"> \
<a href=\"download/%@\" class=\"inner\"> \ <a href=\"download/%@\" class=\"inner\"> \
...@@ -274,7 +274,7 @@ ...@@ -274,7 +274,7 @@
[(MLAlbum *)mo name], [(MLAlbum *)mo name],
[albumTracks count]]]; [albumTracks count]]];
for (MLAlbumTrack *track in albumTracks) { for (MLAlbumTrack *track in albumTracks) {
duration = [self timeFormatted:[[(MLFile *)[[track files] anyObject] duration] integerValue]]; duration = [[VLCTime timeWithNumber:[(MLFile *)[[track files] anyObject] duration]] stringValue];
[mediaInHtml addObject:[NSString stringWithFormat: [mediaInHtml addObject:[NSString stringWithFormat:
@"<div style=\"background-image:url('thumbnail/%@.png')\"> \ @"<div style=\"background-image:url('thumbnail/%@.png')\"> \
<a href=\"download/%@\" class=\"inner\"> \ <a href=\"download/%@\" class=\"inner\"> \
...@@ -416,13 +416,4 @@ ...@@ -416,13 +416,4 @@
return [super shouldDie]; return [super shouldDie];
} }
- (NSString *)timeFormatted:(int)mSeconds
{
mSeconds = (int)(mSeconds / 1000);
int seconds = (int)(mSeconds % 60);
int minutes = (int)((mSeconds / 60) % 60);
int hours = (int)(mSeconds / 3600);
return [NSString stringWithFormat:@"%02d:%02d:%02d",hours, minutes, seconds];
}
@end @end
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
[_dicoInfo setObject:[NSString stringWithFormat:@"%@%@",_PlexMediaServerUrl, [attributeDict objectForKey:@"key"]] forKey:@"keyMedia"]; [_dicoInfo setObject:[NSString stringWithFormat:@"%@%@",_PlexMediaServerUrl, [attributeDict objectForKey:@"key"]] forKey:@"keyMedia"];
if([attributeDict objectForKey:@"file"]) if([attributeDict objectForKey:@"file"])
[_dicoInfo setObject:[[attributeDict objectForKey:@"file"] lastPathComponent] forKey:@"namefile"]; [_dicoInfo setObject:[[attributeDict objectForKey:@"file"] lastPathComponent] forKey:@"namefile"];
NSString *duration = [self timeFormatted:[[attributeDict objectForKey:@"duration"] intValue]]; NSString *duration = [[VLCTime timeWithNumber:[attributeDict objectForKey:@"duration"]] stringValue];
[_dicoInfo setObject:duration forKey:@"duration"]; [_dicoInfo setObject:duration forKey:@"duration"];
NSString *sizeFile = (NSString *)[attributeDict objectForKey:@"size"]; NSString *sizeFile = (NSString *)[attributeDict objectForKey:@"size"];
[_dicoInfo setObject:sizeFile forKey:@"size"]; [_dicoInfo setObject:sizeFile forKey:@"size"];
...@@ -124,13 +124,4 @@ ...@@ -124,13 +124,4 @@
return httpStatus; return httpStatus;
} }
- (NSString *)timeFormatted:(int)mSeconds
{
mSeconds = (int)(mSeconds / 1000);
int seconds = (int)(mSeconds % 60);
int minutes = (int)((mSeconds / 60) % 60);
int hours = (int)(mSeconds / 3600);
return [NSString stringWithFormat:@"%02d:%02d:%02d",hours, minutes, seconds];
}
@end @end
\ No newline at end of file
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