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 @@
for (NSManagedObject *mo in allMedia) {
if ([mo isKindOfClass:[MLFile class]]) {
duration = [self timeFormatted:[[(MLFile *)mo duration] integerValue]];
duration = [[VLCTime timeWithNumber:[(MLFile *)mo duration]] stringValue];
[mediaInHtml addObject:[NSString stringWithFormat:
@"<div style=\"background-image:url('thumbnail/%@.png')\"> \
<a href=\"download/%@\" class=\"inner\"> \
......@@ -206,7 +206,7 @@
[(MLShow *)mo name],
[episodes count]]];
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:
@"<div style=\"background-image:url('thumbnail/%@.png')\"> \
<a href=\"download/%@\" class=\"inner\"> \
......@@ -241,7 +241,7 @@
[(MLLabel *)mo name],
[folderItems count]]];
for (MLFile *file in folderItems) {
duration = [self timeFormatted:[[file duration] integerValue]];
duration = [[VLCTime timeWithNumber:[file duration]] stringValue];
[mediaInHtml addObject:[NSString stringWithFormat:
@"<div style=\"background-image:url('thumbnail/%@.png')\"> \
<a href=\"download/%@\" class=\"inner\"> \
......@@ -274,7 +274,7 @@
[(MLAlbum *)mo name],
[albumTracks count]]];
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:
@"<div style=\"background-image:url('thumbnail/%@.png')\"> \
<a href=\"download/%@\" class=\"inner\"> \
......@@ -416,13 +416,4 @@
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
......@@ -77,7 +77,7 @@
[_dicoInfo setObject:[NSString stringWithFormat:@"%@%@",_PlexMediaServerUrl, [attributeDict objectForKey:@"key"]] forKey:@"keyMedia"];
if([attributeDict objectForKey:@"file"])
[_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"];
NSString *sizeFile = (NSString *)[attributeDict objectForKey:@"size"];
[_dicoInfo setObject:sizeFile forKey:@"size"];
......@@ -124,13 +124,4 @@
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
\ 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