removed trakt references, added user agent to tvdb requests

This commit is contained in:
Keivan Beigi
2014-12-31 14:11:45 -08:00
parent 7e76a36d68
commit d4331e9470
23 changed files with 71 additions and 399 deletions
+14 -3
View File
@@ -1,6 +1,8 @@
using System.IO;
using System.Net;
using System.Xml.Linq;
using NzbDrone.Common.Http;
using NzbDrone.Common.Instrumentation;
using TVDBSharp.Models.Enums;
namespace TVDBSharp.Models.DAO
@@ -13,6 +15,9 @@ namespace TVDBSharp.Models.DAO
public string ApiKey { get; set; }
private const string BaseUrl = "http://thetvdb.com";
private static HttpClient httpClient = new HttpClient(NzbDroneLogger.GetLogger(typeof(DataProvider)));
public XDocument GetShow(int showID)
{
return GetXDocumentFromUrl(string.Format("{0}/api/{1}/series/{2}/all/", BaseUrl, ApiKey, showID));
@@ -35,9 +40,15 @@ namespace TVDBSharp.Models.DAO
private static XDocument GetXDocumentFromUrl(string url)
{
using (var web = new WebClient())
using (var memoryStream = new MemoryStream(web.DownloadData(url)))
return XDocument.Load(memoryStream);
var request = new HttpRequest(url, new HttpAccept("application/xml"));
var response = httpClient.Get(request);
return XDocument.Parse(response.Content);
}
}
}