Merge branch 'markus101'

pull/7/merge
kay.one 14 years ago
commit 5c45515b00

@ -28,7 +28,7 @@ namespace NzbDrone.Core.Test
var fakeSeries = Builder<Series>.CreateNew().Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
.WhereAll().Have(e => e.SeriesId = 1).Build();
.WhereAll().Have(e => e.SeriesId = 1).Have(e => e.EpisodeFileId = 0).Build();
db.InsertMany(fakeEpisodes);
@ -57,8 +57,8 @@ namespace NzbDrone.Core.Test
var fakeEpisodes = Builder<Episode>.CreateNew()
.With(e => e.SeriesId = fakeSeries.SeriesId)
.With(e => e.EpisodeNumber = 1)
.And(e => e.SeasonNumber = 2).Build();
.And(e => e.SeasonNumber = 2)
.With(e => e.EpisodeFileId = 0).Build();
db.Insert(fakeEpisodes);

@ -74,5 +74,57 @@ namespace NzbDrone.Core.Test
}
[Test]
[TestCase("Law & Order: Criminal Intent - S10E07 - Icarus [HDTV]", "Law & Order- Criminal Intent - S10E07 - Icarus [HDTV]")]
public void CleanFileName(string name, string expectedName)
{
//Act
var result = MediaFileProvider.CleanFilename(name);
//Assert
Assert.AreEqual(expectedName, result);
}
[Test]
public void CleanEpisodesWithNonExistantFiles()
{
//Setup
var episodes = Builder<Episode>.CreateListOfSize(10).Build();
var mocker = new AutoMoqer();
var database = MockLib.GetEmptyDatabase(true);
mocker.SetConstant(database);
database.InsertMany(episodes);
//Act
mocker.Resolve<MediaFileProvider>().CleanEpisodesWithNonExistantFiles();
var result = database.Fetch<Episode>();
//Assert
result.Should().HaveSameCount(episodes);
result.Should().OnlyContain(e => e.EpisodeFileId == 0);
}
[Test]
public void DeleteOrphanedEpisodeFiles()
{
//Setup
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(10).Build();
var episodes = Builder<Episode>.CreateListOfSize(5).Build();
var mocker = new AutoMoqer();
var database = MockLib.GetEmptyDatabase(true);
mocker.SetConstant(database);
database.InsertMany(episodes);
database.InsertMany(episodeFiles);
//Act
mocker.Resolve<MediaFileProvider>().DeleteOrphanedEpisodeFiles();
var result = database.Fetch<EpisodeFile>();
//Assert
result.Should().HaveCount(5);
result.Should().OnlyContain(e => e.EpisodeFileId > 0);
}
}
}

@ -1,7 +1,9 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
using AutoMoq;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
@ -18,6 +20,7 @@ namespace NzbDrone.Core.Test
private Episode tomorrow;
private Episode twoDays;
private Episode sevenDays;
private Series series;
[SetUp]
public new void Setup()
@ -25,33 +28,41 @@ namespace NzbDrone.Core.Test
yesterday = Builder<Episode>.CreateNew()
.With(c => c.AirDate = DateTime.Today.AddDays(-1))
.With(c => c.Title = "Yesterday")
.With(c => c.SeriesId = 1)
.Build();
today = Builder<Episode>.CreateNew()
.With(c => c.AirDate = DateTime.Today)
.With(c => c.Title = "Today")
.With(c => c.SeriesId = 1)
.Build();
tomorrow = Builder<Episode>.CreateNew()
.With(c => c.AirDate = DateTime.Today.AddDays(1))
.With(c => c.Title = "Tomorrow")
.With(c => c.SeriesId = 1)
.Build();
twoDays = Builder<Episode>.CreateNew()
.With(c => c.AirDate = DateTime.Today.AddDays(2))
.With(c => c.Title = "Two Days")
.With(c => c.SeriesId = 1)
.Build();
sevenDays = Builder<Episode>.CreateNew()
.With(c => c.AirDate = DateTime.Today.AddDays(7))
.With(c => c.Title = "Seven Days")
.With(c => c.SeriesId = 1)
.Build();
sevenDays = Builder<Episode>.CreateNew()
.With(c => c.AirDate = DateTime.Today.AddDays(8))
.With(c => c.Title = "Eight Days")
.With(c => c.SeriesId = 1)
.Build();
series = Builder<Series>.CreateNew().With(s => s.SeriesId = 1).Build();
base.Setup();
}
@ -68,6 +79,7 @@ namespace NzbDrone.Core.Test
database.Insert(tomorrow);
database.Insert(twoDays);
database.Insert(sevenDays);
database.Insert(series);
//Act
var result = mocker.Resolve<UpcomingEpisodesProvider>().Yesterday();
@ -75,6 +87,8 @@ namespace NzbDrone.Core.Test
//Assert
Assert.AreEqual(1, result.Count);
Assert.AreEqual(yesterday.Title, result[0].Title);
result[0].Series.Should().NotBeNull();
result[0].Series.SeriesId.Should().NotBe(0);
}
[Test]
@ -90,6 +104,7 @@ namespace NzbDrone.Core.Test
database.Insert(tomorrow);
database.Insert(twoDays);
database.Insert(sevenDays);
database.Insert(series);
//Act
var result = mocker.Resolve<UpcomingEpisodesProvider>().Today();
@ -97,6 +112,8 @@ namespace NzbDrone.Core.Test
//Assert
Assert.AreEqual(1, result.Count);
Assert.AreEqual(today.Title, result[0].Title);
result[0].Series.Should().NotBeNull();
result[0].Series.SeriesId.Should().NotBe(0);
}
[Test]
@ -112,6 +129,7 @@ namespace NzbDrone.Core.Test
database.Insert(tomorrow);
database.Insert(twoDays);
database.Insert(sevenDays);
database.Insert(series);
//Act
var result = mocker.Resolve<UpcomingEpisodesProvider>().Tomorrow();
@ -119,6 +137,8 @@ namespace NzbDrone.Core.Test
//Assert
Assert.AreEqual(1, result.Count);
Assert.AreEqual(tomorrow.Title, result[0].Title);
result[0].Series.Should().NotBeNull();
result[0].Series.SeriesId.Should().NotBe(0);
}
[Test]
@ -134,12 +154,17 @@ namespace NzbDrone.Core.Test
database.Insert(tomorrow);
database.Insert(twoDays);
database.Insert(sevenDays);
database.Insert(series);
//Act
var result = mocker.Resolve<UpcomingEpisodesProvider>().Week();
//Assert
Assert.AreEqual(2, result.Count);
result[0].Series.Should().NotBeNull();
result[0].Series.SeriesId.Should().NotBe(0);
result[1].Series.Should().NotBeNull();
result[1].Series.SeriesId.Should().NotBe(0);
}
}
}

@ -55,17 +55,5 @@ namespace NzbDrone.Core.Helpers
return String.Format("{0} - S{1:00}E{2} - {3}", erm.SeriesName, erm.EpisodeFile.Episodes[0].SeasonNumber,
epNumberString, epNameString);
}
public static string CleanFilename(string name)
{
string result = name;
string[] badCharacters = {"\\", "/", "<", ">", "?", "*", ":", "|", "\""};
string[] goodCharacters = {"+", "+", "{", "}", "!", "@", "-", "#", "`"};
for (int i = 0; i < badCharacters.Length; i++)
result = result.Replace(badCharacters[i], goodCharacters[i]);
return result.Trim();
}
}
}

@ -201,7 +201,9 @@ namespace NzbDrone.Core.Providers
/// <param name = "files">list of files to verify</param>
public virtual void CleanUp(List<EpisodeFile> files)
{
//TODO: remove orphaned files. in files table but not linked to from episode table.
_mediaFileProvider.CleanEpisodesWithNonExistantFiles();
_mediaFileProvider.DeleteOrphanedEpisodeFiles();
foreach (var episodeFile in files)
{
if (!_diskProvider.FileExists(episodeFile.Path))

@ -38,6 +38,7 @@ namespace NzbDrone.Core.Providers
var episode = AttachSeries(_database.Fetch<Episode, EpisodeFile>(@"SELECT * FROM Episodes
LEFT JOIN EpisodeFiles ON Episodes.EpisodeFileId = EpisodeFiles.EpisodeFileId
WHERE EpisodeId = @0", id).Single());
if (episode.EpisodeFileId == 0)
episode.EpisodeFile = null;

@ -74,6 +74,26 @@ namespace NzbDrone.Core.Providers
return new FileInfo(path);
}
public virtual void CleanEpisodesWithNonExistantFiles()
{
_database.Execute(@"UPDATE Episodes SET EpisodeFileId = 0
WHERE EpisodeFileId IN
(SELECT Episodes.EpisodeFileId FROM Episodes
LEFT OUTER JOIN EpisodeFiles
ON Episodes.EpisodeFileId = EpisodeFiles.EpisodeFileId
WHERE Episodes.EpisodeFileId > 0 AND EpisodeFiles.EpisodeFileId IS null)");
}
public virtual void DeleteOrphanedEpisodeFiles()
{
_database.Execute(@"DELETE FROM EpisodeFiles
WHERE EpisodeFileId IN
(SELECT EpisodeFiles.EpisodeFileId FROM EpisodeFiles
LEFT OUTER JOIN Episodes
ON EpisodeFiles.EpisodeFileId = Episodes.EpisodeFileId
WHERE Episodes.EpisodeFileId IS null)");
}
public virtual string GetNewFilename(IList<Episode> episodes, string seriesTitle, QualityTypes quality)
{
var separatorStyle = EpisodeSortingHelper.GetSeparatorStyle(_configProvider.SeparatorStyle);
@ -129,6 +149,18 @@ namespace NzbDrone.Core.Providers
result = result.Replace(' ', '.');
Logger.Debug("New File Name is: {0}", result.Trim());
return CleanFilename(result.Trim());
}
public static string CleanFilename(string name)
{
string result = name;
string[] badCharacters = { "\\", "/", "<", ">", "?", "*", ":", "|", "\"" };
string[] goodCharacters = { "+", "+", "{", "}", "!", "@", "-", "#", "`" };
for (int i = 0; i < badCharacters.Length; i++)
result = result.Replace(badCharacters[i], goodCharacters[i]);
return result.Trim();
}
}

@ -6,6 +6,7 @@ using System.Text.RegularExpressions;
using NLog;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using PetaPoco;
using TvdbLib.Data;
@ -17,17 +18,15 @@ namespace NzbDrone.Core.Providers
private readonly ConfigProvider _configProvider;
private readonly TvDbProvider _tvDbProvider;
private readonly IDatabase _database;
private readonly QualityProvider _qualityProvider;
private readonly SceneMappingProvider _sceneNameMappingProvider;
private static readonly Regex TimeRegex = new Regex(@"^(?<time>\d+:?\d*)\W*(?<meridiem>am|pm)?", RegexOptions.IgnoreCase | RegexOptions.Compiled);
public SeriesProvider(IDatabase database, ConfigProvider configProviderProvider, QualityProvider qualityProvider,
public SeriesProvider(IDatabase database, ConfigProvider configProviderProvider,
TvDbProvider tvDbProviderProvider, SceneMappingProvider sceneNameMappingProvider)
{
_database = database;
_configProvider = configProviderProvider;
_tvDbProvider = tvDbProviderProvider;
_qualityProvider = qualityProvider;
_sceneNameMappingProvider = sceneNameMappingProvider;
}
@ -37,15 +36,36 @@ namespace NzbDrone.Core.Providers
public virtual IList<Series> GetAllSeries()
{
var series = _database.Fetch<Series>();
series.ForEach(c => c.QualityProfile = _qualityProvider.Get(c.QualityProfileId));
var series = _database.Fetch<Series, QualityProfile>(@"SELECT * FROM Series
INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId");
return series;
}
public virtual IList<Series> GetAllSeriesWithEpisodeCount(bool ignoreSpecials)
{
var seasonNumber = 0;
if (!ignoreSpecials)
seasonNumber = -1;
var series = _database.Fetch<Series, QualityProfile>(@"SELECT Series.*, COUNT (NULLIF(Ignored, 1)) AS EpisodeCount,
SUM(CASE WHEN Ignored = 0 AND EpisodeFileId > 0 THEN 1 ELSE 0 END) as EpisodeFileCount,
COUNT (DISTINCT(NULLIF(SeasonNumber, @0))) as SeasonCount,
QualityProfiles.*
FROM Series
INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId
JOIN Episodes ON Series.SeriesId = Episodes.SeriesId
GROUP BY seriesId", seasonNumber);
return series;
}
public virtual Series GetSeries(int seriesId)
{
var series = _database.Single<Series>("WHERE seriesId= @0", seriesId);
series.QualityProfile = _qualityProvider.Get(series.QualityProfileId);
var series = _database.Fetch<Series, QualityProfile>(@"SELECT * FROM Series
INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId
WHERE seriesId= @0", seriesId).Single();
return series;
}
@ -106,17 +126,13 @@ namespace NzbDrone.Core.Providers
return GetSeries(seriesId.Value);
}
var series = _database.FirstOrDefault<Series>("WHERE CleanTitle = @0", normalizeTitle);
var series = _database.Fetch<Series, QualityProfile>(@"SELECT * FROM Series
INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId
WHERE CleanTitle = @0", normalizeTitle).FirstOrDefault();
if (series != null)
{
series.QualityProfile = _qualityProvider.Get(series.QualityProfileId);
return series;
}
return null;
}
public virtual void UpdateSeries(Series series)
{
_database.Update(series);

@ -20,8 +20,10 @@ namespace NzbDrone.Core.Providers
public virtual UpcomingEpisodesModel Upcoming()
{
var allEps = _database.Fetch<Episode>("WHERE AirDate BETWEEN @0 AND @1", DateTime.Today.AddDays(-1),
DateTime.Today.AddDays(8));
var allEps = _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
WHERE AirDate BETWEEN @0 AND @1",
DateTime.Today.AddDays(-1), DateTime.Today.AddDays(8));
var yesterday = allEps.Where(e => e.AirDate == DateTime.Today.AddDays(-1)).ToList();
var today = allEps.Where(e => e.AirDate == DateTime.Today).ToList();
@ -32,22 +34,30 @@ namespace NzbDrone.Core.Providers
public virtual List<Episode> Yesterday()
{
return _database.Fetch<Episode>("WHERE AirDate = @0", DateTime.Today.AddDays(-1));
return _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
WHERE AirDate = @0", DateTime.Today.AddDays(-1));
}
public virtual List<Episode> Today()
{
return _database.Fetch<Episode>("WHERE AirDate = @0", DateTime.Today);
return _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
WHERE AirDate = @0", DateTime.Today);
}
public virtual List<Episode> Tomorrow()
{
return _database.Fetch<Episode>("WHERE AirDate = @0", DateTime.Today.AddDays(1));
return _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
WHERE AirDate = @0", DateTime.Today.AddDays(1));
}
public virtual List<Episode> Week()
{
return _database.Fetch<Episode>("WHERE AirDate BETWEEN @0 AND @1", DateTime.Today.AddDays(2), DateTime.Today.AddDays(8));
return _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
WHERE AirDate BETWEEN @0 AND @1", DateTime.Today.AddDays(2), DateTime.Today.AddDays(8));
}
}
}

@ -32,7 +32,7 @@ namespace NzbDrone.Core.Repository
/// </remarks>
public DateTime? GrabDate { get; set; }
[Ignore]
[ResultColumn]
public EpisodeStatusType Status
{
get

@ -10,32 +10,25 @@ namespace NzbDrone.Core.Repository
{
public virtual int SeriesId { get; set; }
public string Title { get; set; }
public string CleanTitle { get; set; }
public string Status { get; set; }
public string Overview { get; set; }
[DisplayName("Air on")]
public DayOfWeek? AirsDayOfWeek { get; set; }
public String AirTimes { get; set; }
public string Language { get; set; }
public string Path { get; set; }
public bool Monitored { get; set; }
public virtual int QualityProfileId { get; set; }
public bool SeasonFolder { get; set; }
@ -55,5 +48,14 @@ namespace NzbDrone.Core.Repository
[Ignore]
public QualityProfile QualityProfile { get; set; }
[ResultColumn]
public int EpisodeCount { get; set; }
[ResultColumn]
public int EpisodeFileCount { get; set; }
[ResultColumn]
public int SeasonCount { get; set; }
}
}

@ -129,7 +129,7 @@ namespace NzbDrone.Web.Controllers
var path =
rootPath.Replace('|', Path.DirectorySeparatorChar).Replace('^', Path.VolumeSeparatorChar).Replace(
'`', '\'') +
Path.DirectorySeparatorChar + EpisodeRenameHelper.CleanFilename(seriesName);
Path.DirectorySeparatorChar + MediaFileProvider.CleanFilename(seriesName);
//Create the folder for the new series and then Add it
_diskProvider.CreateDirectory(path);

@ -80,8 +80,7 @@ namespace NzbDrone.Web.Controllers
[GridAction]
public ActionResult _AjaxSeriesGrid()
{
var series = GetSeriesModels(_seriesProvider.GetAllSeries().ToList());
var series = GetSeriesModels(_seriesProvider.GetAllSeriesWithEpisodeCount(true).ToList());
return View(new GridModel(series));
}
@ -124,17 +123,6 @@ namespace NzbDrone.Web.Controllers
return View(new GridModel(episodes));
}
public JsonResult GetEpisodeCount(int seriesId)
{
var count = _mediaFileProvider.GetEpisodeFilesCount(seriesId);
return Json(new
{
Episodes = count.Item1,
EpisodeTotal = count.Item2
}, JsonRequestBehavior.AllowGet);
}
public ActionResult SearchForSeries(string seriesName)
{
var model = new List<SeriesSearchResultModel>();
@ -206,11 +194,7 @@ namespace NzbDrone.Web.Controllers
private List<SeriesModel> GetSeriesModels(List<Series> seriesInDb)
{
var series = new List<SeriesModel>();
foreach (var s in seriesInDb)
{
series.Add(new SeriesModel
var series = seriesInDb.Select(s => new SeriesModel
{
SeriesId = s.SeriesId,
Title = s.Title,
@ -222,9 +206,10 @@ namespace NzbDrone.Web.Controllers
QualityProfileName = s.QualityProfile.Name,
SeasonFolder = s.SeasonFolder,
Status = s.Status,
SeasonsCount = _episodeProvider.GetSeasons(s.SeriesId).Where(n => n != 0).Count()
});
}
SeasonsCount = s.SeasonCount,
EpisodeCount = s.EpisodeCount,
EpisodeFileCount = s.EpisodeFileCount
}).ToList();
return series;
}

@ -30,25 +30,17 @@ namespace NzbDrone.Web.Controllers
[GridAction]
public ActionResult _AjaxBindingYesterday()
{
var upcomingDb = _upcomingEpisodesProvider.Yesterday();
var upcoming = new List<UpcomingEpisodeModel>();
foreach (var item in upcomingDb)
{
var series = _seriesProvider.GetSeries(item.SeriesId);
upcoming.Add(new UpcomingEpisodeModel
var upcoming = _upcomingEpisodesProvider.Yesterday().Select(u => new UpcomingEpisodeModel
{
SeriesId = series.SeriesId,
EpisodeId = item.EpisodeId,
SeriesName = series.Title,
SeasonNumber = item.SeasonNumber,
EpisodeNumber = item.EpisodeNumber,
Title = item.Title,
Overview = item.Overview,
AirDate = item.AirDate.Add(Convert.ToDateTime(series.AirTimes).TimeOfDay)
SeriesId = u.Series.SeriesId,
EpisodeId = u.EpisodeId,
SeriesName = u.Series.Title,
SeasonNumber = u.SeasonNumber,
EpisodeNumber = u.EpisodeNumber,
Title = u.Title,
Overview = u.Overview,
AirDate = u.AirDate.Add(Convert.ToDateTime(u.Series.AirTimes).TimeOfDay)
});
}
return View(new GridModel(upcoming));
}
@ -56,25 +48,17 @@ namespace NzbDrone.Web.Controllers
[GridAction]
public ActionResult _AjaxBindingToday()
{
var upcomingDb = _upcomingEpisodesProvider.Today();
var upcoming = new List<UpcomingEpisodeModel>();
foreach (var item in upcomingDb)
{
var series = _seriesProvider.GetSeries(item.SeriesId);
upcoming.Add(new UpcomingEpisodeModel
var upcoming = _upcomingEpisodesProvider.Today().Select(u => new UpcomingEpisodeModel
{
SeriesId = series.SeriesId,
EpisodeId = item.EpisodeId,
SeriesName = series.Title,
SeasonNumber = item.SeasonNumber,
EpisodeNumber = item.EpisodeNumber,
Title = item.Title,
Overview = item.Overview,
AirDate = item.AirDate.Add(Convert.ToDateTime(series.AirTimes).TimeOfDay)
SeriesId = u.Series.SeriesId,
EpisodeId = u.EpisodeId,
SeriesName = u.Series.Title,
SeasonNumber = u.SeasonNumber,
EpisodeNumber = u.EpisodeNumber,
Title = u.Title,
Overview = u.Overview,
AirDate = u.AirDate.Add(Convert.ToDateTime(u.Series.AirTimes).TimeOfDay)
});
}
return View(new GridModel(upcoming));
}
@ -82,25 +66,17 @@ namespace NzbDrone.Web.Controllers
[GridAction]
public ActionResult _AjaxBindingTomorrow()
{
var upcomingDb = _upcomingEpisodesProvider.Tomorrow();
var upcoming = new List<UpcomingEpisodeModel>();
foreach (var item in upcomingDb)
{
var series = _seriesProvider.GetSeries(item.SeriesId);
upcoming.Add(new UpcomingEpisodeModel
var upcoming = _upcomingEpisodesProvider.Tomorrow().Select(u => new UpcomingEpisodeModel
{
SeriesId = series.SeriesId,
EpisodeId = item.EpisodeId,
SeriesName = series.Title,
SeasonNumber = item.SeasonNumber,
EpisodeNumber = item.EpisodeNumber,
Title = item.Title,
Overview = item.Overview,
AirDate = item.AirDate.Add(Convert.ToDateTime(series.AirTimes).TimeOfDay)
SeriesId = u.Series.SeriesId,
EpisodeId = u.EpisodeId,
SeriesName = u.Series.Title,
SeasonNumber = u.SeasonNumber,
EpisodeNumber = u.EpisodeNumber,
Title = u.Title,
Overview = u.Overview,
AirDate = u.AirDate.Add(Convert.ToDateTime(u.Series.AirTimes).TimeOfDay)
});
}
return View(new GridModel(upcoming));
}
@ -108,25 +84,17 @@ namespace NzbDrone.Web.Controllers
[GridAction]
public ActionResult _AjaxBindingWeek()
{
var upcomingDb = _upcomingEpisodesProvider.Week();
var upcoming = new List<UpcomingEpisodeModel>();
foreach (var item in upcomingDb)
{
var series = _seriesProvider.GetSeries(item.SeriesId);
upcoming.Add(new UpcomingEpisodeModel
var upcoming = _upcomingEpisodesProvider.Week().Select(u => new UpcomingEpisodeModel
{
SeriesId = series.SeriesId,
EpisodeId = item.EpisodeId,
SeriesName = series.Title,
SeasonNumber = item.SeasonNumber,
EpisodeNumber = item.EpisodeNumber,
Title = item.Title,
Overview = item.Overview,
AirDate = item.AirDate.Add(Convert.ToDateTime(series.AirTimes).TimeOfDay)
SeriesId = u.Series.SeriesId,
EpisodeId = u.EpisodeId,
SeriesName = u.Series.Title,
SeasonNumber = u.SeasonNumber,
EpisodeNumber = u.EpisodeNumber,
Title = u.Title,
Overview = u.Overview,
AirDate = u.AirDate.Add(Convert.ToDateTime(u.Series.AirTimes).TimeOfDay)
});
}
return View(new GridModel(upcoming));
}

@ -14,6 +14,8 @@ namespace NzbDrone.Web.Models
//View Only
public string Title { get; set; }
public int SeasonsCount { get; set; }
public int EpisodeCount { get; set; }
public int EpisodeFileCount { get; set; }
public string Status { get; set; }
public string AirsDayOfWeek { get; set; }
public string QualityProfileName { get; set; }

@ -186,37 +186,9 @@
function grid_rowBound(e) {
var dataItem = e.dataItem;
var seriesId = dataItem.SeriesId;
var getEpisodeCountUrl = '@Url.Action("GetEpisodeCount", "Series")';
var episodeCount = dataItem.EpisodeCount;
var episodeFileCount = dataItem.EpisodeFileCount;
$("#progressbar_" + seriesId).episodeProgress(0, 0);
$.ajax({
type: "GET",
url: getEpisodeCountUrl,
data: jQuery.param({ seriesId: seriesId }),
error: function (req, status, error) {
alert("Sorry! We could search for " + id + " at this time. " + error);
},
success: function (data, textStatus, jqXHR) {
var episodes = data.Episodes;
var episodeTotal = data.EpisodeTotal;
var counter = 0;
var max = episodes + 1;
$.doTimeout(10, function () {
if (counter >= max) {
$("#progressbar_" + seriesId).episodeProgress(episodes, episodeTotal);
return false;
}
$("#progressbar_" + seriesId).episodeProgress(counter, episodeTotal);
counter += 5;
return true;
});
}
});
$("#progressbar_" + seriesId).episodeProgress(episodeFileCount, episodeCount);
}
</script>
Loading…
Cancel
Save