1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00

Merge pull request #20 from NzbDrone/omgwtfnzbs

Omgwtfnzbs
This commit is contained in:
Mark McDowall 2012-12-17 21:01:59 -08:00
commit 9428d68667
12 changed files with 1477 additions and 1 deletions

View File

@ -0,0 +1,24 @@
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<generator>omgwtfnzbs.com rss feeds generator</generator>
<language>en-us</language>
<title>Search NZB Download Feed</title>
<link>http://rss.omgwtfnzbs.com</link>
<description>auto-dl feed for omgwtfnzbs.com</description>
<copyright>2010 - 2012 omgwtfnzbs</copyright>
<atom:link href="http://rss.omgwtfnzbs.com/rss-search.php?catid=19,20&amp;eng=1" rel="self" type="application/rss+xml" />
<pubDate>Mon, 17 Dec 2012 23:30:16 +0000</pubDate>
<item>
<title>Stephen.Fry.Gadget.Man.S01E05.HDTV.x264-C4TV</title>
<pubDate>Mon, 17 Dec 2012 23:30:13 +0000</pubDate>
<guid>http://api.omgwtfnzbs.com/sn.php?id=OAl4g&amp;user=nzbdrone&amp;api=nzbdrone</guid>
<link>http://api.omgwtfnzbs.com/sn.php?id=OAl4g&amp;user=nzbdrone&amp;api=nzbdrone</link>
<description><![CDATA[<b>Category:</b> TV: STD<br /><b>Size:</b> 225.85 MB<br /><b>Group:</b> alt.binaries.teevee<br /><b>Added to index:</b> 17/12/2012 23:30:04<br /><b>Added to usenet:</b> 17/12/2012 23:30:13<br /><b>Weblink:</b> <a href="http://www.tvrage.com/shows/id-33431" target="_blank">http://www.tvrage.com/shows/id-33431</a><br /><b>View NZB:</b> <a href="http://omgwtfnzbs.com/details.php?id=OAl4g" target="_blank">http://omgwtfnzbs.com/details.php?id=OAl4g</a>]]></description>
<category>TV: STD</category>
<cattext>tv.sd</cattext>
<categoryid>19</categoryid>
<enclosure url="http://api.omgwtfnzbs.com/sn.php?id=OAl4g&amp;user=nzbdrone&amp;api=nzbdrone" length="236822906" type="application/x-nzb" />
</item>
</channel>
</rss>

File diff suppressed because it is too large Load Diff

View File

@ -32,6 +32,7 @@ public class IndexerTests : CoreTest
[TestCase("filesharingtalk.xml")]
[TestCase("nzbindex.xml")]
[TestCase("nzbclub.xml")]
[TestCase("omgwtfnzbs.xml")]
public void parse_feed_xml(string fileName)
{
Mocker.GetMock<HttpProvider>()
@ -68,6 +69,9 @@ private void WithConfiguredIndexers()
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.FileSharingTalkUid).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.FileSharingTalkSecret).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.OmgwtfnzbsUsername).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.OmgwtfnzbsApiKey).Returns("MockedConfigValue");
}
[Test]
@ -209,6 +213,22 @@ public void size_nzbclub()
parseResults[0].Size.Should().Be(2652142305);
}
[Test]
public void size_omgwtfnzbs()
{
WithConfiguredIndexers();
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream("http://rss.omgwtfnzbs.com/rss-search.php?catid=19,20&user=MockedConfigValue&api=MockedConfigValue&eng=1", It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\omgwtfnzbs.xml"));
//Act
var parseResults = Mocker.Resolve<Omgwtfnzbs>().FetchRss();
parseResults.Should().HaveCount(1);
parseResults[0].Size.Should().Be(236820890);
}
[Test]
public void Server_Unavailable_503_should_not_log_exception()
{
@ -452,5 +472,21 @@ public void newznab_GetQueryTitle_should_return_expected_result(string seriesTit
{
Mocker.Resolve<Newznab>().GetQueryTitle(seriesTitle).Should().Be(expected);
}
[Test]
public void should_get_nzbInfoUrl_for_omgwtfnzbs()
{
WithConfiguredIndexers();
Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream("http://rss.omgwtfnzbs.com/rss-search.php?catid=19,20&user=MockedConfigValue&api=MockedConfigValue&eng=1", It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\omgwtfnzbs.xml"));
//Act
var parseResults = Mocker.Resolve<Omgwtfnzbs>().FetchRss();
parseResults.Should().HaveCount(1);
parseResults[0].NzbInfoUrl.Should().Be("http://omgwtfnzbs.com/details.php?id=OAl4g");
}
}
}

View File

@ -279,12 +279,18 @@
<Content Include="Files\JsonError.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Files\RSS\omgwtfnzbs.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Files\RSS\nzbclub.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Files\RSS\nzbindex.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Files\RSS\SizeParsing\omgwtfnzbs.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Files\RSS\SizeParsing\nzbclub.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

View File

@ -92,6 +92,7 @@ private void InitIndexers()
Kernel.Bind<IndexerBase>().To<FileSharingTalk>();
Kernel.Bind<IndexerBase>().To<NzbIndex>();
Kernel.Bind<IndexerBase>().To<NzbClub>();
Kernel.Bind<IndexerBase>().To<Omgwtfnzbs>();
var indexers = Kernel.GetAll<IndexerBase>();
Kernel.Get<IndexerProvider>().InitializeIndexers(indexers.ToList());

View File

@ -311,6 +311,7 @@
<Compile Include="Providers\Indexer\NzbClub.cs" />
<Compile Include="Providers\Indexer\NzbIndex.cs" />
<Compile Include="Providers\Indexer\FileSharingTalk.cs" />
<Compile Include="Providers\Indexer\Omgwtfnzbs.cs" />
<Compile Include="Providers\Indexer\Wombles.cs" />
<Compile Include="Providers\MetadataProvider.cs" />
<Compile Include="Providers\Metadata\MetadataBase.cs" />

View File

@ -517,6 +517,18 @@ public virtual int RssSyncInterval
set { SetValue("RssSyncInterval", value); }
}
public virtual string OmgwtfnzbsUsername
{
get { return GetValue("OmgwtfnzbsUsername", String.Empty); }
set { SetValue("OmgwtfnzbsUsername", value); }
}
public virtual string OmgwtfnzbsApiKey
{
get { return GetValue("OmgwtfnzbsApiKey", String.Empty); }
set { SetValue("OmgwtfnzbsApiKey", value); }
}
private string GetValue(string key)
{
return GetValue(key, String.Empty);

View File

@ -0,0 +1,126 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Syndication;
using System.Text;
using System.Text.RegularExpressions;
using Ninject;
using NzbDrone.Common;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers.Indexer
{
class Omgwtfnzbs : IndexerBase
{
[Inject]
public Omgwtfnzbs(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
{
}
public override string Name
{
get { return "omgwtfnzbs"; }
}
protected override string[] Urls
{
get
{
return new string[]
{
String.Format("http://rss.omgwtfnzbs.com/rss-search.php?catid=19,20&user={0}&api={1}&eng=1",
_configProvider.OmgwtfnzbsUsername, _configProvider.OmgwtfnzbsApiKey)
};
}
}
public override bool IsConfigured
{
get
{
return !string.IsNullOrWhiteSpace(_configProvider.OmgwtfnzbsUsername) &&
!string.IsNullOrWhiteSpace(_configProvider.OmgwtfnzbsApiKey);
}
}
protected override IList<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{
var searchUrls = new List<String>();
foreach (var url in Urls)
{
searchUrls.Add(String.Format("{0}&search={1}+S{2:00}E{3:00}", url, seriesTitle, seasonNumber, episodeNumber));
}
return searchUrls;
}
protected override IList<string> GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date)
{
var searchUrls = new List<String>();
foreach (var url in Urls)
{
searchUrls.Add(String.Format("{0}&search={1}+{2:yyyy MM dd}", url, seriesTitle, date));
}
return searchUrls;
}
protected override IList<string> GetSeasonSearchUrls(string seriesTitle, int seasonNumber)
{
var searchUrls = new List<String>();
foreach (var url in Urls)
{
searchUrls.Add(String.Format("{0}&search={1}+S{2:00}", url, seriesTitle, seasonNumber));
}
return searchUrls;
}
protected override IList<string> GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard)
{
var searchUrls = new List<String>();
foreach (var url in Urls)
{
searchUrls.Add(String.Format("{0}&search={1}+S{2:00}E{3}", url, seriesTitle, seasonNumber, episodeWildcard));
}
return searchUrls;
}
protected override string NzbDownloadUrl(SyndicationItem item)
{
return item.Links[0].Uri.ToString();
}
protected override string NzbInfoUrl(SyndicationItem item)
{
//Todo: Me thinks I need to parse details to get this...
var match = Regex.Match(item.Summary.Text, @"(?:\<b\>View NZB\:\<\/b\>\s\<a\shref\=\"")(?<URL>.+)(?:\""\starget)",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
if(match.Success)
{
return match.Groups["URL"].Value;
}
return String.Empty;
}
protected override EpisodeParseResult CustomParser(SyndicationItem item, EpisodeParseResult currentResult)
{
if (currentResult != null)
{
var sizeString = Regex.Match(item.Summary.Text, @"Size:\<\/b\>\s\d+\.\d{1,2}\s\w{2}\<br \/\>", RegexOptions.IgnoreCase | RegexOptions.Compiled).Value;
currentResult.Size = Parser.GetReportSize(sizeString);
}
return currentResult;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

View File

@ -101,12 +101,16 @@ public ActionResult Indexers()
FileSharingTalkUid = _configProvider.FileSharingTalkUid,
FileSharingTalkSecret = _configProvider.FileSharingTalkSecret,
OmgwtfnzbsUsername = _configProvider.OmgwtfnzbsUsername,
OmgwtfnzbsApiKey = _configProvider.OmgwtfnzbsApiKey,
NzbsRUsEnabled = _indexerProvider.GetSettings(typeof(NzbsRUs)).Enable,
NewznabEnabled = _indexerProvider.GetSettings(typeof(Newznab)).Enable,
WomblesEnabled = _indexerProvider.GetSettings(typeof(Wombles)).Enable,
FileSharingTalkEnabled = _indexerProvider.GetSettings(typeof(FileSharingTalk)).Enable,
NzbIndexEnabled = _indexerProvider.GetSettings(typeof(NzbIndex)).Enable,
NzbClubEnabled = _indexerProvider.GetSettings(typeof(NzbClub)).Enable,
OmgwtfnzbsEnabled = _indexerProvider.GetSettings(typeof(Omgwtfnzbs)).Enable,
RssSyncInterval = _configProvider.RssSyncInterval,
@ -395,12 +399,19 @@ public JsonResult SaveIndexers(IndexerSettingsModel data)
nzbClubSettings.Enable = data.NzbClubEnabled;
_indexerProvider.SaveSettings(nzbClubSettings);
var omgwtfnzbsSettings = _indexerProvider.GetSettings(typeof(Omgwtfnzbs));
omgwtfnzbsSettings.Enable = data.OmgwtfnzbsEnabled;
_indexerProvider.SaveSettings(omgwtfnzbsSettings);
_configProvider.NzbsrusUId = data.NzbsrusUId;
_configProvider.NzbsrusHash = data.NzbsrusHash;
_configProvider.FileSharingTalkUid = data.FileSharingTalkUid;
_configProvider.FileSharingTalkSecret = data.FileSharingTalkSecret;
_configProvider.OmgwtfnzbsUsername = data.OmgwtfnzbsUsername;
_configProvider.OmgwtfnzbsApiKey = data.OmgwtfnzbsApiKey;
//Save the interval to config and immediately apply it the the job (to avoid a restart)
_configProvider.RssSyncInterval = data.RssSyncInterval;

View File

@ -37,6 +37,20 @@ public class IndexerSettingsModel
[RequiredIf("FileSharingTalkEnabled", true, ErrorMessage = "Password Secret Required when File Sharing Talk is enabled")]
public String FileSharingTalkSecret { get; set; }
[DataType(DataType.Text)]
[DisplayName("Username")]
[Description("Username for omgwtfnzbs")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
[RequiredIf("OmgwtfnzbsEnabled", true, ErrorMessage = "Username is required when omgwtfnzbs is enabled")]
public String OmgwtfnzbsUsername { get; set; }
[DataType(DataType.Text)]
[DisplayName("API Key")]
[Description("API Key for omgwtfnzbs")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
[RequiredIf("OmgwtfnzbsEnabled", true, ErrorMessage = "API Key is required when omgwtfnzbs is enabled")]
public String OmgwtfnzbsApiKey { get; set; }
[DisplayName("NZBsRUs")]
[Description("Enable downloading episodes from NZBsRus")]
public bool NzbsRUsEnabled { get; set; }
@ -61,6 +75,10 @@ public class IndexerSettingsModel
[Description("Enable downloading episodes from NzbClub")]
public bool NzbClubEnabled { get; set; }
[DisplayName("omgwtfnzbs")]
[Description("Enable downloading episodes from omgwtfnzbs")]
public bool OmgwtfnzbsEnabled { get; set; }
[Required(ErrorMessage = "Please enter a valid number of days")]
[DataType(DataType.Text)]
[DisplayName("Retention")]

View File

@ -28,7 +28,10 @@
<label for="nzbIndexStatus">NzbIndex</label>
@Html.CheckBox("nzbClubStatus", @Model.NzbClubEnabled, new { @class = "indexerStatusButton" })
<label for="nzbClubStatus">Nzb Club</label>
<label for="nzbClubStatus">Nzb Club</label>
@Html.CheckBox("omgwtfnzbsStatus", @Model.OmgwtfnzbsEnabled, new { @class = "indexerStatusButton" })
<label for="omgwtfnzbsStatus">omgwtfnzbs</label>
</div>
<div id="stylized">
@using (Html.BeginForm("SaveIndexers", "Settings", FormMethod.Post, new { id = "IndexersForm", name = "IndexersForm", @class = "settingsForm" }))
@ -117,6 +120,25 @@
</label>
@Html.CheckBoxFor(m => m.NzbClubEnabled, new { @class = "inputClass checkClass enabledCheck" })
</div>
<h3><a href="#">omgwtfnzbs</a></h3>
<div class="indexerPanel">
<label class="labelClass">
Enable <span class="small">@Html.DescriptionFor(m => m.OmgwtfnzbsEnabled)</span>
</label>
@Html.CheckBoxFor(m => m.OmgwtfnzbsEnabled, new { @class = "inputClass checkClass enabledCheck" })
<label class="labelClass">@Html.LabelFor(m => m.OmgwtfnzbsUsername)
<span class="small">@Html.DescriptionFor(m => m.OmgwtfnzbsUsername)</span>
<span class="small">@Html.ValidationMessageFor(m => m.OmgwtfnzbsUsername)</span>
</label>
@Html.TextBoxFor(m => m.OmgwtfnzbsUsername, new { @class = "inputClass" })
<label class="labelClass">@Html.LabelFor(m => m.OmgwtfnzbsApiKey)
<span class="small">@Html.DescriptionFor(m => m.OmgwtfnzbsApiKey)</span>
<span class="small">@Html.ValidationMessageFor(m => m.OmgwtfnzbsApiKey)</span>
</label>
@Html.TextBoxFor(m => m.OmgwtfnzbsApiKey, new { @class = "inputClass" })
</div>
</div>
<div class="indexer-global-settings">
@ -191,6 +213,9 @@
if (id == 'NzbClubEnabled')
$('#nzbClubStatus').prop('checked', checked);
if (id == 'OmgwtfnzbsEnabled')
$('#omgwtfnzbsStatus').prop('checked', checked);
$('.indexerStatusButton').button("refresh");
reValidate();
@ -217,6 +242,9 @@
if (id == 'nzbClubStatus')
$('#NzbClubEnabled').prop('checked', checked);
if (id == 'omgwtfnzbsStatus')
$('#OmgwtfnzbsEnabled').prop('checked', checked);
reValidate();
});