Merge branch 'master' of git://github.com/kayone/NzbDrone

This commit is contained in:
Mark McDowall 2011-05-29 14:25:34 -07:00
commit 2788368f73
8 changed files with 98 additions and 45 deletions

View File

@ -1,5 +1,6 @@
// ReSharper disable RedundantUsingDirective // ReSharper disable RedundantUsingDirective
using System; using System;
using System.Linq;
using MbUnit.Framework; using MbUnit.Framework;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
@ -38,19 +39,19 @@ namespace NzbDrone.Core.Test
[Test] [Test]
[Row(new object[] {"CAPITAL", "capital", true})] [Row(new object[] { "CAPITAL", "capital", true })]
[Row(new object[] {"Something!!", "Something", true})] [Row(new object[] { "Something!!", "Something", true })]
[Row(new object[] {"Simpsons 2000", "Simpsons", true})] [Row(new object[] { "Simpsons 2000", "Simpsons", true })]
[Row(new object[] {"Simp222sons", "Simpsons", true})] [Row(new object[] { "Simp222sons", "Simpsons", true })]
[Row(new object[] {"Simpsons", "The Simpsons", true})] [Row(new object[] { "Simpsons", "The Simpsons", true })]
[Row(new object[] {"Law and order", "Law & order", true})] [Row(new object[] { "Law and order", "Law & order", true })]
[Row(new object[] {"xxAndxx", "xxxx", false})] [Row(new object[] { "xxAndxx", "xxxx", false })]
[Row(new object[] {"Andxx", "xx", false})] [Row(new object[] { "Andxx", "xx", false })]
[Row(new object[] {"xxAnd", "xx", false})] [Row(new object[] { "xxAnd", "xx", false })]
[Row(new object[] {"Thexx", "xx", false})] [Row(new object[] { "Thexx", "xx", false })]
[Row(new object[] {"Thexx", "xx", false})] [Row(new object[] { "Thexx", "xx", false })]
[Row(new object[] {"xxThexx", "xxxxx", false})] [Row(new object[] { "xxThexx", "xxxxx", false })]
[Row(new object[] {"Simpsons The", "Simpsons", true})] [Row(new object[] { "Simpsons The", "Simpsons", true })]
public void Name_match_test(string a, string b, bool match) public void Name_match_test(string a, string b, bool match)
{ {
bool result = TvDbProvider.IsTitleMatch(a, b); bool result = TvDbProvider.IsTitleMatch(a, b);
@ -83,5 +84,50 @@ namespace NzbDrone.Core.Test
//assert //assert
Assert.IsNull(result); Assert.IsNull(result);
} }
[Test]
public void American_dad_fix()
{
//setup
var tvdbProvider = new TvDbProvider();
//act
var result = tvdbProvider.GetSeries(73141, true);
var seasons = result.Episodes.Select(e => e.SeasonNumber)
.Distinct().ToList();
var seasons1 = result.Episodes.Where(e => e.SeasonNumber == 1).ToList();
var seasons2 = result.Episodes.Where(e => e.SeasonNumber == 2).ToList();
var seasons3 = result.Episodes.Where(e => e.SeasonNumber == 3).ToList();
var seasons4 = result.Episodes.Where(e => e.SeasonNumber == 4).ToList();
var seasons5 = result.Episodes.Where(e => e.SeasonNumber == 5).ToList();
var seasons6 = result.Episodes.Where(e => e.SeasonNumber == 6).ToList();
foreach (var episode in result.Episodes)
{
Console.WriteLine(episode);
}
//assert
Assert.Count(7, seasons);
Assert.Count(23, seasons1);
Assert.Count(19, seasons2);
Assert.Count(16, seasons3);
Assert.Count(20, seasons4);
Assert.Count(18, seasons5);
Assert.Distinct(seasons1.Select(s => s.EpisodeNumber));
Assert.Distinct(seasons2.Select(s => s.EpisodeNumber));
Assert.Distinct(seasons3.Select(s => s.EpisodeNumber));
Assert.Distinct(seasons4.Select(s => s.EpisodeNumber));
Assert.Distinct(seasons5.Select(s => s.EpisodeNumber));
Assert.Distinct(seasons6.Select(s => s.EpisodeNumber));
}
} }
} }

View File

@ -47,7 +47,7 @@ namespace NzbDrone.Core.Providers.Jobs
{ {
notification.CurrentMessage = "Updating " + series.Title; notification.CurrentMessage = "Updating " + series.Title;
_seriesProvider.UpdateSeriesInfo(series.SeriesId); _seriesProvider.UpdateSeriesInfo(series.SeriesId);
_episodeProvider.RefreshEpisodeInfo(series.SeriesId); _episodeProvider.RefreshEpisodeInfo(series);
notification.CurrentMessage = "Update completed for " + series.Title; notification.CurrentMessage = "Update completed for " + series.Title;
} }
} }

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using NLog; using NLog;
@ -79,7 +80,32 @@ namespace NzbDrone.Core.Providers
lock (_handler) lock (_handler)
{ {
Logger.Debug("Fetching SeriesId'{0}' from tvdb", id); Logger.Debug("Fetching SeriesId'{0}' from tvdb", id);
return _handler.GetSeries(id, TvdbLanguage.DefaultLanguage, loadEpisodes, false, false); var result = _handler.GetSeries(id, TvdbLanguage.DefaultLanguage, loadEpisodes, false, false);
//Fix American Dad's scene gongshow
if (result != null && result.Id == 73141)
{
var seasonOneEpisodeCount = result.Episodes.Where(e => e.SeasonNumber == 0).Count();
var seasonOneId = result.Episodes.Where(e => e.SeasonNumber == 1).First().SeasonId;
foreach (var episode in result.Episodes)
{
if (episode.SeasonNumber > 1)
{
if (episode.SeasonNumber == 2)
{
episode.EpisodeNumber = episode.EpisodeNumber + seasonOneEpisodeCount;
episode.SeasonId = seasonOneId;
}
episode.SeasonNumber = episode.SeasonNumber - 1;
}
}
}
return result;
} }
} }

View File

@ -49,15 +49,17 @@ namespace NzbDrone.Core.Repository
{ {
get get
{ {
if (Ignored || (Season != null && !Season.Monitored)) return EpisodeStatusType.Ignored; if (EpisodeFileId != 0) return EpisodeStatusType.Ready;
var season = Season;
if (Ignored || (season != null && !season.Monitored)) return EpisodeStatusType.Ignored;
if (GrabDate != null && GrabDate.Value.AddDays(1) >= DateTime.Now) if (GrabDate != null && GrabDate.Value.AddDays(1) >= DateTime.Now)
{ {
return EpisodeStatusType.Downloading; return EpisodeStatusType.Downloading;
} }
if (EpisodeFileId != 0) return EpisodeStatusType.Ready;
if (AirDate.Date.Year > 1900 && DateTime.Now.Date >= AirDate.Date) if (AirDate.Date.Year > 1900 && DateTime.Now.Date >= AirDate.Date)
{ {
return EpisodeStatusType.Missing; return EpisodeStatusType.Missing;

View File

@ -55,15 +55,6 @@ namespace NzbDrone.Web.Controllers
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
public ActionResult LoadEpisodes(int seriesId)
{
_episodeProvider.RefreshEpisodeInfo(seriesId);
return RedirectToAction("Details", new
{
seriesId
});
}
public ActionResult SeasonEditor(int seriesId) public ActionResult SeasonEditor(int seriesId)
{ {
var model = var model =
@ -149,7 +140,7 @@ namespace NzbDrone.Web.Controllers
return String.Empty; return String.Empty;
//Return the path relative to the Series' Folder //Return the path relative to the Series' Folder
return file.Path.Replace(file.Series.Path, "").Trim(Path.DirectorySeparatorChar); return file.Path;
} }
public ActionResult SearchForSeries(string seriesName) public ActionResult SearchForSeries(string seriesName)

View File

@ -7,23 +7,11 @@
@section ActionMenu{ @section ActionMenu{
@{Html.Telerik().Menu().Name("SeriesMenu").Items(items => @{Html.Telerik().Menu().Name("SeriesMenu").Items(items =>
{ {
items.Add().Text("Back to Series List").Action("Index", items.Add().Text("Back to Series List").Action("Index", "Series");
"Series"); items.Add().Text("Scan For Episodes on Disk")
items.Add().Text("Scan For Episodes on Disk").Action( .Action("SyncEpisodesOnDisk", "Series", new { seriesId = Model.SeriesId });
"SyncEpisodesOnDisk", "Series", items.Add().Text("Update Info").Action("UpdateInfo", "Series", new { seriesId = Model.SeriesId });
new { seriesId = Model.SeriesId }); items.Add().Text("Rename Series").Action("RenameSeries", "Series", new { seriesId = Model.SeriesId });
items.Add().Text("Update Info").Action(
"UpdateInfo", "Series",
new { seriesId = Model.SeriesId });
items.Add().Text("Rename Series").Action("RenameSeries",
"Series",
new
{
seriesId
=
Model.
SeriesId
});
}).Render();} }).Render();}
} }
@section MainContent{ @section MainContent{