mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-27 22:56:45 -04:00
Fixed: Replaced trakt with tvdb as data source
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Xml.Linq;
|
||||
using TVDBSharp.Models.Enums;
|
||||
|
||||
namespace TVDBSharp.Models.DAO
|
||||
{
|
||||
/// <summary>
|
||||
/// Standard implementation of the <see cref="IDataProvider" /> interface.
|
||||
/// </summary>
|
||||
public class DataProvider : IDataProvider
|
||||
{
|
||||
public string ApiKey { get; set; }
|
||||
private const string BaseUrl = "http://thetvdb.com";
|
||||
|
||||
public XDocument GetShow(int showID)
|
||||
{
|
||||
return GetXDocumentFromUrl(string.Format("{0}/api/{1}/series/{2}/all/", BaseUrl, ApiKey, showID));
|
||||
}
|
||||
|
||||
public XDocument GetEpisode(int episodeId, string lang)
|
||||
{
|
||||
return GetXDocumentFromUrl(string.Format("{0}/api/{1}/episodes/{2}/{3}.xml", BaseUrl, ApiKey, episodeId, lang));
|
||||
}
|
||||
|
||||
public XDocument GetUpdates(Interval interval)
|
||||
{
|
||||
return GetXDocumentFromUrl(string.Format("{0}/api/{1}/updates/updates_{2}.xml", BaseUrl, ApiKey, IntervalHelpers.Print(interval)));
|
||||
}
|
||||
|
||||
public XDocument Search(string query)
|
||||
{
|
||||
return GetXDocumentFromUrl(string.Format("{0}/api/GetSeries.php?seriesname={1}", BaseUrl, query));
|
||||
}
|
||||
|
||||
private static XDocument GetXDocumentFromUrl(string url)
|
||||
{
|
||||
using (var web = new WebClient())
|
||||
using (var memoryStream = new MemoryStream(web.DownloadData(url)))
|
||||
return XDocument.Load(memoryStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using System.Xml.Linq;
|
||||
using TVDBSharp.Models.Enums;
|
||||
|
||||
namespace TVDBSharp.Models.DAO
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a Dataprovider API.
|
||||
/// </summary>
|
||||
public interface IDataProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// The API key provided by TVDB.
|
||||
/// </summary>
|
||||
string ApiKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the show with the given id and returns the corresponding XML tree.
|
||||
/// </summary>
|
||||
/// <param name="showID">ID of the show you wish to lookup.</param>
|
||||
/// <returns>Returns an XML tree of the show object.</returns>
|
||||
XDocument GetShow(int showID);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the episode with the given id and returns the corresponding XML tree.
|
||||
/// </summary>
|
||||
/// <param name="episodeId">ID of the episode to retrieve</param>
|
||||
/// <param name="lang">ISO 639-1 language code of the episode</param>
|
||||
/// <returns>XML tree of the episode object</returns>
|
||||
XDocument GetEpisode(int episodeId, string lang);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves updates on tvdb (Shows, Episodes and Banners)
|
||||
/// </summary>
|
||||
/// <param name="interval">The interval for the updates</param>
|
||||
/// <returns>XML tree of the Updates object</returns>
|
||||
XDocument GetUpdates(Interval interval);
|
||||
|
||||
/// <summary>
|
||||
/// Returns an XML tree representing a search query for the given parameter.
|
||||
/// </summary>
|
||||
/// <param name="query">Query to perform the search with.</param>
|
||||
/// <returns>Returns an XML tree of a search result.</returns>
|
||||
XDocument Search(string query);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user