Updated folder mapping logic. Added unmapped folder view.
This commit is contained in:
parent
beaf0cf939
commit
9d52229e04
|
@ -23,5 +23,11 @@ namespace NzbDrone.Core.Test
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
Main.ConfigureNlog();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -68,8 +68,47 @@ namespace NzbDrone.Core.Test
|
||||||
moqData.Verify(c => c.Add(It.IsAny<Series>()), Times.Once());
|
moqData.Verify(c => c.Add(It.IsAny<Series>()), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[Row(0)]
|
||||||
|
[Row(1)]
|
||||||
|
[Row(2)]
|
||||||
|
[Row(3)]
|
||||||
|
public void register_series_with_match(int matchPosition)
|
||||||
|
{
|
||||||
|
TvdbSeries fakeSeries = Builder<TvdbSeries>.CreateNew().With(f => f.SeriesName = "The Simpsons").Build();
|
||||||
|
var fakeSearch = Builder<TvdbSearchResult>.CreateListOfSize(4).Build();
|
||||||
|
fakeSearch[matchPosition].Id = fakeSeries.Id;
|
||||||
|
fakeSearch[matchPosition].SeriesName = fakeSeries.SeriesName;
|
||||||
|
|
||||||
|
|
||||||
|
//Arrange
|
||||||
|
var moqData = new Mock<IRepository>();
|
||||||
|
var moqTvdb = new Mock<ITvDbProvider>();
|
||||||
|
|
||||||
|
moqData.Setup(f => f.Exists<Series>(c => c.TvdbId == It.IsAny<long>())).Returns(false);
|
||||||
|
|
||||||
|
moqTvdb.Setup(f => f.SearchSeries(It.IsAny<String>())).Returns(fakeSearch);
|
||||||
|
moqTvdb.Setup(f => f.GetSeries(fakeSeries.Id, It.IsAny<TvdbLanguage>())).Returns(fakeSeries);
|
||||||
|
|
||||||
|
var kernel = new MockingKernel();
|
||||||
|
kernel.Bind<IRepository>().ToConstant(moqData.Object);
|
||||||
|
kernel.Bind<ITvDbProvider>().ToConstant(moqTvdb.Object);
|
||||||
|
kernel.Bind<ISeriesProvider>().To<SeriesProvider>();
|
||||||
|
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var seriesController = kernel.Get<ISeriesProvider>();
|
||||||
|
seriesController.RegisterSeries(@"D:\TV Shows\The Simpsons");
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
//Verify that the show was added to the database only once.
|
||||||
|
moqData.Verify(c => c.Add(It.Is<Series>(d => d.TvdbId == fakeSeries.Id)), Times.Once());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
[Description("This test confirms that the tvdb id stored in the db is preserved rather than being replaced by an auto incrementing value")]
|
[Description("This test confirms that the tvdb id stored in the db is preserved rather than being replaced by an auto incrementing value")]
|
||||||
public void tvdbid_is_preserved([RandomNumbers(Minimum = 100, Maximum = 999, Count = 1)] int tvdbId)
|
public void tvdbid_is_preserved([RandomNumbers(Minimum = 100, Maximum = 999, Count = 1)] int tvdbId)
|
||||||
{
|
{
|
||||||
|
@ -86,5 +125,26 @@ namespace NzbDrone.Core.Test
|
||||||
Assert.IsNotEmpty(allSeries);
|
Assert.IsNotEmpty(allSeries);
|
||||||
Assert.AreEqual(tvdbId, allSeries.First().TvdbId);
|
Assert.AreEqual(tvdbId, allSeries.First().TvdbId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[Row(new object[] { "CAPITAL", "capital", true })]
|
||||||
|
[Row(new object[] { "Something!!", "Something", true })]
|
||||||
|
[Row(new object[] { "Simpsons 2000", "Simpsons", true })]
|
||||||
|
[Row(new object[] { "Simp222sons", "Simpsons", true })]
|
||||||
|
[Row(new object[] { "Simpsons", "The Simpsons", true })]
|
||||||
|
[Row(new object[] { "Law and order", "Law & order", true })]
|
||||||
|
[Row(new object[] { "xxAndxx", "xxxx", false })]
|
||||||
|
[Row(new object[] { "Andxx", "xx", false })]
|
||||||
|
[Row(new object[] { "xxAnd", "xx", false })]
|
||||||
|
[Row(new object[] { "Thexx", "xx", false })]
|
||||||
|
[Row(new object[] { "Thexx", "xx", false })]
|
||||||
|
[Row(new object[] { "xxThexx", "xxxxx", false })]
|
||||||
|
[Row(new object[] { "Simpsons The", "Simpsons", true })]
|
||||||
|
public void Name_match_test(string a, string b, bool match)
|
||||||
|
{
|
||||||
|
bool result = SeriesProvider.IsTitleMatch(a, b);
|
||||||
|
|
||||||
|
Assert.AreEqual(match, result, "{0} , {1}", a, b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,432 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<doc>
|
||||||
|
<assembly>
|
||||||
|
<name>NLog.Extended</name>
|
||||||
|
</assembly>
|
||||||
|
<members>
|
||||||
|
<member name="T:NLog.LayoutRenderers.AspNetApplicationValueLayoutRenderer">
|
||||||
|
<summary>
|
||||||
|
ASP.NET Application variable.
|
||||||
|
</summary>
|
||||||
|
<remarks>
|
||||||
|
Use this layout renderer to insert the value of the specified variable stored
|
||||||
|
in the ASP.NET Application dictionary.
|
||||||
|
</remarks>
|
||||||
|
<example>
|
||||||
|
<para>You can set the value of an ASP.NET Application variable by using the following code:</para>
|
||||||
|
<code lang="C#">
|
||||||
|
<![CDATA[
|
||||||
|
HttpContext.Current.Application["myvariable"] = 123;
|
||||||
|
HttpContext.Current.Application["stringvariable"] = "aaa BBB";
|
||||||
|
HttpContext.Current.Application["anothervariable"] = DateTime.Now;
|
||||||
|
]]>
|
||||||
|
</code>
|
||||||
|
<para>Example usage of ${aspnet-application}:</para>
|
||||||
|
<code lang="NLog Layout Renderer">
|
||||||
|
${aspnet-application:variable=myvariable} - produces "123"
|
||||||
|
${aspnet-application:variable=anothervariable} - produces "01/01/2006 00:00:00"
|
||||||
|
${aspnet-application:variable=anothervariable:culture=pl-PL} - produces "2006-01-01 00:00:00"
|
||||||
|
${aspnet-application:variable=myvariable:padding=5} - produces " 123"
|
||||||
|
${aspnet-application:variable=myvariable:padding=-5} - produces "123 "
|
||||||
|
${aspnet-application:variable=stringvariable:upperCase=true} - produces "AAA BBB"
|
||||||
|
</code>
|
||||||
|
</example>
|
||||||
|
</member>
|
||||||
|
<member name="M:NLog.LayoutRenderers.AspNetApplicationValueLayoutRenderer.Append(System.Text.StringBuilder,NLog.LogEventInfo)">
|
||||||
|
<summary>
|
||||||
|
Renders the specified ASP.NET Application variable and appends it to the specified <see cref="T:System.Text.StringBuilder"/>.
|
||||||
|
</summary>
|
||||||
|
<param name="builder">The <see cref="T:System.Text.StringBuilder"/> to append the rendered data to.</param>
|
||||||
|
<param name="logEvent">Logging event.</param>
|
||||||
|
</member>
|
||||||
|
<member name="P:NLog.LayoutRenderers.AspNetApplicationValueLayoutRenderer.Variable">
|
||||||
|
<summary>
|
||||||
|
Gets or sets the variable name.
|
||||||
|
</summary>
|
||||||
|
<docgen category='Rendering Options' order='10' />
|
||||||
|
</member>
|
||||||
|
<member name="T:NLog.LayoutRenderers.AspNetRequestValueLayoutRenderer">
|
||||||
|
<summary>
|
||||||
|
ASP.NET Request variable.
|
||||||
|
</summary>
|
||||||
|
<remarks>
|
||||||
|
Use this layout renderer to insert the value of the specified parameter of the
|
||||||
|
ASP.NET Request object.
|
||||||
|
</remarks>
|
||||||
|
<example>
|
||||||
|
<para>Example usage of ${aspnet-request}:</para>
|
||||||
|
<code lang="NLog Layout Renderer">
|
||||||
|
${aspnet-request:item=v}
|
||||||
|
${aspnet-request:querystring=v}
|
||||||
|
${aspnet-request:form=v}
|
||||||
|
${aspnet-request:cookie=v}
|
||||||
|
${aspnet-request:serverVariable=v}
|
||||||
|
</code>
|
||||||
|
</example>
|
||||||
|
</member>
|
||||||
|
<member name="M:NLog.LayoutRenderers.AspNetRequestValueLayoutRenderer.Append(System.Text.StringBuilder,NLog.LogEventInfo)">
|
||||||
|
<summary>
|
||||||
|
Renders the specified ASP.NET Request variable and appends it to the specified <see cref="T:System.Text.StringBuilder"/>.
|
||||||
|
</summary>
|
||||||
|
<param name="builder">The <see cref="T:System.Text.StringBuilder"/> to append the rendered data to.</param>
|
||||||
|
<param name="logEvent">Logging event.</param>
|
||||||
|
</member>
|
||||||
|
<member name="P:NLog.LayoutRenderers.AspNetRequestValueLayoutRenderer.Item">
|
||||||
|
<summary>
|
||||||
|
Gets or sets the item name. The QueryString, Form, Cookies, or ServerVariables collection variables having the specified name are rendered.
|
||||||
|
</summary>
|
||||||
|
<docgen category='Rendering Options' order='10' />
|
||||||
|
</member>
|
||||||
|
<member name="P:NLog.LayoutRenderers.AspNetRequestValueLayoutRenderer.QueryString">
|
||||||
|
<summary>
|
||||||
|
Gets or sets the QueryString variable to be rendered.
|
||||||
|
</summary>
|
||||||
|
<docgen category='Rendering Options' order='10' />
|
||||||
|
</member>
|
||||||
|
<member name="P:NLog.LayoutRenderers.AspNetRequestValueLayoutRenderer.Form">
|
||||||
|
<summary>
|
||||||
|
Gets or sets the form variable to be rendered.
|
||||||
|
</summary>
|
||||||
|
<docgen category='Rendering Options' order='10' />
|
||||||
|
</member>
|
||||||
|
<member name="P:NLog.LayoutRenderers.AspNetRequestValueLayoutRenderer.Cookie">
|
||||||
|
<summary>
|
||||||
|
Gets or sets the cookie to be rendered.
|
||||||
|
</summary>
|
||||||
|
<docgen category='Rendering Options' order='10' />
|
||||||
|
</member>
|
||||||
|
<member name="P:NLog.LayoutRenderers.AspNetRequestValueLayoutRenderer.ServerVariable">
|
||||||
|
<summary>
|
||||||
|
Gets or sets the ServerVariables item to be rendered.
|
||||||
|
</summary>
|
||||||
|
<docgen category='Rendering Options' order='10' />
|
||||||
|
</member>
|
||||||
|
<member name="T:NLog.LayoutRenderers.AspNetSessionIDLayoutRenderer">
|
||||||
|
<summary>
|
||||||
|
ASP.NET Session ID.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:NLog.LayoutRenderers.AspNetSessionIDLayoutRenderer.Append(System.Text.StringBuilder,NLog.LogEventInfo)">
|
||||||
|
<summary>
|
||||||
|
Renders the ASP.NET Session ID appends it to the specified <see cref="T:System.Text.StringBuilder"/>.
|
||||||
|
</summary>
|
||||||
|
<param name="builder">The <see cref="T:System.Text.StringBuilder"/> to append the rendered data to.</param>
|
||||||
|
<param name="logEvent">Logging event.</param>
|
||||||
|
</member>
|
||||||
|
<member name="T:NLog.LayoutRenderers.AspNetSessionValueLayoutRenderer">
|
||||||
|
<summary>
|
||||||
|
ASP.NET Session variable.
|
||||||
|
</summary>
|
||||||
|
<remarks>
|
||||||
|
Use this layout renderer to insert the value of the specified variable stored
|
||||||
|
in the ASP.NET Session dictionary.
|
||||||
|
</remarks>
|
||||||
|
<example>
|
||||||
|
<para>You can set the value of an ASP.NET Session variable by using the following code:</para>
|
||||||
|
<code lang="C#">
|
||||||
|
<![CDATA[
|
||||||
|
HttpContext.Current.Session["myvariable"] = 123;
|
||||||
|
HttpContext.Current.Session["stringvariable"] = "aaa BBB";
|
||||||
|
HttpContext.Current.Session["anothervariable"] = DateTime.Now;
|
||||||
|
]]>
|
||||||
|
</code>
|
||||||
|
<para>Example usage of ${aspnet-session}:</para>
|
||||||
|
<code lang="NLog Layout Renderer">
|
||||||
|
${aspnet-session:variable=myvariable} - produces "123"
|
||||||
|
${aspnet-session:variable=anothervariable} - produces "01/01/2006 00:00:00"
|
||||||
|
${aspnet-session:variable=anothervariable:culture=pl-PL} - produces "2006-01-01 00:00:00"
|
||||||
|
${aspnet-session:variable=myvariable:padding=5} - produces " 123"
|
||||||
|
${aspnet-session:variable=myvariable:padding=-5} - produces "123 "
|
||||||
|
${aspnet-session:variable=stringvariable:upperCase=true} - produces "AAA BBB"
|
||||||
|
</code>
|
||||||
|
</example>
|
||||||
|
</member>
|
||||||
|
<member name="M:NLog.LayoutRenderers.AspNetSessionValueLayoutRenderer.Append(System.Text.StringBuilder,NLog.LogEventInfo)">
|
||||||
|
<summary>
|
||||||
|
Renders the specified ASP.NET Session value and appends it to the specified <see cref="T:System.Text.StringBuilder"/>.
|
||||||
|
</summary>
|
||||||
|
<param name="builder">The <see cref="T:System.Text.StringBuilder"/> to append the rendered data to.</param>
|
||||||
|
<param name="logEvent">Logging event.</param>
|
||||||
|
</member>
|
||||||
|
<member name="P:NLog.LayoutRenderers.AspNetSessionValueLayoutRenderer.Variable">
|
||||||
|
<summary>
|
||||||
|
Gets or sets the session variable name.
|
||||||
|
</summary>
|
||||||
|
<docgen category='Rendering Options' order='10' />
|
||||||
|
</member>
|
||||||
|
<member name="T:NLog.LayoutRenderers.AspNetUserAuthTypeLayoutRenderer">
|
||||||
|
<summary>
|
||||||
|
ASP.NET User variable.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:NLog.LayoutRenderers.AspNetUserAuthTypeLayoutRenderer.Append(System.Text.StringBuilder,NLog.LogEventInfo)">
|
||||||
|
<summary>
|
||||||
|
Renders the specified ASP.NET User.Identity.AuthenticationType variable and appends it to the specified <see cref="T:System.Text.StringBuilder"/>.
|
||||||
|
</summary>
|
||||||
|
<param name="builder">The <see cref="T:System.Text.StringBuilder"/> to append the rendered data to.</param>
|
||||||
|
<param name="logEvent">Logging event.</param>
|
||||||
|
</member>
|
||||||
|
<member name="T:NLog.LayoutRenderers.AspNetUserIdentityLayoutRenderer">
|
||||||
|
<summary>
|
||||||
|
ASP.NET User variable.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:NLog.LayoutRenderers.AspNetUserIdentityLayoutRenderer.Append(System.Text.StringBuilder,NLog.LogEventInfo)">
|
||||||
|
<summary>
|
||||||
|
Renders the specified ASP.NET User.Identity.Name variable and appends it to the specified <see cref="T:System.Text.StringBuilder"/>.
|
||||||
|
</summary>
|
||||||
|
<param name="builder">The <see cref="T:System.Text.StringBuilder"/> to append the rendered data to.</param>
|
||||||
|
<param name="logEvent">Logging event.</param>
|
||||||
|
</member>
|
||||||
|
<member name="T:NLog.Targets.AspNetTraceTarget">
|
||||||
|
<summary>
|
||||||
|
Writes log messages to the ASP.NET trace.
|
||||||
|
</summary>
|
||||||
|
<seealso href="http://nlog-project.org/wiki/AspNetTrace_target">Documentation on NLog Wiki</seealso>
|
||||||
|
<remarks>
|
||||||
|
Log entries can then be viewed by navigating to http://server/path/Trace.axd.
|
||||||
|
</remarks>
|
||||||
|
</member>
|
||||||
|
<member name="M:NLog.Targets.AspNetTraceTarget.Write(NLog.LogEventInfo)">
|
||||||
|
<summary>
|
||||||
|
Writes the specified logging event to the ASP.NET Trace facility.
|
||||||
|
If the log level is greater than or equal to <see cref="F:NLog.LogLevel.Warn"/> it uses the
|
||||||
|
<see cref="M:System.Web.TraceContext.Warn(System.String,System.String)"/> method, otherwise it uses
|
||||||
|
<see cref="M:System.Web.TraceContext.Write(System.String,System.String)"/> method.
|
||||||
|
</summary>
|
||||||
|
<param name="logEvent">The logging event.</param>
|
||||||
|
</member>
|
||||||
|
<member name="T:NLog.Targets.MessageQueueTarget">
|
||||||
|
<summary>
|
||||||
|
Writes log message to the specified message queue handled by MSMQ.
|
||||||
|
</summary>
|
||||||
|
<seealso href="http://nlog-project.org/wiki/MessageQueue_target">Documentation on NLog Wiki</seealso>
|
||||||
|
<example>
|
||||||
|
<p>
|
||||||
|
To set up the target in the <a href="config.html">configuration file</a>,
|
||||||
|
use the following syntax:
|
||||||
|
</p>
|
||||||
|
<code lang="XML" source="examples/targets/Configuration File/MSMQ/Simple/NLog.config" />
|
||||||
|
<p>
|
||||||
|
You can use a single target to write to multiple queues (similar to writing to multiple files with the File target).
|
||||||
|
</p>
|
||||||
|
<code lang="XML" source="examples/targets/Configuration File/MSMQ/Multiple/NLog.config" />
|
||||||
|
<p>
|
||||||
|
The above examples assume just one target and a single rule.
|
||||||
|
More configuration options are described <a href="config.html">here</a>.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
To set up the log target programmatically use code like this:
|
||||||
|
</p>
|
||||||
|
<code lang="C#" source="examples/targets/Configuration API/MSMQ/Simple/Example.cs" />
|
||||||
|
</example>
|
||||||
|
</member>
|
||||||
|
<member name="M:NLog.Targets.MessageQueueTarget.#ctor">
|
||||||
|
<summary>
|
||||||
|
Initializes a new instance of the <see cref="T:NLog.Targets.MessageQueueTarget"/> class.
|
||||||
|
</summary>
|
||||||
|
<remarks>
|
||||||
|
The default value of the layout is: <code>${longdate}|${level:uppercase=true}|${logger}|${message}</code>
|
||||||
|
</remarks>
|
||||||
|
</member>
|
||||||
|
<member name="M:NLog.Targets.MessageQueueTarget.Write(NLog.LogEventInfo)">
|
||||||
|
<summary>
|
||||||
|
Writes the specified logging event to a queue specified in the Queue
|
||||||
|
parameter.
|
||||||
|
</summary>
|
||||||
|
<param name="logEvent">The logging event.</param>
|
||||||
|
</member>
|
||||||
|
<member name="M:NLog.Targets.MessageQueueTarget.PrepareMessage(NLog.LogEventInfo)">
|
||||||
|
<summary>
|
||||||
|
Prepares a message to be sent to the message queue.
|
||||||
|
</summary>
|
||||||
|
<param name="logEvent">The log event to be used when calculating label and text to be written.</param>
|
||||||
|
<returns>The message to be sent.</returns>
|
||||||
|
<remarks>
|
||||||
|
You may override this method in inheriting classes
|
||||||
|
to provide services like encryption or message
|
||||||
|
authentication.
|
||||||
|
</remarks>
|
||||||
|
</member>
|
||||||
|
<member name="P:NLog.Targets.MessageQueueTarget.Queue">
|
||||||
|
<summary>
|
||||||
|
Gets or sets the name of the queue to write to.
|
||||||
|
</summary>
|
||||||
|
<remarks>
|
||||||
|
To write to a private queue on a local machine use <c>.\private$\QueueName</c>.
|
||||||
|
For other available queue names, consult MSMQ documentation.
|
||||||
|
</remarks>
|
||||||
|
<docgen category='Queue Options' order='10' />
|
||||||
|
</member>
|
||||||
|
<member name="P:NLog.Targets.MessageQueueTarget.Label">
|
||||||
|
<summary>
|
||||||
|
Gets or sets the label to associate with each message.
|
||||||
|
</summary>
|
||||||
|
<remarks>
|
||||||
|
By default no label is associated.
|
||||||
|
</remarks>
|
||||||
|
<docgen category='Queue Options' order='10' />
|
||||||
|
</member>
|
||||||
|
<member name="P:NLog.Targets.MessageQueueTarget.CreateQueueIfNotExists">
|
||||||
|
<summary>
|
||||||
|
Gets or sets a value indicating whether to create the queue if it doesn't exists.
|
||||||
|
</summary>
|
||||||
|
<docgen category='Queue Options' order='10' />
|
||||||
|
</member>
|
||||||
|
<member name="P:NLog.Targets.MessageQueueTarget.Recoverable">
|
||||||
|
<summary>
|
||||||
|
Gets or sets a value indicating whether to use recoverable messages (with guaranteed delivery).
|
||||||
|
</summary>
|
||||||
|
<docgen category='Queue Options' order='10' />
|
||||||
|
</member>
|
||||||
|
<member name="P:NLog.Targets.MessageQueueTarget.Encoding">
|
||||||
|
<summary>
|
||||||
|
Gets or sets the encoding to be used when writing text to the queue.
|
||||||
|
</summary>
|
||||||
|
<docgen category='Layout Options' order='10' />
|
||||||
|
</member>
|
||||||
|
<member name="P:NLog.Targets.MessageQueueTarget.UseXmlEncoding">
|
||||||
|
<summary>
|
||||||
|
Gets or sets a value indicating whether to use the XML format when serializing message.
|
||||||
|
</summary>
|
||||||
|
<docgen category='Layout Options' order='10' />
|
||||||
|
</member>
|
||||||
|
<member name="T:NLog.Targets.Wrappers.AspNetBufferingTargetWrapper">
|
||||||
|
<summary>
|
||||||
|
Buffers log events for the duration of ASP.NET request and sends them down
|
||||||
|
to the wrapped target at the end of a request.
|
||||||
|
</summary>
|
||||||
|
<seealso href="http://nlog-project.org/wiki/AspNetBufferingWrapper_target">Documentation on NLog Wiki</seealso>
|
||||||
|
<remarks>
|
||||||
|
<p>
|
||||||
|
Typically this target is used in cooperation with PostFilteringTargetWrapper
|
||||||
|
to provide verbose logging for failing requests and normal or no logging for
|
||||||
|
successful requests. We need to make the decision of the final filtering rule
|
||||||
|
to apply after all logs for a page have been generated.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
To use this target, you need to add an entry in the httpModules section of
|
||||||
|
web.config:
|
||||||
|
</p>
|
||||||
|
<code lang="XML">
|
||||||
|
<![CDATA[<?xml version="1.0" ?>
|
||||||
|
<configuration>
|
||||||
|
<system.web>
|
||||||
|
<httpModules>
|
||||||
|
<add name="NLog" type="NLog.Web.NLogHttpModule, NLog"/>
|
||||||
|
</httpModules>
|
||||||
|
</system.web>
|
||||||
|
</configuration>
|
||||||
|
]]>
|
||||||
|
</code>
|
||||||
|
</remarks>
|
||||||
|
<example>
|
||||||
|
<p>To set up the ASP.NET Buffering target wrapper <a href="config.html">configuration file</a>, put
|
||||||
|
the following in <c>web.nlog</c> file in your web application directory (this assumes
|
||||||
|
that PostFilteringWrapper is used to provide the filtering and actual logs go to
|
||||||
|
a file).
|
||||||
|
</p>
|
||||||
|
<code lang="XML" source="examples/targets/Configuration File/ASPNetBufferingWrapper/web.nlog" />
|
||||||
|
<p>
|
||||||
|
This assumes just one target and a single rule. More configuration
|
||||||
|
options are described <a href="config.html">here</a>.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
To configure the target programmatically, put the following
|
||||||
|
piece of code in your <c>Application_OnStart()</c> handler in Global.asax.cs
|
||||||
|
or some other place that gets executed at the very beginning of your code:
|
||||||
|
</p>
|
||||||
|
<code lang="C#" source="examples/targets/Configuration API/ASPNetBufferingWrapper/Global.asax.cs" />
|
||||||
|
<p>
|
||||||
|
Fully working C# project can be found in the <c>Examples/Targets/Configuration API/ASPNetBufferingWrapper</c>
|
||||||
|
directory along with usage instructions.
|
||||||
|
</p>
|
||||||
|
</example>
|
||||||
|
</member>
|
||||||
|
<member name="M:NLog.Targets.Wrappers.AspNetBufferingTargetWrapper.#ctor">
|
||||||
|
<summary>
|
||||||
|
Initializes a new instance of the <see cref="T:NLog.Targets.Wrappers.AspNetBufferingTargetWrapper"/> class.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:NLog.Targets.Wrappers.AspNetBufferingTargetWrapper.#ctor(NLog.Targets.Target)">
|
||||||
|
<summary>
|
||||||
|
Initializes a new instance of the <see cref="T:NLog.Targets.Wrappers.AspNetBufferingTargetWrapper"/> class.
|
||||||
|
</summary>
|
||||||
|
<param name="wrappedTarget">The wrapped target.</param>
|
||||||
|
</member>
|
||||||
|
<member name="M:NLog.Targets.Wrappers.AspNetBufferingTargetWrapper.#ctor(NLog.Targets.Target,System.Int32)">
|
||||||
|
<summary>
|
||||||
|
Initializes a new instance of the <see cref="T:NLog.Targets.Wrappers.AspNetBufferingTargetWrapper"/> class.
|
||||||
|
</summary>
|
||||||
|
<param name="wrappedTarget">The wrapped target.</param>
|
||||||
|
<param name="bufferSize">Size of the buffer.</param>
|
||||||
|
</member>
|
||||||
|
<member name="M:NLog.Targets.Wrappers.AspNetBufferingTargetWrapper.InitializeTarget">
|
||||||
|
<summary>
|
||||||
|
Initializes the target by hooking up the NLogHttpModule BeginRequest and EndRequest events.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:NLog.Targets.Wrappers.AspNetBufferingTargetWrapper.CloseTarget">
|
||||||
|
<summary>
|
||||||
|
Closes the target by flushing pending events in the buffer (if any).
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:NLog.Targets.Wrappers.AspNetBufferingTargetWrapper.Write(NLog.Common.AsyncLogEventInfo)">
|
||||||
|
<summary>
|
||||||
|
Adds the specified log event to the buffer.
|
||||||
|
</summary>
|
||||||
|
<param name="logEvent">The log event.</param>
|
||||||
|
</member>
|
||||||
|
<member name="P:NLog.Targets.Wrappers.AspNetBufferingTargetWrapper.BufferSize">
|
||||||
|
<summary>
|
||||||
|
Gets or sets the number of log events to be buffered.
|
||||||
|
</summary>
|
||||||
|
<docgen category='Buffering Options' order='100' />
|
||||||
|
</member>
|
||||||
|
<member name="P:NLog.Targets.Wrappers.AspNetBufferingTargetWrapper.GrowBufferAsNeeded">
|
||||||
|
<summary>
|
||||||
|
Gets or sets a value indicating whether buffer should grow as needed.
|
||||||
|
</summary>
|
||||||
|
<value>A value of <c>true</c> if buffer should grow as needed; otherwise, <c>false</c>.</value>
|
||||||
|
<remarks>
|
||||||
|
Value of <c>true</c> causes the buffer to expand until <see cref="P:NLog.Targets.Wrappers.AspNetBufferingTargetWrapper.BufferGrowLimit"/> is hit,
|
||||||
|
<c>false</c> causes the buffer to never expand and lose the earliest entries in case of overflow.
|
||||||
|
</remarks>
|
||||||
|
<docgen category="Buffering Options" order="100"/>
|
||||||
|
</member>
|
||||||
|
<member name="P:NLog.Targets.Wrappers.AspNetBufferingTargetWrapper.BufferGrowLimit">
|
||||||
|
<summary>
|
||||||
|
Gets or sets the maximum number of log events that the buffer can keep.
|
||||||
|
</summary>
|
||||||
|
<docgen category='Buffering Options' order='100' />
|
||||||
|
</member>
|
||||||
|
<member name="T:NLog.Web.NLogHttpModule">
|
||||||
|
<summary>
|
||||||
|
ASP.NET HttpModule that enables NLog to hook BeginRequest and EndRequest events easily.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:NLog.Web.NLogHttpModule.Init(System.Web.HttpApplication)">
|
||||||
|
<summary>
|
||||||
|
Initializes the HttpModule.
|
||||||
|
</summary>
|
||||||
|
<param name="application">
|
||||||
|
ASP.NET application.
|
||||||
|
</param>
|
||||||
|
</member>
|
||||||
|
<member name="M:NLog.Web.NLogHttpModule.Dispose">
|
||||||
|
<summary>
|
||||||
|
Disposes the module.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="E:NLog.Web.NLogHttpModule.EndRequest">
|
||||||
|
<summary>
|
||||||
|
Event to be raised at the end of each HTTP Request.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="E:NLog.Web.NLogHttpModule.BeginRequest">
|
||||||
|
<summary>
|
||||||
|
Event to be raised at the beginning of each HTTP Request.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
</members>
|
||||||
|
</doc>
|
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -1,11 +1,13 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using log4net;
|
|
||||||
using Ninject;
|
using Ninject;
|
||||||
|
using NLog.Config;
|
||||||
|
using NLog.Targets;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using SubSonic.DataProviders;
|
using SubSonic.DataProviders;
|
||||||
using SubSonic.Repository;
|
using SubSonic.Repository;
|
||||||
|
using NLog;
|
||||||
|
|
||||||
namespace NzbDrone.Core
|
namespace NzbDrone.Core
|
||||||
{
|
{
|
||||||
|
@ -20,7 +22,7 @@ namespace NzbDrone.Core
|
||||||
kernel.Bind<IDiskProvider>().To<DiskProvider>();
|
kernel.Bind<IDiskProvider>().To<DiskProvider>();
|
||||||
kernel.Bind<ITvDbProvider>().To<TvDbProvider>();
|
kernel.Bind<ITvDbProvider>().To<TvDbProvider>();
|
||||||
kernel.Bind<IConfigProvider>().To<ConfigProvider>();
|
kernel.Bind<IConfigProvider>().To<ConfigProvider>();
|
||||||
kernel.Bind<ILog>().ToMethod(c => LogManager.GetLogger("logger-name"));
|
kernel.Bind<log4net.ILog>().ToMethod(c => log4net.LogManager.GetLogger("logger-name"));
|
||||||
kernel.Bind<IRepository>().ToMethod(c => new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations));
|
kernel.Bind<IRepository>().ToMethod(c => new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,5 +30,42 @@ namespace NzbDrone.Core
|
||||||
{
|
{
|
||||||
get { return new DirectoryInfo(HttpContext.Current.Server.MapPath("\\")).Parent.FullName; }
|
get { return new DirectoryInfo(HttpContext.Current.Server.MapPath("\\")).Parent.FullName; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void ConfigureNlog()
|
||||||
|
{
|
||||||
|
// Step 1. Create configuration object
|
||||||
|
var config = new LoggingConfiguration();
|
||||||
|
|
||||||
|
// Step 2. Create targets and add them to the configuration
|
||||||
|
var consoleTarget = new DebuggerTarget();
|
||||||
|
config.AddTarget("console", consoleTarget);
|
||||||
|
|
||||||
|
FileTarget fileTarget = new FileTarget();
|
||||||
|
config.AddTarget("file", fileTarget);
|
||||||
|
|
||||||
|
// Step 3. Set target properties
|
||||||
|
consoleTarget.Layout = "${logger} ${message}";
|
||||||
|
fileTarget.FileName = "${basedir}/test.log";
|
||||||
|
fileTarget.Layout = "${message}";
|
||||||
|
|
||||||
|
// Step 4. Define rules
|
||||||
|
LoggingRule rule1 = new LoggingRule("*", LogLevel.Trace, consoleTarget);
|
||||||
|
config.LoggingRules.Add(rule1);
|
||||||
|
|
||||||
|
LoggingRule rule2 = new LoggingRule("*", LogLevel.Trace, fileTarget);
|
||||||
|
config.LoggingRules.Add(rule2);
|
||||||
|
|
||||||
|
// Step 5. Activate the configuration
|
||||||
|
NLog.LogManager.Configuration = config;
|
||||||
|
|
||||||
|
Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
logger.Trace("trace log message");
|
||||||
|
logger.Debug("debug log message");
|
||||||
|
logger.Info("info log message");
|
||||||
|
logger.Warn("warn log message");
|
||||||
|
logger.Error("error log message");
|
||||||
|
logger.Fatal("fatal log message");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -128,6 +128,10 @@
|
||||||
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL" />
|
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL" />
|
||||||
<Reference Include="Ninject, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL" />
|
<Reference Include="Ninject, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL" />
|
||||||
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL" />
|
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL" />
|
||||||
|
<Reference Include="NLog.Extended, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>Libraries\NLog.Extended.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="SubSonic.Core, Version=3.0.1.3, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="SubSonic.Core, Version=3.0.1.3, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>Libraries\SubSonic.Core.dll</HintPath>
|
<HintPath>Libraries\SubSonic.Core.dll</HintPath>
|
||||||
|
@ -202,6 +206,9 @@
|
||||||
<Content Include="Libraries\Ninject.Web.Mvc.pdb" />
|
<Content Include="Libraries\Ninject.Web.Mvc.pdb" />
|
||||||
<Content Include="Libraries\Ninject.xml" />
|
<Content Include="Libraries\Ninject.xml" />
|
||||||
<Content Include="Libraries\NLog.dll" />
|
<Content Include="Libraries\NLog.dll" />
|
||||||
|
<Content Include="Libraries\NLog.Extended.dll" />
|
||||||
|
<Content Include="Libraries\NLog.Extended.pdb" />
|
||||||
|
<Content Include="Libraries\NLog.Extended.xml" />
|
||||||
<Content Include="Libraries\NLog.pdb" />
|
<Content Include="Libraries\NLog.pdb" />
|
||||||
<Content Include="Libraries\NLog.xml" />
|
<Content Include="Libraries\NLog.xml" />
|
||||||
<Content Include="Libraries\SubSonic.Core.dll" />
|
<Content Include="Libraries\SubSonic.Core.dll" />
|
||||||
|
@ -212,9 +219,6 @@
|
||||||
<Content Include="Libraries\TvdbLib.pdb" />
|
<Content Include="Libraries\TvdbLib.pdb" />
|
||||||
<Content Include="Libraries\TvdbLib.XML" />
|
<Content Include="Libraries\TvdbLib.XML" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<None Include="nzbdrone.db" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
|
using TvdbLib.Data;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Providers
|
namespace NzbDrone.Core.Providers
|
||||||
{
|
{
|
||||||
|
@ -23,5 +25,9 @@ namespace NzbDrone.Core.Providers
|
||||||
/// <param name="id">The TVDB ID of the series</param>
|
/// <param name="id">The TVDB ID of the series</param>
|
||||||
/// <returns>Whether or not the show is monitored</returns>
|
/// <returns>Whether or not the show is monitored</returns>
|
||||||
bool IsMonitored(long id);
|
bool IsMonitored(long id);
|
||||||
|
|
||||||
|
bool RegisterSeries(string path);
|
||||||
|
void RegisterSeries(string path, TvdbSeries series);
|
||||||
|
List<String> GetUnmappedFolders();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
using NLog;
|
||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
using SubSonic.Repository;
|
using SubSonic.Repository;
|
||||||
using TvdbLib.Data;
|
using TvdbLib.Data;
|
||||||
|
@ -13,6 +14,8 @@ namespace NzbDrone.Core.Providers
|
||||||
public class SeriesProvider : ISeriesProvider
|
public class SeriesProvider : ISeriesProvider
|
||||||
{
|
{
|
||||||
//TODO: Remove parsing of rest of tv show info we just need the show name
|
//TODO: Remove parsing of rest of tv show info we just need the show name
|
||||||
|
|
||||||
|
private static readonly Regex CleanUpRegex = new Regex(@"((\s|^)the(\s|$))|((\s|^)and(\s|$))|[^a-z]", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||||
private static readonly Regex ParseRegex = new Regex(@"(?<showName>.*)
|
private static readonly Regex ParseRegex = new Regex(@"(?<showName>.*)
|
||||||
(?:
|
(?:
|
||||||
s(?<seasonNumber>\d+)e(?<episodeNumber>\d+)-?e(?<episodeNumber2>\d+)
|
s(?<seasonNumber>\d+)e(?<episodeNumber>\d+)-?e(?<episodeNumber2>\d+)
|
||||||
|
@ -28,15 +31,16 @@ namespace NzbDrone.Core.Providers
|
||||||
| (?<episodeName>.*)
|
| (?<episodeName>.*)
|
||||||
)", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace);
|
)", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private readonly IConfigProvider _config;
|
private readonly IConfigProvider _config;
|
||||||
private readonly IDiskProvider _diskProvider;
|
private readonly IDiskProvider _diskProvider;
|
||||||
private readonly ILog _logger;
|
|
||||||
private readonly IRepository _sonioRepo;
|
private readonly IRepository _sonioRepo;
|
||||||
private readonly ITvDbProvider _tvDb;
|
private readonly ITvDbProvider _tvDb;
|
||||||
|
private static readonly Logger Logger = NLog.LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public SeriesProvider(ILog logger, IDiskProvider diskProvider, IConfigProvider configProvider, IRepository dataRepository, ITvDbProvider tvDbProvider)
|
public SeriesProvider(IDiskProvider diskProvider, IConfigProvider configProvider, IRepository dataRepository, ITvDbProvider tvDbProvider)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
_config = configProvider;
|
_config = configProvider;
|
||||||
_sonioRepo = dataRepository;
|
_sonioRepo = dataRepository;
|
||||||
|
@ -55,46 +59,14 @@ namespace NzbDrone.Core.Providers
|
||||||
return _sonioRepo.Single<Series>(s => s.TvdbId == tvdbId);
|
return _sonioRepo.Single<Series>(s => s.TvdbId == tvdbId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IList<Season> GetSeasons(long tvdbId)
|
/// <summary>
|
||||||
|
/// Determines if a series is being actively watched.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">The TVDB ID of the series</param>
|
||||||
|
/// <returns>Whether or not the show is monitored</returns>
|
||||||
|
public bool IsMonitored(long id)
|
||||||
{
|
{
|
||||||
return _sonioRepo.Find<Season>(c => c.SeriesId == tvdbId);
|
return _sonioRepo.Exists<Series>(c => c.TvdbId == id && c.Monitored);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void SyncSeriesWithDisk()
|
|
||||||
{
|
|
||||||
foreach (string seriesFolder in _diskProvider.GetDirectories(_config.SeriesRoot))
|
|
||||||
{
|
|
||||||
var cleanPath = DiskProvider.CleanPath(new DirectoryInfo(seriesFolder).FullName);
|
|
||||||
if (!_sonioRepo.Exists<Series>(s => s.Path == cleanPath))
|
|
||||||
{
|
|
||||||
_logger.InfoFormat("Folder '{0} isn't mapped to a series in the database. Trying to map it.'", cleanPath);
|
|
||||||
AddShow(cleanPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private void AddShow(string path)
|
|
||||||
{
|
|
||||||
var searchResults = _tvDb.SearchSeries(new DirectoryInfo(path).Name);
|
|
||||||
if (searchResults.Count != 0 && !_sonioRepo.Exists<Series>(s => s.TvdbId == searchResults[0].Id))
|
|
||||||
AddShow(path, _tvDb.GetSeries(searchResults[0].Id, searchResults[0].Language));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AddShow(string path, TvdbSeries series)
|
|
||||||
{
|
|
||||||
var repoSeries = new Series();
|
|
||||||
repoSeries.TvdbId = series.Id;
|
|
||||||
repoSeries.SeriesName = series.SeriesName;
|
|
||||||
repoSeries.AirTimes = series.AirsTime;
|
|
||||||
repoSeries.AirsDayOfWeek = series.AirsDayOfWeek;
|
|
||||||
repoSeries.Overview = series.Overview;
|
|
||||||
repoSeries.Status = series.Status;
|
|
||||||
repoSeries.Language = series.Language != null ? series.Language.Abbriviation : string.Empty;
|
|
||||||
repoSeries.Path = path;
|
|
||||||
_sonioRepo.Add(repoSeries);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -114,15 +86,108 @@ namespace NzbDrone.Core.Providers
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public void SyncSeriesWithDisk()
|
||||||
/// Determines if a series is being actively watched.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id">The TVDB ID of the series</param>
|
|
||||||
/// <returns>Whether or not the show is monitored</returns>
|
|
||||||
public bool IsMonitored(long id)
|
|
||||||
{
|
{
|
||||||
//should just check the db for now, if it exists its being monitored.
|
if (String.IsNullOrEmpty(_config.SeriesRoot))
|
||||||
throw new NotImplementedException();
|
throw new InvalidOperationException("TV Series folder is not configured yet.");
|
||||||
|
|
||||||
|
foreach (string seriesFolder in GetUnmappedFolders())
|
||||||
|
{
|
||||||
|
Logger.Info("Folder '{0}' isn't mapped to a series in the database. Trying to map it.'", seriesFolder);
|
||||||
|
RegisterSeries(seriesFolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> GetUnmappedFolders()
|
||||||
|
{
|
||||||
|
var results = new List<String>();
|
||||||
|
foreach (string seriesFolder in _diskProvider.GetDirectories(_config.SeriesRoot))
|
||||||
|
{
|
||||||
|
var cleanPath = DiskProvider.CleanPath(new DirectoryInfo(seriesFolder).FullName);
|
||||||
|
if (!_sonioRepo.Exists<Series>(s => s.Path == cleanPath))
|
||||||
|
{
|
||||||
|
results.Add(cleanPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool RegisterSeries(string path)
|
||||||
|
{
|
||||||
|
var seriesPath = new DirectoryInfo(path);
|
||||||
|
var searchResults = _tvDb.SearchSeries(seriesPath.Name);
|
||||||
|
Logger.Debug("Search for '{0}' returned {1} results", searchResults.Count);
|
||||||
|
|
||||||
|
if (searchResults.Count == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
foreach (var tvdbSearchResult in searchResults)
|
||||||
|
{
|
||||||
|
TvdbSearchResult result = tvdbSearchResult;
|
||||||
|
if (IsTitleMatch(seriesPath.Name, result.SeriesName) && !_sonioRepo.Exists<Series>(c => c.TvdbId == result.Id))
|
||||||
|
{
|
||||||
|
RegisterSeries(path, _tvDb.GetSeries(result.Id, result.Language));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.Info("Unable to fine a match for {0}", seriesPath.Name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void RegisterSeries(string path, TvdbSeries series)
|
||||||
|
{
|
||||||
|
Logger.Info("registering '{0}' with [{1}]-{2}", path, series.Id, series.SeriesName);
|
||||||
|
var repoSeries = new Series();
|
||||||
|
repoSeries.TvdbId = series.Id;
|
||||||
|
repoSeries.Title = series.SeriesName;
|
||||||
|
repoSeries.AirTimes = series.AirsTime;
|
||||||
|
repoSeries.AirsDayOfWeek = series.AirsDayOfWeek;
|
||||||
|
repoSeries.Overview = series.Overview;
|
||||||
|
repoSeries.Status = series.Status;
|
||||||
|
repoSeries.Language = series.Language != null ? series.Language.Abbriviation : string.Empty;
|
||||||
|
repoSeries.Path = path;
|
||||||
|
repoSeries.CleanTitle = CleanUpRegex.Replace(series.SeriesName, "").ToLower();
|
||||||
|
_sonioRepo.Add(repoSeries);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Static Helpers
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether a title in a search result is equal to the title searched for.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="directoryName">Name of the directory.</param>
|
||||||
|
/// <param name="tvdbTitle">The TVDB title.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// <c>true</c> if the titles are found to be same; otherwise, <c>false</c>.
|
||||||
|
/// </returns>
|
||||||
|
public static bool IsTitleMatch(string directoryName, string tvdbTitle)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var result = false;
|
||||||
|
|
||||||
|
if (String.IsNullOrEmpty(directoryName))
|
||||||
|
throw new ArgumentException("directoryName");
|
||||||
|
if (String.IsNullOrEmpty(tvdbTitle))
|
||||||
|
throw new ArgumentException("tvdbTitle");
|
||||||
|
|
||||||
|
if (String.Equals(directoryName, tvdbTitle, StringComparison.CurrentCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
else if (String.Equals(CleanUpRegex.Replace(directoryName, ""), CleanUpRegex.Replace(tvdbTitle, ""), StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
result = true;
|
||||||
|
|
||||||
|
Logger.Debug("Match between '{0}' and '{1}' was {2}", tvdbTitle, directoryName, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -9,7 +9,9 @@ namespace NzbDrone.Core.Repository
|
||||||
[SubSonicPrimaryKey(false)]
|
[SubSonicPrimaryKey(false)]
|
||||||
public int TvdbId { get; set; }
|
public int TvdbId { get; set; }
|
||||||
|
|
||||||
public string SeriesName { get; set; }
|
public string Title { get; set; }
|
||||||
|
|
||||||
|
public string CleanTitle { get; set; }
|
||||||
|
|
||||||
public string Status { get; set; }
|
public string Status { get; set; }
|
||||||
|
|
||||||
|
@ -24,10 +26,14 @@ namespace NzbDrone.Core.Repository
|
||||||
|
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
|
|
||||||
|
public bool Monitored { get; set; }
|
||||||
|
|
||||||
[SubSonicToManyRelation]
|
[SubSonicToManyRelation]
|
||||||
public virtual List<Season> Seasons { get; private set; }
|
public virtual List<Season> Seasons { get; private set; }
|
||||||
|
|
||||||
[SubSonicToManyRelation]
|
[SubSonicToManyRelation]
|
||||||
public virtual List<Episode> Episodes { get; private set; }
|
public virtual List<Episode> Episodes { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -20,6 +20,7 @@ a:link
|
||||||
{
|
{
|
||||||
color: #034af3;
|
color: #034af3;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
|
||||||
}
|
}
|
||||||
a:visited
|
a:visited
|
||||||
{
|
{
|
||||||
|
@ -249,6 +250,16 @@ input[type="submit"]
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.display-label
|
||||||
|
{
|
||||||
|
font-weight: bolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
.display-field
|
||||||
|
{
|
||||||
|
padding: 7px;
|
||||||
|
}
|
||||||
|
|
||||||
/* TABLE
|
/* TABLE
|
||||||
----------------------------------------------------------*/
|
----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -275,6 +286,8 @@ table th
|
||||||
background-repeat: repeat-x;
|
background-repeat: repeat-x;
|
||||||
color: #283B56;
|
color: #283B56;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MISC
|
/* MISC
|
||||||
|
@ -335,7 +348,7 @@ div#title
|
||||||
background-position: left;
|
background-position: left;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
padding: 0px 0px 0px 20px;
|
padding: 0px 0px 0px 20px;
|
||||||
font-size:0.9em;
|
font-size: 0.9em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-validation-error
|
.input-validation-error
|
||||||
|
@ -345,7 +358,7 @@ div#title
|
||||||
|
|
||||||
.validation-summary-errors
|
.validation-summary-errors
|
||||||
{
|
{
|
||||||
font-size:0.9em;
|
font-size: 0.9em;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
color: #ff0000;
|
color: #ff0000;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,13 @@ namespace NzbDrone.Web.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ActionResult UnMapped()
|
||||||
|
{
|
||||||
|
_seriesProvider.SyncSeriesWithDisk();
|
||||||
|
return View(_seriesProvider.GetUnmappedFolders());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// GET: /Series/Details/5
|
// GET: /Series/Details/5
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace NzbDrone.Web
|
||||||
|
|
||||||
protected override void OnApplicationStarted()
|
protected override void OnApplicationStarted()
|
||||||
{
|
{
|
||||||
|
Main.ConfigureNlog();
|
||||||
AreaRegistration.RegisterAllAreas();
|
AreaRegistration.RegisterAllAreas();
|
||||||
RegisterRoutes(RouteTable.Routes);
|
RegisterRoutes(RouteTable.Routes);
|
||||||
base.OnApplicationStarted();
|
base.OnApplicationStarted();
|
||||||
|
|
|
@ -94,6 +94,7 @@
|
||||||
<Content Include="Global.asax" />
|
<Content Include="Global.asax" />
|
||||||
<Content Include="Views\Series\Details.aspx" />
|
<Content Include="Views\Series\Details.aspx" />
|
||||||
<Content Include="Views\Series\index.aspx" />
|
<Content Include="Views\Series\index.aspx" />
|
||||||
|
<Content Include="Views\Series\Unmapped.aspx" />
|
||||||
<Content Include="Views\Settings\Index.aspx" />
|
<Content Include="Views\Settings\Index.aspx" />
|
||||||
<Content Include="Web.config">
|
<Content Include="Web.config">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
|
|
|
@ -6,35 +6,28 @@
|
||||||
|
|
||||||
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
|
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
|
||||||
|
|
||||||
<h2>Details</h2>
|
<h2><%: Model.Title %></h2>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Fields</legend>
|
|
||||||
|
|
||||||
<div class="display-label">Id</div>
|
<div class="display-label">ID</div>
|
||||||
<div class="display-field"><%: Model.TvdbId %></div>
|
<div class="display-field"><%: Model.TvdbId %></div>
|
||||||
|
|
||||||
<div class="display-label">SeriesName</div>
|
|
||||||
<div class="display-field"><%: Model.SeriesName %></div>
|
|
||||||
|
|
||||||
<div class="display-label">Status</div>
|
|
||||||
<div class="display-field"><%: Model.Status %></div>
|
|
||||||
|
|
||||||
<div class="display-label">Overview</div>
|
<div class="display-label">Overview</div>
|
||||||
<div class="display-field"><%: Model.Overview %></div>
|
<div class="display-field"><%: Model.Overview %></div>
|
||||||
|
|
||||||
|
<div class="display-label">Status</div>
|
||||||
|
<div class="display-field"><%: Model.Status %></div>
|
||||||
|
|
||||||
<div class="display-label">AirTimes</div>
|
<div class="display-label">AirTimes</div>
|
||||||
<div class="display-field"><%: Model.AirTimes %></div>
|
<div class="display-field"><%: Model.AirTimes %></div>
|
||||||
|
|
||||||
<div class="display-label">Language</div>
|
<div class="display-label">Language</div>
|
||||||
<div class="display-field"><%: Model.Language %></div>
|
<div class="display-field"><%: Model.Language.ToUpper() %></div>
|
||||||
|
|
||||||
<div class="display-label">Path</div>
|
<div class="display-label">Location</div>
|
||||||
<div class="display-field"><%: Model.Path %></div>
|
<div class="display-field"><%: Model.Path %></div>
|
||||||
|
|
||||||
<div class="display-label">TvdbId</div>
|
|
||||||
<div class="display-field"><%: Model.TvdbId %></div>
|
|
||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<p>
|
<p>
|
||||||
<%-- <%: Html.ActionLink("Edit", "Edit", new { /* id=Model.PrimaryKey */ }) %> |--%>
|
<%-- <%: Html.ActionLink("Edit", "Edit", new { /* id=Model.PrimaryKey */ }) %> |--%>
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<List<String>>" %>
|
||||||
|
|
||||||
|
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
|
||||||
|
Unmapped
|
||||||
|
</asp:Content>
|
||||||
|
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
|
||||||
|
<h2> The following folders aren't currently mapped to any Series.</h2>
|
||||||
|
<h3> Please Re-sync your folders.
|
||||||
|
If the problem persists try renaming your folders to something more similar to the name of series they contain.</h3>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Folder
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<% foreach (var item in Model)
|
||||||
|
{ %>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<%: item %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% } %>
|
||||||
|
</table>
|
||||||
|
</asp:Content>
|
|
@ -4,8 +4,16 @@
|
||||||
SeriesView
|
SeriesView
|
||||||
</asp:Content>
|
</asp:Content>
|
||||||
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
|
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
|
||||||
|
<ul id="menu">
|
||||||
|
<li>
|
||||||
|
<%: Html.ActionLink("Sync With Disk", "Sync") %></li>
|
||||||
|
<li>
|
||||||
|
<%: Html.ActionLink("View Unmapped Folders", "Unmapped") %></li>
|
||||||
|
</ul>
|
||||||
<h2>
|
<h2>
|
||||||
SeriesView</h2>
|
SeriesView</h2>
|
||||||
|
<p>
|
||||||
|
</p>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
|
@ -33,7 +41,7 @@
|
||||||
<%: item.TvdbId.ToString()%>
|
<%: item.TvdbId.ToString()%>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%: Html.ActionLink(item.SeriesName, "Details", new { item.TvdbId })%>
|
<%: Html.ActionLink(item.Title, "Details", new { item.TvdbId })%>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%: item.Status %>
|
<%: item.Status %>
|
||||||
|
@ -44,8 +52,4 @@
|
||||||
</tr>
|
</tr>
|
||||||
<% } %>
|
<% } %>
|
||||||
</table>
|
</table>
|
||||||
<p>
|
|
||||||
<%: Html.ActionLink("Create New", "Create") %>
|
|
||||||
<%: Html.ActionLink("Sync With Disk", "Sync") %>
|
|
||||||
</p>
|
|
||||||
</asp:Content>
|
</asp:Content>
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<div id="menucontainer">
|
<div id="menucontainer">
|
||||||
|
|
||||||
<ul id="menu">
|
<ul id="menu">
|
||||||
<li><%: Html.ActionLink("Home", "Index", "Home")%></li>
|
<li><%: Html.ActionLink("Series", "Index", "Series")%></li>
|
||||||
<li><%: Html.ActionLink("Settings", "Index", "Settings")%></li>
|
<li><%: Html.ActionLink("Settings", "Index", "Settings")%></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue