mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-12 11:15:43 +02:00
Code cleanup per commit comments. More Work?!
EpisodeParseResult will use Season ## when it is a full season instead of writing out each episode number.
This commit is contained in:
parent
1f983094ac
commit
26adbf2602
@ -10,34 +10,28 @@ public class SabnzbdQueueTimeConverter : JsonConverter
|
||||
{
|
||||
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 @@ public override string ToString()
|
||||
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…
Reference in New Issue
Block a user