1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/NzbDrone.Core/Indexers/Omgwtfnzbs.cs

125 lines
3.9 KiB
C#
Raw Normal View History

2012-12-18 04:52:56 +03:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Syndication;
using System.Text.RegularExpressions;
using NzbDrone.Common;
2013-02-24 09:48:52 +03:00
using NzbDrone.Core.Configuration;
2012-12-18 04:52:56 +03:00
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
2013-02-23 07:37:23 +03:00
namespace NzbDrone.Core.Indexers
2012-12-18 04:52:56 +03:00
{
class Omgwtfnzbs : IndexerBase
{
2013-02-24 09:48:52 +03:00
public Omgwtfnzbs(HttpProvider httpProvider, IConfigService configService)
: base(httpProvider, configService)
2012-12-18 04:52:56 +03:00
{
}
public override string Name
{
get { return "omgwtfnzbs"; }
}
protected override string[] Urls
{
get
{
return new string[]
{
2012-12-27 06:34:47 +03:00
String.Format("http://rss.omgwtfnzbs.org/rss-search.php?catid=19,20&user={0}&api={1}&eng=1",
2013-02-24 09:48:52 +03:00
_configService.OmgwtfnzbsUsername, _configService.OmgwtfnzbsApiKey)
2012-12-18 04:52:56 +03:00
};
}
}
public override bool IsConfigured
{
get
{
2013-02-24 09:48:52 +03:00
return !string.IsNullOrWhiteSpace(_configService.OmgwtfnzbsUsername) &&
!string.IsNullOrWhiteSpace(_configService.OmgwtfnzbsApiKey);
2012-12-18 04:52:56 +03:00
}
}
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;
}
}
}