mirror of
https://github.com/Radarr/Radarr.git
synced 2024-08-16 23:39:44 +02:00
refactored Episode, Added Quality Enum
This commit is contained in:
parent
01c1943d0e
commit
a49850cc89
@ -1,115 +1,120 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<queue><active_lang>us-en</active_lang>
|
<queue>
|
||||||
<session>5c770e3197e4fe763423ee7c392c25d1</session>
|
<active_lang>us-en</active_lang>
|
||||||
<slots><slot><status>Queued</status>
|
<session>5c770e3197e4fe763423ee7c392c25d1</session>
|
||||||
<index>0</index>
|
<slots>
|
||||||
<eta>unknown</eta>
|
<slot>
|
||||||
<timeleft>0:00:00</timeleft>
|
<status>Queued</status>
|
||||||
<avg_age>11h</avg_age>
|
<index>0</index>
|
||||||
<script>None</script>
|
<eta>unknown</eta>
|
||||||
|
<timeleft>0:00:00</timeleft>
|
||||||
|
<avg_age>11h</avg_age>
|
||||||
|
<script>None</script>
|
||||||
|
|
||||||
<msgid></msgid>
|
<msgid></msgid>
|
||||||
<verbosity></verbosity>
|
<verbosity></verbosity>
|
||||||
<mb>770.96</mb>
|
<mb>770.96</mb>
|
||||||
<sizeleft>770.96 MB</sizeleft>
|
<sizeleft>770.96 MB</sizeleft>
|
||||||
<filename>Ubuntu Test</filename>
|
<filename>Ubuntu Test</filename>
|
||||||
<priority>Normal</priority>
|
<priority>Normal</priority>
|
||||||
<cat>None</cat>
|
<cat>None</cat>
|
||||||
<mbleft>770.96</mbleft>
|
<mbleft>770.96</mbleft>
|
||||||
<percentage>0</percentage>
|
<percentage>0</percentage>
|
||||||
<nzo_id>SABnzbd_nzo_xyr5ak</nzo_id>
|
<nzo_id>SABnzbd_nzo_xyr5ak</nzo_id>
|
||||||
|
|
||||||
<unpackopts>3</unpackopts>
|
<unpackopts>3</unpackopts>
|
||||||
<size>770.96 MB</size>
|
<size>770.96 MB</size>
|
||||||
</slot>
|
</slot>
|
||||||
</slots>
|
</slots>
|
||||||
<speed>0 </speed>
|
<speed>0 </speed>
|
||||||
<size>770.96 MB</size>
|
<size>770.96 MB</size>
|
||||||
<limit>0</limit>
|
<limit>0</limit>
|
||||||
<start>0</start>
|
<start>0</start>
|
||||||
<diskspacetotal2>259.45</diskspacetotal2>
|
<diskspacetotal2>259.45</diskspacetotal2>
|
||||||
<darwin>False</darwin>
|
<darwin>False</darwin>
|
||||||
|
|
||||||
<last_warning></last_warning>
|
<last_warning></last_warning>
|
||||||
<have_warnings>0</have_warnings>
|
<have_warnings>0</have_warnings>
|
||||||
<noofslots>1</noofslots>
|
<noofslots>1</noofslots>
|
||||||
<pause_int>0</pause_int>
|
<pause_int>0</pause_int>
|
||||||
<categories><category>None</category>
|
<categories>
|
||||||
<category>anime</category>
|
<category>None</category>
|
||||||
<category>apps</category>
|
<category>anime</category>
|
||||||
<category>books</category>
|
<category>apps</category>
|
||||||
<category>consoles</category>
|
<category>books</category>
|
||||||
|
<category>consoles</category>
|
||||||
|
|
||||||
<category>ds-games</category>
|
<category>ds-games</category>
|
||||||
<category>emulation</category>
|
<category>emulation</category>
|
||||||
<category>games</category>
|
<category>games</category>
|
||||||
<category>misc</category>
|
<category>misc</category>
|
||||||
<category>movies</category>
|
<category>movies</category>
|
||||||
<category>music</category>
|
<category>music</category>
|
||||||
<category>pda</category>
|
<category>pda</category>
|
||||||
<category>resources</category>
|
<category>resources</category>
|
||||||
<category>test</category>
|
<category>test</category>
|
||||||
|
|
||||||
<category>tv</category>
|
<category>tv</category>
|
||||||
<category>tv-dvd</category>
|
<category>tv-dvd</category>
|
||||||
<category>unknown</category>
|
<category>unknown</category>
|
||||||
<category>wii-games</category>
|
<category>wii-games</category>
|
||||||
<category>xbox-dlc</category>
|
<category>xbox-dlc</category>
|
||||||
<category>xbox-xbla</category>
|
<category>xbox-xbla</category>
|
||||||
</categories>
|
</categories>
|
||||||
<diskspacetotal1>259.45</diskspacetotal1>
|
<diskspacetotal1>259.45</diskspacetotal1>
|
||||||
<mb>770.96</mb>
|
<mb>770.96</mb>
|
||||||
|
|
||||||
<loadavg></loadavg>
|
<loadavg></loadavg>
|
||||||
<cache_max>157286400</cache_max>
|
<cache_max>157286400</cache_max>
|
||||||
<speedlimit></speedlimit>
|
<speedlimit></speedlimit>
|
||||||
<webdir>C:\Program Files\SABnzbd\interfaces\Plush\templates</webdir>
|
<webdir>C:\Program Files\SABnzbd\interfaces\Plush\templates</webdir>
|
||||||
<paused>True</paused>
|
<paused>True</paused>
|
||||||
<isverbose>False</isverbose>
|
<isverbose>False</isverbose>
|
||||||
<restart_req>False</restart_req>
|
<restart_req>False</restart_req>
|
||||||
<power_options>True</power_options>
|
<power_options>True</power_options>
|
||||||
<helpuri>http://wiki.sabnzbd.org/</helpuri>
|
<helpuri>http://wiki.sabnzbd.org/</helpuri>
|
||||||
<uptime>4d</uptime>
|
<uptime>4d</uptime>
|
||||||
|
|
||||||
<refresh_rate></refresh_rate>
|
<refresh_rate></refresh_rate>
|
||||||
<version>0.6.x</version>
|
<version>0.6.x</version>
|
||||||
<color_scheme></color_scheme>
|
<color_scheme></color_scheme>
|
||||||
<new_release></new_release>
|
<new_release></new_release>
|
||||||
<nt>True</nt>
|
<nt>True</nt>
|
||||||
<status>Paused</status>
|
<status>Paused</status>
|
||||||
<finish>0</finish>
|
<finish>0</finish>
|
||||||
<cache_art>0</cache_art>
|
<cache_art>0</cache_art>
|
||||||
<paused_all>False</paused_all>
|
<paused_all>False</paused_all>
|
||||||
<finishaction></finishaction>
|
<finishaction></finishaction>
|
||||||
<sizeleft>770.96 MB</sizeleft>
|
<sizeleft>770.96 MB</sizeleft>
|
||||||
|
|
||||||
<cache_size>0B</cache_size>
|
<cache_size>0B</cache_size>
|
||||||
<mbleft>770.96</mbleft>
|
<mbleft>770.96</mbleft>
|
||||||
<diskspace2>1177.64</diskspace2>
|
<diskspace2>1177.64</diskspace2>
|
||||||
<diskspace1>1177.64</diskspace1>
|
<diskspace1>1177.64</diskspace1>
|
||||||
<scripts><script>None</script>
|
<scripts>
|
||||||
<script>Alias.config</script>
|
<script>None</script>
|
||||||
<script>ConsoleCategories.config</script>
|
<script>Alias.config</script>
|
||||||
<script>exiso.exe</script>
|
<script>ConsoleCategories.config</script>
|
||||||
<script>Movies.exe</script>
|
<script>exiso.exe</script>
|
||||||
|
<script>Movies.exe</script>
|
||||||
|
|
||||||
<script>Movies.exe.config</script>
|
<script>Movies.exe.config</script>
|
||||||
<script>Movies.pdb</script>
|
<script>Movies.pdb</script>
|
||||||
<script>PreQueue.exe</script>
|
<script>PreQueue.exe</script>
|
||||||
<script>PreQueue.exe.config</script>
|
<script>PreQueue.exe.config</script>
|
||||||
<script>PreQueue.pdb</script>
|
<script>PreQueue.pdb</script>
|
||||||
<script>SABTest.exe</script>
|
<script>SABTest.exe</script>
|
||||||
<script>TVMove.exe</script>
|
<script>TVMove.exe</script>
|
||||||
<script>TVMove.exe.config</script>
|
<script>TVMove.exe.config</script>
|
||||||
<script>TVMove_0.4.1.exe</script>
|
<script>TVMove_0.4.1.exe</script>
|
||||||
|
|
||||||
<script>XBox360.exe</script>
|
<script>XBox360.exe</script>
|
||||||
<script>XBox360.exe.config</script>
|
<script>XBox360.exe.config</script>
|
||||||
</scripts>
|
</scripts>
|
||||||
<timeleft>0:00:00</timeleft>
|
<timeleft>0:00:00</timeleft>
|
||||||
<nzb_quota></nzb_quota>
|
<nzb_quota></nzb_quota>
|
||||||
<eta>unknown</eta>
|
<eta>unknown</eta>
|
||||||
<kbpersec>0.00</kbpersec>
|
<kbpersec>0.00</kbpersec>
|
||||||
<new_rel_url></new_rel_url>
|
<new_rel_url></new_rel_url>
|
||||||
<queue_details>0</queue_details>
|
<queue_details>0</queue_details>
|
||||||
</queue>
|
</queue>
|
@ -34,7 +34,7 @@ public void AddByUrlSuccess()
|
|||||||
config.Setup(c => c.GetValue("Priority", String.Empty, false)).Returns(priority);
|
config.Setup(c => c.GetValue("Priority", String.Empty, false)).Returns(priority);
|
||||||
|
|
||||||
var http = new Mock<IHttpProvider>();
|
var http = new Mock<IHttpProvider>();
|
||||||
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");
|
http.Setup(s => s.DownloadString("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 SabProvider(config.Object, new Mock<ILog>().Object, http.Object);
|
var target = new SabProvider(config.Object, new Mock<ILog>().Object, http.Object);
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public void AddByUrlError()
|
|||||||
config.Setup(c => c.GetValue("Priority", String.Empty, false)).Returns(priority);
|
config.Setup(c => c.GetValue("Priority", String.Empty, false)).Returns(priority);
|
||||||
|
|
||||||
var http = new Mock<IHttpProvider>();
|
var http = new Mock<IHttpProvider>();
|
||||||
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");
|
http.Setup(s => s.DownloadString("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 SabProvider(config.Object, new Mock<ILog>().Object, http.Object);
|
var target = new SabProvider(config.Object, new Mock<ILog>().Object, http.Object);
|
||||||
|
|
||||||
@ -102,16 +102,15 @@ public void IsInQueue_True()
|
|||||||
var http = new Mock<IHttpProvider>();
|
var http = new Mock<IHttpProvider>();
|
||||||
http.Setup(
|
http.Setup(
|
||||||
s =>
|
s =>
|
||||||
s.GetRequest(
|
s.DownloadString(
|
||||||
"http://192.168.5.55:2222/sabnzbd/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
|
"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());
|
.Returns(new StreamReader(@".\Files\Queue.xml").ReadToEnd());
|
||||||
|
|
||||||
var target = new SabProvider(config.Object, new Mock<ILog>().Object, http.Object);
|
var target = new SabProvider(config.Object, new Mock<ILog>().Object, http.Object);
|
||||||
|
|
||||||
Episode episode = new Episode();
|
Episode episode = new Episode();
|
||||||
FeedItem item = new FeedItem();
|
|
||||||
item.TitleFix = "Ubuntu Test";
|
episode.FileName = "Ubuntu Test";
|
||||||
episode.FeedItem = item;
|
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
bool result = target.IsInQueue(episode);
|
bool result = target.IsInQueue(episode);
|
||||||
@ -140,16 +139,13 @@ public void IsInQueue_False_Empty()
|
|||||||
var http = new Mock<IHttpProvider>();
|
var http = new Mock<IHttpProvider>();
|
||||||
http.Setup(
|
http.Setup(
|
||||||
s =>
|
s =>
|
||||||
s.GetRequest(
|
s.DownloadString(
|
||||||
"http://192.168.5.55:2222/sabnzbd/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
|
"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());
|
.Returns(new StreamReader(@".\Files\QueueEmpty.xml").ReadToEnd());
|
||||||
|
|
||||||
var target = new SabProvider(config.Object, new Mock<ILog>().Object, http.Object);
|
var target = new SabProvider(config.Object, new Mock<ILog>().Object, http.Object);
|
||||||
|
|
||||||
Episode episode = new Episode();
|
Episode episode = new Episode();
|
||||||
FeedItem item = new FeedItem();
|
|
||||||
item.TitleFix = "Ubuntu Test";
|
|
||||||
episode.FeedItem = item;
|
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
bool result = target.IsInQueue(episode);
|
bool result = target.IsInQueue(episode);
|
||||||
@ -178,7 +174,7 @@ public void IsInQueue_False_Error()
|
|||||||
var http = new Mock<IHttpProvider>();
|
var http = new Mock<IHttpProvider>();
|
||||||
http.Setup(
|
http.Setup(
|
||||||
s =>
|
s =>
|
||||||
s.GetRequest(
|
s.DownloadString(
|
||||||
"http://192.168.5.55:2222/sabnzbd/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
|
"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());
|
.Returns(new StreamReader(@".\Files\QueueError.xml").ReadToEnd());
|
||||||
|
|
||||||
@ -187,7 +183,6 @@ public void IsInQueue_False_Error()
|
|||||||
Episode episode = new Episode();
|
Episode episode = new Episode();
|
||||||
FeedItem item = new FeedItem();
|
FeedItem item = new FeedItem();
|
||||||
item.TitleFix = "Ubuntu Test";
|
item.TitleFix = "Ubuntu Test";
|
||||||
episode.FeedItem = item;
|
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
bool result = target.IsInQueue(episode);
|
bool result = target.IsInQueue(episode);
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Helpers
|
|
||||||
{
|
|
||||||
|
|
||||||
static class Disk
|
|
||||||
{
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Cleans the path. making it a uniform path.
|
|
||||||
/// this will normalize all different presentations of a single folder.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="path">The path.</param>
|
|
||||||
/// <returns>Cleaned Path</returns>
|
|
||||||
public static string CleanPath(string path)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(path)) throw new ArgumentException("Path can not be null or empty");
|
|
||||||
return path.ToLower().Trim('/', '\\', ' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -136,17 +136,18 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Providers\ConfigProvider.cs" />
|
<Compile Include="Providers\ConfigProvider.cs" />
|
||||||
|
<Compile Include="Providers\EpisodeProvider.cs" />
|
||||||
<Compile Include="Providers\HttpProvider.cs" />
|
<Compile Include="Providers\HttpProvider.cs" />
|
||||||
<Compile Include="Providers\IDownloadProvider.cs" />
|
<Compile Include="Providers\IDownloadProvider.cs" />
|
||||||
<Compile Include="Providers\IHttpProvider.cs" />
|
<Compile Include="Providers\IHttpProvider.cs" />
|
||||||
<Compile Include="Providers\ISeriesProvider.cs" />
|
<Compile Include="Providers\ISeriesProvider.cs" />
|
||||||
<Compile Include="Providers\ITvDbProvider.cs" />
|
<Compile Include="Providers\ITvDbProvider.cs" />
|
||||||
<Compile Include="Providers\SabProvider.cs" />
|
<Compile Include="Providers\SabProvider.cs" />
|
||||||
<Compile Include="Helpers\Disk.cs" />
|
|
||||||
<Compile Include="Repository\Config.cs" />
|
<Compile Include="Repository\Config.cs" />
|
||||||
<Compile Include="Repository\Episode.cs" />
|
<Compile Include="Repository\Episode.cs" />
|
||||||
<Compile Include="Repository\FeedItem.cs" />
|
<Compile Include="Repository\FeedItem.cs" />
|
||||||
<Compile Include="Repository\ItemInfo.cs" />
|
<Compile Include="Repository\ItemInfo.cs" />
|
||||||
|
<Compile Include="Repository\Quality.cs" />
|
||||||
<Compile Include="Repository\Site.cs" />
|
<Compile Include="Repository\Site.cs" />
|
||||||
<Compile Include="Repository\Series.cs" />
|
<Compile Include="Repository\Series.cs" />
|
||||||
<Compile Include="Main.cs" />
|
<Compile Include="Main.cs" />
|
||||||
|
@ -23,5 +23,11 @@ public String CreateDirectory(string path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public static string CleanPath(string path)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(path)) throw new ArgumentException("Path can not be null or empty");
|
||||||
|
return path.ToLower().Trim('/', '\\', ' ');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
68
NzbDrone.Core/Providers/EpisodeProvider.cs
Normal file
68
NzbDrone.Core/Providers/EpisodeProvider.cs
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
using System;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using NzbDrone.Core.Repository;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Providers
|
||||||
|
{
|
||||||
|
public class EpisodeProvider
|
||||||
|
{
|
||||||
|
private static Regex _parseRegex =
|
||||||
|
new Regex(
|
||||||
|
@"(?<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>.*)
|
||||||
|
)", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace);
|
||||||
|
|
||||||
|
|
||||||
|
public static Episode Parse(string title)
|
||||||
|
{
|
||||||
|
Match match = _parseRegex.Match(title);
|
||||||
|
|
||||||
|
if (!match.Success)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new Episode
|
||||||
|
{
|
||||||
|
|
||||||
|
Season = ParseInt(match.Groups["seasonNumber"].Value),
|
||||||
|
EpisodeNumber = ParseInt(match.Groups["episodeNumber"].Value),
|
||||||
|
EpisodeNumber2 = ParseInt(match.Groups["episodeNumber2"].Value),
|
||||||
|
Title = ReplaceSeparatorChars(match.Groups["episodeName"].Value),
|
||||||
|
Release = ReplaceSeparatorChars(match.Groups["release"].Value),
|
||||||
|
Proper = title.Contains("PROPER")
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -5,19 +5,9 @@ namespace NzbDrone.Core.Providers
|
|||||||
{
|
{
|
||||||
class HttpProvider : IHttpProvider
|
class HttpProvider : IHttpProvider
|
||||||
{
|
{
|
||||||
public string GetRequest(string request)
|
public string DownloadString(string request)
|
||||||
{
|
{
|
||||||
//Get the request and return as String Array
|
return new WebClient().DownloadString(request);
|
||||||
try
|
|
||||||
{
|
|
||||||
var webClient = new WebClient();
|
|
||||||
return webClient.DownloadString(request);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine(ex);
|
|
||||||
return String.Empty;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
{
|
{
|
||||||
public interface IHttpProvider
|
public interface IHttpProvider
|
||||||
{
|
{
|
||||||
string GetRequest(string request);
|
string DownloadString(string request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public bool AddByUrl(ItemInfo nzb)
|
|||||||
|
|
||||||
_logger.DebugFormat("Adding report [{0}] to the queue.", nzbName);
|
_logger.DebugFormat("Adding report [{0}] to the queue.", nzbName);
|
||||||
|
|
||||||
string response = _http.GetRequest(request).Replace("\n", String.Empty);
|
string response = _http.DownloadString(request).Replace("\n", String.Empty);
|
||||||
_logger.DebugFormat("Queue Repsonse: [{0}]", response);
|
_logger.DebugFormat("Queue Repsonse: [{0}]", response);
|
||||||
|
|
||||||
if (response == "ok")
|
if (response == "ok")
|
||||||
@ -48,7 +48,7 @@ public bool IsInQueue(Episode epsiode)
|
|||||||
{
|
{
|
||||||
string action = "mode=queue&output=xml";
|
string action = "mode=queue&output=xml";
|
||||||
string request = GetSabRequest(action);
|
string request = GetSabRequest(action);
|
||||||
string response = _http.GetRequest(request);
|
string response = _http.DownloadString(request);
|
||||||
|
|
||||||
XDocument xDoc = XDocument.Parse(response);
|
XDocument xDoc = XDocument.Parse(response);
|
||||||
|
|
||||||
@ -60,9 +60,9 @@ public bool IsInQueue(Episode epsiode)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
//Get the Count of Items in Queue where 'filename' is Equal to goodName, if not zero, return true (isInQueue)))
|
//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)
|
if ((from s in xDoc.Descendants("slot") where s.Element("filename").Value.Equals(epsiode.FileName, StringComparison.InvariantCultureIgnoreCase) select s).Count() != 0)
|
||||||
{
|
{
|
||||||
_logger.DebugFormat("Episode in queue - '{0}'", epsiode.FeedItem.TitleFix);
|
_logger.DebugFormat("Episode in queue - '{0}'", epsiode.FileName);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using log4net;
|
using log4net;
|
||||||
using NzbDrone.Core.Helpers;
|
|
||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
using SubSonic.Repository;
|
using SubSonic.Repository;
|
||||||
using TvdbLib.Data;
|
using TvdbLib.Data;
|
||||||
@ -44,7 +43,7 @@ public void SyncSeriesWithDisk()
|
|||||||
|
|
||||||
foreach (string seriesFolder in _diskProvider.GetDirectories(_config.SeriesRoot))
|
foreach (string seriesFolder in _diskProvider.GetDirectories(_config.SeriesRoot))
|
||||||
{
|
{
|
||||||
var cleanPath = Disk.CleanPath(new DirectoryInfo(seriesFolder).FullName);
|
var cleanPath = DiskProvider.CleanPath(new DirectoryInfo(seriesFolder).FullName);
|
||||||
if (!_sonioRepo.Exists<Series>(s => s.Path == cleanPath))
|
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);
|
_logger.InfoFormat("Folder '{0} isn't mapped to a series in the database. Trying to map it.'", cleanPath);
|
||||||
|
@ -8,120 +8,16 @@ namespace NzbDrone.Core.Repository
|
|||||||
{
|
{
|
||||||
public class Episode
|
public class Episode
|
||||||
{
|
{
|
||||||
//Information about the current episode being processed
|
public string SeriesId { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
private const string EpisodePattern = @"
|
public string Title2 { get; set; }
|
||||||
(?<showName>.*)
|
public int Season { get; set; }
|
||||||
(?:
|
|
||||||
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 EpisodeNumber { get; set; }
|
||||||
public int EpisodeNumber2 { get; set; }
|
public int EpisodeNumber2 { get; set; }
|
||||||
public DateTime AirDate { get; set; }
|
public DateTime AirDate { get; set; }
|
||||||
public string Release { get; set; }
|
public string Release { get; set; }
|
||||||
public int Quality { get; set; }
|
public int Quality { get; set; }
|
||||||
|
public bool Proper { get; set; }
|
||||||
public bool IsProper
|
public String FileName { get; set; }
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
35
NzbDrone.Core/Repository/Quality.cs
Normal file
35
NzbDrone.Core/Repository/Quality.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
namespace NzbDrone.Core.Repository
|
||||||
|
{
|
||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
/// <summary>
|
||||||
|
/// Represents Video Quality
|
||||||
|
/// </summary>
|
||||||
|
public enum Quality
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Quality is unknown
|
||||||
|
/// </summary>
|
||||||
|
Unknown = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// SD File (Source could be HD)
|
||||||
|
/// </summary>
|
||||||
|
SDTV = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// SD File (DVD Source)
|
||||||
|
/// </summary>
|
||||||
|
DVD = 2,
|
||||||
|
/// <summary>
|
||||||
|
/// HD File (HDTV Source)
|
||||||
|
/// </summary>
|
||||||
|
HDTV = 3,
|
||||||
|
/// <summary>
|
||||||
|
/// HD File (Online Source)
|
||||||
|
/// </summary>
|
||||||
|
WEBDL = 4,
|
||||||
|
/// <summary>
|
||||||
|
/// HD File (Blu-ray Source)
|
||||||
|
/// </summary>
|
||||||
|
Bluray = 5
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user