Hacked sabprovider to support addbyurl from newzbin

This commit is contained in:
kay.one 2011-06-02 23:08:55 -07:00
parent 4f16615e8b
commit c0814fa95d
3 changed files with 120 additions and 9 deletions

View file

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using System.Xml.Linq;
using NLog;
@ -30,11 +31,17 @@ namespace NzbDrone.Core.Providers
{
string cat = _configProvider.SabTvCategory;
int priority = (int)_configProvider.SabTvPriority;
string name = url.Replace("&", "%26");
string name = GetNzbName(url);
string nzbName = HttpUtility.UrlEncode(title);
string action = string.Format("mode=addurl&name={0}&priority={1}&pp=3&cat={2}&nzbname={3}",
name, priority, cat, nzbName);
if (url.ToLower().Contains("newzbin"))
{
action = action.Replace("mode=addurl", "mode=addid");
}
string request = GetSabRequest(action);
Logger.Info("Adding report [{0}] to the queue.", title);
@ -50,6 +57,18 @@ namespace NzbDrone.Core.Providers
return false;
}
private static string GetNzbName(string urlString)
{
var url = new Uri(urlString);
if (url.Host.ToLower().Contains("newzbin"))
{
var postId = Regex.Match(urlString, @"\d{5,10}").Value;
return postId;
}
return urlString.Replace("&", "%26");
}
public virtual bool IsInQueue(string title)
{
const string action = "mode=queue&output=xml";