mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-21 22:05:43 -04:00
Added couchpotato, and added a test
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace NzbDrone.Core.NetImport.RSSImport
|
||||
{
|
||||
class IMDbWatchListAPI
|
||||
{
|
||||
[XmlRoot(ElementName = "item")]
|
||||
public class Movie
|
||||
{
|
||||
[XmlElement(ElementName = "pubDate")]
|
||||
public string PublishDate { get; set; }
|
||||
[XmlElement(ElementName = "title")]
|
||||
public string Title { get; set; }
|
||||
[XmlElement(ElementName = "link")]
|
||||
public string Link { get; set; }
|
||||
[XmlElement(ElementName = "guid")]
|
||||
public string Guid { get; set; }
|
||||
[XmlElement(ElementName = "description")]
|
||||
public string Description { get; set; }
|
||||
}
|
||||
|
||||
[XmlRoot(ElementName = "channel")]
|
||||
public class Channel
|
||||
{
|
||||
[XmlElement(ElementName = "title")]
|
||||
public string Title { get; set; }
|
||||
[XmlElement(ElementName = "link")]
|
||||
public string Link { get; set; }
|
||||
[XmlElement(ElementName = "description")]
|
||||
public string Description { get; set; }
|
||||
[XmlElement(ElementName = "pubDate")]
|
||||
public string PublishDate { get; set; }
|
||||
[XmlElement(ElementName = "lastBuildDate")]
|
||||
public string LastBuildDate { get; set; }
|
||||
[XmlElement(ElementName = "item")]
|
||||
public List<Movie> Movie { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Xml.Linq;
|
||||
using FluentValidation.Results;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Exceptions;
|
||||
using RestSharp;
|
||||
using NzbDrone.Core.Rest;
|
||||
|
||||
namespace NzbDrone.Core.NetImport.RSSImport
|
||||
{
|
||||
public interface IIMDbWatchListProxy
|
||||
{
|
||||
void ImportMovies(string url);
|
||||
ValidationFailure Test(RSSImportSettings settings);
|
||||
}
|
||||
|
||||
public class IMDbWatchListProxy : IIMDbWatchListProxy
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
private const string URL = "http://rss.imdb.com";
|
||||
|
||||
public IMDbWatchListProxy(Logger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void ImportMovies(string id)
|
||||
{
|
||||
var client = RestClientFactory.BuildClient(URL);
|
||||
var request = new RestRequest("/list/{id}", Method.GET);
|
||||
request.RequestFormat = DataFormat.Xml;
|
||||
request.AddParameter("id", id, ParameterType.UrlSegment);
|
||||
|
||||
var response = client.ExecuteAndValidate(request);
|
||||
ValidateResponse(response);
|
||||
}
|
||||
|
||||
private void Verify(string id)
|
||||
{
|
||||
var client = RestClientFactory.BuildClient(URL);
|
||||
var request = new RestRequest("/list/{id}", Method.GET);
|
||||
request.RequestFormat = DataFormat.Xml;
|
||||
request.AddParameter("id", id, ParameterType.UrlSegment);
|
||||
|
||||
var response = client.ExecuteAndValidate(request);
|
||||
ValidateResponse(response);
|
||||
}
|
||||
|
||||
private void ValidateResponse(IRestResponse response)
|
||||
{
|
||||
var xDoc = XDocument.Parse(response.Content);
|
||||
var nma = xDoc.Descendants("nma").Single();
|
||||
var error = nma.Descendants("error").SingleOrDefault();
|
||||
|
||||
if (error != null)
|
||||
{
|
||||
((HttpStatusCode)Convert.ToInt32(error.Attribute("code").Value)).VerifyStatusCode(error.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public ValidationFailure Test(RSSImportSettings settings)
|
||||
{
|
||||
try
|
||||
{
|
||||
Verify(settings.Link);
|
||||
ImportMovies(settings.Link);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "Unable to import movies: " + ex.Message);
|
||||
return new ValidationFailure("IMDbWatchListId", "Unable to import movies");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,10 +20,10 @@ namespace NzbDrone.Core.NetImport.RSSImport
|
||||
return pageableRequests;
|
||||
}
|
||||
|
||||
public NetImportPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria)
|
||||
{
|
||||
return new NetImportPageableRequestChain();
|
||||
}
|
||||
//public NetImportPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria)
|
||||
//{
|
||||
// return new NetImportPageableRequestChain();
|
||||
//}
|
||||
|
||||
private IEnumerable<NetImportRequest> GetMovies(string searchParameters)
|
||||
{
|
||||
|
||||
@@ -14,7 +14,6 @@ namespace NzbDrone.Core.NetImport.RSSImport
|
||||
public RSSImportSettings()
|
||||
{
|
||||
Link = "http://rss.yoursite.com";
|
||||
ProfileId = 1;
|
||||
}
|
||||
|
||||
[FieldDefinition(0, Label = "RSS Link", HelpText = "Link to the rss feed of movies.")]
|
||||
|
||||
Reference in New Issue
Block a user