1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-20 18:02:44 +01:00

Merged Mark's fork in

This commit is contained in:
Keivan 2010-09-27 20:40:01 -07:00
parent babe2735ee
commit e2128d2235
14 changed files with 740 additions and 14 deletions

View File

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8" ?>
<queue><active_lang>us-en</active_lang>
<session>5c770e3197e4fe763423ee7c392c25d1</session>
<slots><slot><status>Queued</status>
<index>0</index>
<eta>unknown</eta>
<timeleft>0:00:00</timeleft>
<avg_age>11h</avg_age>
<script>None</script>
<msgid></msgid>
<verbosity></verbosity>
<mb>770.96</mb>
<sizeleft>770.96 MB</sizeleft>
<filename>Ubuntu Test</filename>
<priority>Normal</priority>
<cat>None</cat>
<mbleft>770.96</mbleft>
<percentage>0</percentage>
<nzo_id>SABnzbd_nzo_xyr5ak</nzo_id>
<unpackopts>3</unpackopts>
<size>770.96 MB</size>
</slot>
</slots>
<speed>0 </speed>
<size>770.96 MB</size>
<limit>0</limit>
<start>0</start>
<diskspacetotal2>259.45</diskspacetotal2>
<darwin>False</darwin>
<last_warning></last_warning>
<have_warnings>0</have_warnings>
<noofslots>1</noofslots>
<pause_int>0</pause_int>
<categories><category>None</category>
<category>anime</category>
<category>apps</category>
<category>books</category>
<category>consoles</category>
<category>ds-games</category>
<category>emulation</category>
<category>games</category>
<category>misc</category>
<category>movies</category>
<category>music</category>
<category>pda</category>
<category>resources</category>
<category>test</category>
<category>tv</category>
<category>tv-dvd</category>
<category>unknown</category>
<category>wii-games</category>
<category>xbox-dlc</category>
<category>xbox-xbla</category>
</categories>
<diskspacetotal1>259.45</diskspacetotal1>
<mb>770.96</mb>
<loadavg></loadavg>
<cache_max>157286400</cache_max>
<speedlimit></speedlimit>
<webdir>C:\Program Files\SABnzbd\interfaces\Plush\templates</webdir>
<paused>True</paused>
<isverbose>False</isverbose>
<restart_req>False</restart_req>
<power_options>True</power_options>
<helpuri>http://wiki.sabnzbd.org/</helpuri>
<uptime>4d</uptime>
<refresh_rate></refresh_rate>
<version>0.6.x</version>
<color_scheme></color_scheme>
<new_release></new_release>
<nt>True</nt>
<status>Paused</status>
<finish>0</finish>
<cache_art>0</cache_art>
<paused_all>False</paused_all>
<finishaction></finishaction>
<sizeleft>770.96 MB</sizeleft>
<cache_size>0B</cache_size>
<mbleft>770.96</mbleft>
<diskspace2>1177.64</diskspace2>
<diskspace1>1177.64</diskspace1>
<scripts><script>None</script>
<script>Alias.config</script>
<script>ConsoleCategories.config</script>
<script>exiso.exe</script>
<script>Movies.exe</script>
<script>Movies.exe.config</script>
<script>Movies.pdb</script>
<script>PreQueue.exe</script>
<script>PreQueue.exe.config</script>
<script>PreQueue.pdb</script>
<script>SABTest.exe</script>
<script>TVMove.exe</script>
<script>TVMove.exe.config</script>
<script>TVMove_0.4.1.exe</script>
<script>XBox360.exe</script>
<script>XBox360.exe.config</script>
</scripts>
<timeleft>0:00:00</timeleft>
<nzb_quota></nzb_quota>
<eta>unknown</eta>
<kbpersec>0.00</kbpersec>
<new_rel_url></new_rel_url>
<queue_details>0</queue_details>
</queue>

View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8" ?>
<queue><active_lang>us-en</active_lang>
<session>5c770e3197e4fe763423ee7c392c25d1</session>
<slots></slots>
<speed>0 </speed>
<size>0B</size>
<limit>0</limit>
<start>0</start>
<diskspacetotal2>259.45</diskspacetotal2>
<darwin>False</darwin>
<last_warning></last_warning>
<have_warnings>0</have_warnings>
<noofslots>0</noofslots>
<pause_int>0</pause_int>
<categories><category>None</category>
<category>anime</category>
<category>apps</category>
<category>books</category>
<category>consoles</category>
<category>ds-games</category>
<category>emulation</category>
<category>games</category>
<category>misc</category>
<category>movies</category>
<category>music</category>
<category>pda</category>
<category>resources</category>
<category>test</category>
<category>tv</category>
<category>tv-dvd</category>
<category>unknown</category>
<category>wii-games</category>
<category>xbox-dlc</category>
<category>xbox-xbla</category>
</categories>
<diskspacetotal1>259.45</diskspacetotal1>
<mb>0.00</mb>
<loadavg></loadavg>
<cache_max>157286400</cache_max>
<speedlimit></speedlimit>
<webdir>C:\Program Files\SABnzbd\interfaces\Plush\templates</webdir>
<paused>False</paused>
<isverbose>False</isverbose>
<restart_req>False</restart_req>
<power_options>True</power_options>
<helpuri>http://wiki.sabnzbd.org/</helpuri>
<uptime>4d</uptime>
<refresh_rate></refresh_rate>
<version>0.6.x</version>
<color_scheme></color_scheme>
<new_release></new_release>
<nt>True</nt>
<status>Idle</status>
<finish>0</finish>
<cache_art>0</cache_art>
<paused_all>False</paused_all>
<finishaction></finishaction>
<sizeleft>0B</sizeleft>
<cache_size>0B</cache_size>
<mbleft>0.00</mbleft>
<diskspace2>1177.64</diskspace2>
<diskspace1>1177.64</diskspace1>
<scripts><script>None</script>
<script>Alias.config</script>
<script>ConsoleCategories.config</script>
<script>exiso.exe</script>
<script>Movies.exe</script>
<script>Movies.exe.config</script>
<script>Movies.pdb</script>
<script>PreQueue.exe</script>
<script>PreQueue.exe.config</script>
<script>PreQueue.pdb</script>
<script>SABTest.exe</script>
<script>TVMove.exe</script>
<script>TVMove.exe.config</script>
<script>TVMove_0.4.1.exe</script>
<script>XBox360.exe</script>
<script>XBox360.exe.config</script>
</scripts>
<timeleft>0:00:00</timeleft>
<nzb_quota></nzb_quota>
<eta>unknown</eta>
<kbpersec>0.00</kbpersec>
<new_rel_url></new_rel_url>
<queue_details>0</queue_details>
</queue>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<result><status>False</status>
<error>API Key Incorrect</error>
</result>

View File

@ -72,6 +72,7 @@
<Compile Include="Ninject.Moq\MockingKernel.cs" />
<Compile Include="Ninject.Moq\MockProvider.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SabControllerTest.cs" />
<Compile Include="SeriesTest.cs" />
<Compile Include="TvDbControllerTest.cs" />
</ItemGroup>
@ -85,7 +86,17 @@
<Content Include="Libs\FizzWare.NBuilder.dll" />
<Content Include="Libs\Moq.dll" />
<Content Include="Libs\Moq.xml" />
<Content Include="Files\Queue.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Files\QueueEmpty.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Files\QueueError.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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.

View File

@ -0,0 +1,199 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Gallio.Framework;
using log4net;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Controllers;
using SubSonic.Repository;
namespace NzbDrone.Core.Test
{
[TestFixture]
public class SabControllerTest
{
[Test]
public void AddByUrlSuccess()
{
//Setup
string sabnzbdInfo = "192.168.5.55:2222";
string apikey = "5c770e3197e4fe763423ee7c392c25d1";
string username = "admin";
string password = "pass";
string priority = "0";
var config = new Mock<IConfigController>();
config.Setup(c => c.GetValue("SabnzbdInfo", String.Empty, false)).Returns(sabnzbdInfo);
config.Setup(c => c.GetValue("ApiKey", String.Empty, false)).Returns(apikey);
config.Setup(c => c.GetValue("Username", String.Empty, false)).Returns(username);
config.Setup(c => c.GetValue("Password", String.Empty, false)).Returns(password);
config.Setup(c => c.GetValue("Priority", String.Empty, false)).Returns(priority);
var http = new Mock<IHttpController>();
http.Setup(s => s.GetRequest("http://192.168.5.55:2222/sabnzbd/api?mode=addurl&name=http://www.nzbclub.com/nzb_download.aspx?mid=1950232&priority=0&cat=tv&nzbname=This+is+an+Nzb&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass")).Returns("ok");
var target = new SabController(config.Object, new Mock<ILog>().Object, http.Object);
ItemInfo nzb = new ItemInfo();
nzb.Link = new Uri("http://www.nzbclub.com/nzb_download.aspx?mid=1950232");
nzb.Title = "This is an Nzb";
//Act
bool result = target.AddByUrl(nzb);
//Assert
Assert.AreEqual(true, result);
}
[Test]
public void AddByUrlError()
{
//Setup
string sabnzbdInfo = "192.168.5.55:2222";
string apikey = "5c770e3197e4fe763423ee7c392c25d1";
string username = "admin";
string password = "pass";
string priority = "0";
var config = new Mock<IConfigController>();
config.Setup(c => c.GetValue("SabnzbdInfo", String.Empty, false)).Returns(sabnzbdInfo);
config.Setup(c => c.GetValue("ApiKey", String.Empty, false)).Returns(apikey);
config.Setup(c => c.GetValue("Username", String.Empty, false)).Returns(username);
config.Setup(c => c.GetValue("Password", String.Empty, false)).Returns(password);
config.Setup(c => c.GetValue("Priority", String.Empty, false)).Returns(priority);
var http = new Mock<IHttpController>();
http.Setup(s => s.GetRequest("http://192.168.5.55:2222/sabnzbd/api?mode=addurl&name=http://www.nzbclub.com/nzb_download.aspx?mid=1950232&priority=0&cat=tv&nzbname=This+is+an+Nzb&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass")).Returns("error");
var target = new SabController(config.Object, new Mock<ILog>().Object, http.Object);
ItemInfo nzb = new ItemInfo();
nzb.Link = new Uri("http://www.nzbclub.com/nzb_download.aspx?mid=1950232");
nzb.Title = "This is an Nzb";
//Act
bool result = target.AddByUrl(nzb);
//Assert
Assert.AreEqual(false, result);
}
[Test]
public void IsInQueue_True()
{
//Setup
string sabnzbdInfo = "192.168.5.55:2222";
string apikey = "5c770e3197e4fe763423ee7c392c25d1";
string username = "admin";
string password = "pass";
string priority = "0";
var config = new Mock<IConfigController>();
config.Setup(c => c.GetValue("SabnzbdInfo", String.Empty, false)).Returns(sabnzbdInfo);
config.Setup(c => c.GetValue("ApiKey", String.Empty, false)).Returns(apikey);
config.Setup(c => c.GetValue("Username", String.Empty, false)).Returns(username);
config.Setup(c => c.GetValue("Password", String.Empty, false)).Returns(password);
config.Setup(c => c.GetValue("Priority", String.Empty, false)).Returns(priority);
var http = new Mock<IHttpController>();
http.Setup(
s =>
s.GetRequest(
"http://192.168.5.55:2222/sabnzbd/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns(new StreamReader(@".\Files\Queue.xml").ReadToEnd());
var target = new SabController(config.Object, new Mock<ILog>().Object, http.Object);
Episode episode = new Episode();
FeedItem item = new FeedItem();
item.TitleFix = "Ubuntu Test";
episode.FeedItem = item;
//Act
bool result = target.IsInQueue(episode);
//Assert
Assert.AreEqual(true, result);
}
[Test]
public void IsInQueue_False_Empty()
{
//Setup
string sabnzbdInfo = "192.168.5.55:2222";
string apikey = "5c770e3197e4fe763423ee7c392c25d1";
string username = "admin";
string password = "pass";
string priority = "0";
var config = new Mock<IConfigController>();
config.Setup(c => c.GetValue("SabnzbdInfo", String.Empty, false)).Returns(sabnzbdInfo);
config.Setup(c => c.GetValue("ApiKey", String.Empty, false)).Returns(apikey);
config.Setup(c => c.GetValue("Username", String.Empty, false)).Returns(username);
config.Setup(c => c.GetValue("Password", String.Empty, false)).Returns(password);
config.Setup(c => c.GetValue("Priority", String.Empty, false)).Returns(priority);
var http = new Mock<IHttpController>();
http.Setup(
s =>
s.GetRequest(
"http://192.168.5.55:2222/sabnzbd/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns(new StreamReader(@".\Files\QueueEmpty.xml").ReadToEnd());
var target = new SabController(config.Object, new Mock<ILog>().Object, http.Object);
Episode episode = new Episode();
FeedItem item = new FeedItem();
item.TitleFix = "Ubuntu Test";
episode.FeedItem = item;
//Act
bool result = target.IsInQueue(episode);
//Assert
Assert.AreEqual(false, result);
}
[Test]
public void IsInQueue_False_Error()
{
//Setup
string sabnzbdInfo = "192.168.5.55:2222";
string apikey = "5c770e3197e4fe763423ee7c392c25d1";
string username = "admin";
string password = "pass";
string priority = "0";
var config = new Mock<IConfigController>();
config.Setup(c => c.GetValue("SabnzbdInfo", String.Empty, false)).Returns(sabnzbdInfo);
config.Setup(c => c.GetValue("ApiKey", String.Empty, false)).Returns(apikey);
config.Setup(c => c.GetValue("Username", String.Empty, false)).Returns(username);
config.Setup(c => c.GetValue("Password", String.Empty, false)).Returns(password);
config.Setup(c => c.GetValue("Priority", String.Empty, false)).Returns(priority);
var http = new Mock<IHttpController>();
http.Setup(
s =>
s.GetRequest(
"http://192.168.5.55:2222/sabnzbd/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns(new StreamReader(@".\Files\QueueError.xml").ReadToEnd());
var target = new SabController(config.Object, new Mock<ILog>().Object, http.Object);
Episode episode = new Episode();
FeedItem item = new FeedItem();
item.TitleFix = "Ubuntu Test";
episode.FeedItem = item;
//Act
bool result = target.IsInQueue(episode);
//Assert
Assert.AreEqual(false, result);
}
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
namespace NzbDrone.Core.Controllers
{
class HttpController : IHttpController
{
public string GetRequest(string request)
{
//Get the request and return as String Array
try
{
var webClient = new WebClient();
return webClient.DownloadString(request);
}
catch (Exception ex)
{
Console.WriteLine(ex);
return String.Empty;
}
}
}
}

View File

@ -2,12 +2,13 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Controllers
{
public interface IDownloadClientController
{
string AddByUrl(string url); //Should accept something other than string (NzbInfo?) returns result if applicable
bool IsInQueue(string goodName);//Should accept something other than string (Episode?) returns bool
bool AddByUrl(ItemInfo nzb); //Should accept something other than string (NzbInfo?) returns success or failure
bool IsInQueue(Episode episode);//Should accept something other than string (Episode?) returns bool
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Controllers
{
public interface IHttpController
{
string GetRequest(string request);
}
}

View File

@ -1,37 +1,92 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using log4net;
using System.Xml.Linq;
using System.Xml;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Controllers
{
public class SabController : IDownloadClientController
{
private readonly IConfigController _config;
private readonly ILog _logger;
private readonly IHttpController _http;
public SabController(IConfigController config)
public SabController(IConfigController config, ILog logger, IHttpController http)
{
_config = config;
_logger = logger;
_http = http;
}
public string AddByUrl(string url)
#region IDownloadClientController Members
public bool AddByUrl(ItemInfo nzb)
{
const string mode = "addurl";
const string cat = "tv";
string priority = _config.GetValue("Priority", String.Empty, false);
string name = nzb.Link.ToString().Replace("&", "%26");
string nzbName = HttpUtility.UrlEncode(nzb.Title);
string action = string.Format("mode={0}&name={1}&priority={2}&cat={3}&nzbname={4}", mode, name, priority, cat, nzbName);
string request = GetSabRequest(action);
return "";
}
_logger.DebugFormat("Adding report [{0}] to the queue.", nzbName);
public string AddByPath(string path)
{
string response = _http.GetRequest(request).Replace("\n", String.Empty);
_logger.DebugFormat("Queue Repsonse: [{0}]", response);
return "";
}
public bool IsInQueue(string goodName)
{
if (response == "ok")
return true;
return false;
}
public bool IsInQueue(Episode epsiode)
{
string action = "mode=queue&output=xml";
string request = GetSabRequest(action);
string response = _http.GetRequest(request);
XDocument xDoc = XDocument.Parse(response);
//If an Error Occurred, retuyrn)
if (xDoc.Descendants("error").Count() != 0)
return false;
if (xDoc.Descendants("queue").Count() == 0)
return false;
//Get the Count of Items in Queue where 'filename' is Equal to goodName, if not zero, return true (isInQueue)))
if ((from s in xDoc.Descendants("slot") where s.Element("filename").Value.Equals(epsiode.FeedItem.TitleFix, StringComparison.InvariantCultureIgnoreCase) select s).Count() != 0)
{
_logger.DebugFormat("Episode in queue - '{0}'", epsiode.FeedItem.TitleFix);
return true;
}
return false; //Not in Queue
}
#endregion
private string GetSabRequest(string action)
{
string sabnzbdInfo = _config.GetValue("SabnzbdInfo", String.Empty, false);
string username = _config.GetValue("Username", String.Empty, false);
string password = _config.GetValue("Password", String.Empty, false);
string apiKey = _config.GetValue("ApiKey", String.Empty, false);
return string.Format(
@"http://{0}/sabnzbd/api?$Action&apikey={1}&ma_username={2}&ma_password={3}",
sabnzbdInfo, apiKey, username, password).Replace("$Action", action);
}
}
}

View File

@ -130,16 +130,24 @@
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Web" />
<Reference Include="System.XML" />
<Reference Include="System.Xml.Linq" />
<Reference Include="TvdbLib, Version=0.8.8.0, Culture=neutral, processorArchitecture=MSIL" />
</ItemGroup>
<ItemGroup>
<Compile Include="Controllers\DbConfigController.cs" />
<Compile Include="Controllers\HttpController.cs" />
<Compile Include="Controllers\IDownloadClientController.cs" />
<Compile Include="Controllers\IHttpController.cs" />
<Compile Include="Controllers\ISeriesController.cs" />
<Compile Include="Controllers\ITvDbController.cs" />
<Compile Include="Controllers\SabController.cs" />
<Compile Include="Helpers\Disk.cs" />
<Compile Include="Repository\Config.cs" />
<Compile Include="Repository\Episode.cs" />
<Compile Include="Repository\FeedItem.cs" />
<Compile Include="Repository\ItemInfo.cs" />
<Compile Include="Repository\Site.cs" />
<Compile Include="Repository\Series.cs" />
<Compile Include="Main.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

View File

@ -0,0 +1,127 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace NzbDrone.Core.Repository
{
public class Episode
{
//Information about the current episode being processed
private const string EpisodePattern = @"
(?<showName>.*)
(?:
s(?<seasonNumber>\d+)e(?<episodeNumber>\d+)-?e(?<episodeNumber2>\d+)
| s(?<seasonNumber>\d+)e(?<episodeNumber>\d+)
| (?<seasonNumber>\d+)x(?<episodeNumber>\d+)
| (?<airDate>\d{4}.\d{2}.\d{2})
)
(?:
(?<episodeName>.*?)
(?<release>
(?:hdtv|pdtv|xvid|ws|720p|x264|bdrip|dvdrip|dsr|proper)
.*)
| (?<episodeName>.*)
)
";
public FeedItem FeedItem { get; set; }
public string ShowName { get; set; }
public string EpisodeName { get; set; }
public string EpisodeName2 { get; set; }
public int SeasonNumber { get; set; }
public int EpisodeNumber { get; set; }
public int EpisodeNumber2 { get; set; }
public DateTime AirDate { get; set; }
public string Release { get; set; }
public int Quality { get; set; }
public bool IsProper
{
get { return FeedItem.Title.Contains("PROPER"); }
}
public bool IsDaily
{
get { return AirDate != DateTime.MinValue; }
}
public bool IsMulti
{
get { return SeasonNumber != 0 && EpisodeNumber != 0 && EpisodeNumber2 != 0; }
}
public string EpisodeTitle
{
get { return IsDaily ? GetDailyEpisode() : IsMulti ? GetMultiEpisode() : GetSeasonEpisode(); }
}
public string Title
{
get { return string.Format("{0} - {1}", ShowName, EpisodeTitle); }
}
public override string ToString()
{
return string.Format("{0} - {1}", ShowName, EpisodeTitle);
}
private string GetDailyEpisode()
{
return AirDate.ToString("yyyy-MM-dd");
}
private string GetMultiEpisode()
{
return string.Format("{0}x{1:D2}-{0}x{2:D2}", SeasonNumber, EpisodeNumber, EpisodeNumber2);
}
private string GetSeasonEpisode()
{
return string.Format("{0}x{1:D2}", SeasonNumber, EpisodeNumber);
}
public static Episode Parse(FeedItem feedItem)
{
Match match = Regex.Match(feedItem.Title, EpisodePattern,
RegexOptions.IgnorePatternWhitespace | RegexOptions.IgnoreCase);
if (!match.Success)
return null;
return new Episode
{
ShowName = ReplaceSeparatorChars(match.Groups["showName"].Value),
SeasonNumber = ParseInt(match.Groups["seasonNumber"].Value),
EpisodeNumber = ParseInt(match.Groups["episodeNumber"].Value),
EpisodeNumber2 = ParseInt(match.Groups["episodeNumber2"].Value),
EpisodeName = ReplaceSeparatorChars(match.Groups["episodeName"].Value),
Release = ReplaceSeparatorChars(match.Groups["release"].Value)
};
}
private static string ReplaceSeparatorChars(string s)
{
if (s == null) return string.Empty;
return s.Replace('.', ' ').Replace('-', ' ').Replace('_', ' ').Trim();
}
private static int ParseInt(string s)
{
int i;
int.TryParse(s, out i);
return i;
}
private static DateTime ParseAirDate(string s)
{
DateTime d;
if (DateTime.TryParse(ReplaceSeparatorChars(s).Replace(' ', '-'), out d))
return d;
return DateTime.MinValue;
}
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Repository
{
public class FeedItem
{
//Item from the NZB Feed waiting tp be processed.
public string Description { get; set; }
public string Title { get; set; }
public string TitleFix { get; set; }
public string NzbId { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Repository
{
public class ItemInfo
{
public string Id { get; set; }
public string Title { get; set; }
public Site Site { get; set; }
public Uri Link { get; set; }
public string Description { get; set; }
public bool IsPassworded()
{
return Title.EndsWith("(Passworded)", StringComparison.InvariantCultureIgnoreCase);
}
}
}

View File

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace NzbDrone.Core.Repository
{
public class Site
{
private static readonly IList<Site> Sites = new List<Site>
{
new Site {Name = "nzbmatrix", Url = "nzbmatrix.com", Pattern = @"\d{6,10}"},
new Site {Name = "nzbsDotOrg", Url = "nzbs.org", Pattern = @"\d{5,10}"},
new Site {Name = "nzbsrus", Url = "nzbsrus.com", Pattern = @"\d{6,10}"},
new Site {Name = "lilx", Url = "lilx.net", Pattern = @"\d{6,10}"},
};
public string Name { get; set; }
public string Pattern { get; set; }
public string Url { get; set; }
// TODO: use HttpUtility.ParseQueryString();
// https://nzbmatrix.com/api-nzb-download.php?id=626526
public string ParseId(string url)
{
return Regex.Match(url, Pattern).Value;
}
public static Site Parse(string url)
{
return Sites.Where(site => url.Contains(site.Url)).SingleOrDefault() ??
new Site { Name = "unknown", Pattern = @"\d{6,10}" };
}
}
}