|
|
@ -1,6 +1,7 @@
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Exceptions;
|
|
|
|
using NzbDrone.Core.Messaging.Events;
|
|
|
|
using NzbDrone.Core.Messaging.Events;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -36,17 +37,21 @@ namespace NzbDrone.Core.Tv
|
|
|
|
{
|
|
|
|
{
|
|
|
|
cleanTitle = cleanTitle.ToLowerInvariant();
|
|
|
|
cleanTitle = cleanTitle.ToLowerInvariant();
|
|
|
|
|
|
|
|
|
|
|
|
return Query.Where(s => s.CleanTitle == cleanTitle)
|
|
|
|
var series = Query.Where(s => s.CleanTitle == cleanTitle)
|
|
|
|
.SingleOrDefault();
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ReturnSingleSeriesOrThrow(series);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Series FindByTitle(string cleanTitle, int year)
|
|
|
|
public Series FindByTitle(string cleanTitle, int year)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
cleanTitle = cleanTitle.ToLowerInvariant();
|
|
|
|
cleanTitle = cleanTitle.ToLowerInvariant();
|
|
|
|
|
|
|
|
|
|
|
|
return Query.Where(s => s.CleanTitle == cleanTitle)
|
|
|
|
var series = Query.Where(s => s.CleanTitle == cleanTitle)
|
|
|
|
.AndWhere(s => s.Year == year)
|
|
|
|
.AndWhere(s => s.Year == year)
|
|
|
|
.SingleOrDefault();
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ReturnSingleSeriesOrThrow(series);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<Series> FindByTitleInexact(string cleanTitle)
|
|
|
|
public List<Series> FindByTitleInexact(string cleanTitle)
|
|
|
@ -72,5 +77,20 @@ namespace NzbDrone.Core.Tv
|
|
|
|
return Query.Where(s => s.Path == path)
|
|
|
|
return Query.Where(s => s.Path == path)
|
|
|
|
.FirstOrDefault();
|
|
|
|
.FirstOrDefault();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Series ReturnSingleSeriesOrThrow(List<Series> series)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (series.Count == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (series.Count == 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return series.First();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw new MultipleSeriesFoundException("Expected one series, but found {0}. Matching series: {1}", series.Count, string.Join(",", series));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|