Release group is added to history and episodefile

This commit is contained in:
Mark McDowall 2012-08-05 23:33:07 -07:00
parent d6c90e7f36
commit 6f3262c68a
9 changed files with 37 additions and 11 deletions

View File

@ -12,6 +12,8 @@ namespace NzbDrone.Core.Datastore.Migrations
protected override void MainDbUpgrade()
{
Database.AddColumn("EpisodeFiles", new Column("SceneName", DbType.String, ColumnProperty.Null));
Database.AddColumn("EpisodeFiles", new Column("ReleaseGroup", DbType.String, ColumnProperty.Null));
Database.AddColumn("History", new Column("ReleaseGroup", DbType.String, ColumnProperty.Null));
}
}
}

View File

@ -44,6 +44,8 @@ namespace NzbDrone.Core.Model
public int Age { get; set; }
public string ReleaseGroup { get; set; }
public override string ToString()
{

View File

@ -124,6 +124,7 @@ namespace NzbDrone.Core
result.Language = ParseLanguage(title);
result.Quality = ParseQuality(title);
result.OriginalString = title;
result.ReleaseGroup = ParseReleaseGroup(title);
return result;
}
}
@ -424,19 +425,22 @@ namespace NzbDrone.Core
return LanguageType.English;
}
internal static string ParseReleaseGroup(string name)
internal static string ParseReleaseGroup(string title)
{
Logger.Trace("Trying to parse release group for {0}", name);
Logger.Trace("Trying to parse release group for {0}", title);
name = name.Trim();
var index = name.LastIndexOf('-');
title = title.Trim();
var index = title.LastIndexOf('-');
if (index < 0)
index = name.LastIndexOf(' ');
index = title.LastIndexOf(' ');
var group = name.Substring(index + 1);
if (index < 0)
return String.Empty;
if (group.Length == name.Length)
var group = title.Substring(index + 1);
if (group.Length == title.Length)
return String.Empty;
Logger.Trace("Release Group found: {0}", group);

View File

@ -154,6 +154,7 @@ namespace NzbDrone.Core.Providers
episodeFile.Proper = parseResult.Quality.Proper;
episodeFile.SeasonNumber = parseResult.SeasonNumber;
episodeFile.SceneName = Path.GetFileNameWithoutExtension(filePath.NormalizePath());
episodeFile.ReleaseGroup = parseResult.ReleaseGroup;
var fileId = _mediaFileProvider.Add(episodeFile);
//Link file to all episodes

View File

@ -63,6 +63,7 @@ namespace NzbDrone.Core.Providers
history.EpisodeId = episode.EpisodeId;
history.SeriesId = episode.SeriesId;
history.NzbInfoUrl = parseResult.NzbInfoUrl;
history.ReleaseGroup = parseResult.ReleaseGroup;
_historyProvider.Add(history);
_episodeProvider.MarkEpisodeAsFetched(episode.EpisodeId);

View File

@ -63,7 +63,6 @@ namespace NzbDrone.Core.Providers.Indexer
get { return null; }
}
protected abstract IList<String> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber);
protected abstract IList<String> GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date);
protected abstract IList<String> GetSeasonSearchUrls(string seriesTitle, int seasonNumber);

View File

@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.ServiceModel.Syndication;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using Ninject;
using NzbDrone.Common;
using NzbDrone.Core.Model;
@ -44,7 +46,6 @@ namespace NzbDrone.Core.Providers.Indexer
}
}
protected override NetworkCredential Credentials
{
get { return new NetworkCredential(_configProvider.NewzbinUsername, _configProvider.NewzbinPassword); }
@ -90,7 +91,6 @@ namespace NzbDrone.Core.Providers.Indexer
};
}
public override string Name
{
get { return "Newzbin"; }
@ -118,10 +118,25 @@ namespace NzbDrone.Core.Providers.Indexer
var sizeString = Regex.Match(item.Summary.Text, @"\(Size: \d*\,?\d+\.\d{1,2}\w{2}\)", RegexOptions.IgnoreCase).Value;
currentResult.Size = Parser.GetReportSize(sizeString);
try
{
var releaseGroupText = item.ElementExtensions.Single(s => s.OuterName == "nfo")
.GetObject<XElement>()
.Element(XName.Get("filename", "http://www.newzbin2.es/DTD/2007/feeds/report/"))
.Value;
var releaseGroup = Parser.ParseReleaseGroup(releaseGroupText.Replace(".nfo", ""));
currentResult.ReleaseGroup = releaseGroup;
}
catch(Exception ex)
{
_logger.TraceException("Error getting release group for newzbin release", ex);
currentResult.ReleaseGroup = "";
}
}
return currentResult;
}
}
}

View File

@ -35,6 +35,7 @@ namespace NzbDrone.Core.Repository
public long Size { get; set; }
public DateTime DateAdded { get; set; }
public string SceneName { get; set; }
public string ReleaseGroup { get; set; }
[Ignore]
public Model.Quality QualityWrapper

View File

@ -17,6 +17,7 @@ namespace NzbDrone.Core.Repository
public bool IsProper { get; set; }
public string Indexer { get; set; }
public string NzbInfoUrl { get; set; }
public string ReleaseGroup { get; set; }
[ResultColumn]
public Episode Episode { get; set; }