Code cleanup per commit comments. More Work?!

EpisodeParseResult will use Season ## when it is a full season instead of writing out each episode number.
pull/2/head
Mark McDowall 13 years ago
parent 1f983094ac
commit 26adbf2602

@ -10,34 +10,28 @@ namespace NzbDrone.Core.Helpers
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (value is TimeSpan)
writer.WriteValue(value.ToString());
else
throw new Exception("Expected TimeSpan object value.");
var ts = (TimeSpan)value;
writer.WriteValue(ts.ToString());
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
var split = reader.Value.ToString().Split(':');
if (split.Count() == 3)
if (split.Count() != 3)
{
return new TimeSpan(int.Parse(split[0]), // hours
throw new ArgumentException("TimeSpan is invalid");
}
return new TimeSpan(int.Parse(split[0]), // hours
int.Parse(split[1]), // minutes
int.Parse(split[2]) // seconds
);
}
throw new ArgumentException("TimeSpan is invalid");
}
public override bool CanConvert(Type objectType)
{
if (objectType == typeof(TimeSpan))
return true;
return false;
return objectType == typeof(TimeSpan);
}
}
}

@ -44,6 +44,9 @@ namespace NzbDrone.Core.Model
if (AirDate != null && EpisodeNumbers == null)
return string.Format("{0} - {1} {2}", SeriesTitle, AirDate.Value.ToShortDateString(), Quality);
if (FullSeason)
return string.Format("{0} - Season {1:00}", SeriesTitle, SeasonNumber);
if (EpisodeNumbers != null)
return string.Format("{0} - S{1:00}E{2} {3}", SeriesTitle, SeasonNumber,
String.Join("-", EpisodeNumbers), Quality);

Loading…
Cancel
Save