mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-10 09:04:17 -04:00
Removing TheTVDB implementation (new git)
This commit is contained in:
parent
77bf623611
commit
ce98686f4f
233
Kyoo.Common/.gitignore
vendored
Normal file
233
Kyoo.Common/.gitignore
vendored
Normal file
@ -0,0 +1,233 @@
|
|||||||
|
## PROJECT CUSTOM IGNORES
|
||||||
|
|
||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
build/
|
||||||
|
bld/
|
||||||
|
bin/
|
||||||
|
Bin/
|
||||||
|
obj/
|
||||||
|
Obj/
|
||||||
|
|
||||||
|
# Visual Studio 2015 cache/options directory
|
||||||
|
.vs/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUNIT
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_i.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# JustCode is a .NET coding add-in
|
||||||
|
.JustCode
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/packages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/packages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/packages/repositories.config
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Microsoft Azure ApplicationInsights config file
|
||||||
|
ApplicationInsights.config
|
||||||
|
|
||||||
|
# Windows Store app package directory
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
/node_modules
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
@ -1,68 +0,0 @@
|
|||||||
using Kyoo.Models;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Net;
|
|
||||||
using System.Net.Http;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Kyoo.InternalAPI.MetadataProvider.TheTvDB
|
|
||||||
{
|
|
||||||
public class HelperTvDB : ProviderHelper
|
|
||||||
{
|
|
||||||
public override string Provider => "TvDB";
|
|
||||||
|
|
||||||
private string token;
|
|
||||||
private DateTime tokenDate;
|
|
||||||
|
|
||||||
protected async Task<string> Authentificate()
|
|
||||||
{
|
|
||||||
if (DateTime.Now.Subtract(tokenDate) < TimeSpan.FromDays(1))
|
|
||||||
return token;
|
|
||||||
|
|
||||||
HttpClient client = new HttpClient();
|
|
||||||
HttpContent content = new StringContent("{ \"apikey\": \"IM2OXA8UHUIU0GH6\" }", Encoding.UTF8, "application/json");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
HttpResponseMessage response = await client.PostAsync("https://api.thetvdb.com/login", content);
|
|
||||||
|
|
||||||
if (response.StatusCode == HttpStatusCode.OK)
|
|
||||||
{
|
|
||||||
string resp = await response.Content.ReadAsStringAsync();
|
|
||||||
var obj = new {Token = ""};
|
|
||||||
|
|
||||||
token = JsonConvert.DeserializeAnonymousType(resp, obj).Token;
|
|
||||||
tokenDate = DateTime.UtcNow;
|
|
||||||
return token;
|
|
||||||
}
|
|
||||||
Debug.WriteLine("&Couldn't authentificate in TheTvDB API.\nError status: " + response.StatusCode + " Message: " + response.RequestMessage);
|
|
||||||
}
|
|
||||||
catch (WebException ex)
|
|
||||||
{
|
|
||||||
Debug.WriteLine("&Couldn't authentificate in TheTvDB API.\nError status: " + ex.Status);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected static long? GetYear(string firstAired)
|
|
||||||
{
|
|
||||||
if (firstAired?.Length >= 4 && long.TryParse(firstAired.Substring(0, 4), out long year))
|
|
||||||
return year;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Status? GetStatus(string status)
|
|
||||||
{
|
|
||||||
if (status == "Ended")
|
|
||||||
return Status.Finished;
|
|
||||||
if (status == "Continuing")
|
|
||||||
return Status.Airing;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,325 +0,0 @@
|
|||||||
using Kyoo.InternalAPI.MetadataProvider.TheTvDB;
|
|
||||||
using Kyoo.InternalAPI.Utility;
|
|
||||||
using Kyoo.Models;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Web;
|
|
||||||
#pragma warning disable 1998
|
|
||||||
|
|
||||||
namespace Kyoo.InternalAPI.MetadataProvider
|
|
||||||
{
|
|
||||||
[MetaProvider]
|
|
||||||
public class ProviderTheTvDB : HelperTvDB, IMetadataProvider
|
|
||||||
{
|
|
||||||
public async Task<Collection> GetCollectionFromName(string name)
|
|
||||||
{
|
|
||||||
return new Collection(-1, Slugifier.ToSlug(name), name, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Show> GetShowFromName(string showName, string showPath)
|
|
||||||
{
|
|
||||||
string token = await Authentificate();
|
|
||||||
|
|
||||||
if (token != null)
|
|
||||||
{
|
|
||||||
WebRequest request = WebRequest.Create("https://api.thetvdb.com/search/series?name=" + HttpUtility.UrlEncode(showName));
|
|
||||||
request.Method = "GET";
|
|
||||||
request.Timeout = 12000;
|
|
||||||
request.ContentType = "application/json";
|
|
||||||
request.Headers.Add(HttpRequestHeader.Authorization, "Bearer " + token);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync();
|
|
||||||
|
|
||||||
if (response.StatusCode == HttpStatusCode.OK)
|
|
||||||
{
|
|
||||||
Stream stream = response.GetResponseStream();
|
|
||||||
if (stream != null)
|
|
||||||
{
|
|
||||||
using StreamReader reader = new StreamReader(stream);
|
|
||||||
string content = await reader.ReadToEndAsync();
|
|
||||||
stream.Close();
|
|
||||||
response.Close();
|
|
||||||
|
|
||||||
dynamic obj = JsonConvert.DeserializeObject(content);
|
|
||||||
dynamic data = obj.data[0];
|
|
||||||
|
|
||||||
Show show = new Show(-1,
|
|
||||||
ToSlug(showName),
|
|
||||||
(string) data.seriesName,
|
|
||||||
((JArray) data.aliases).ToObject<IEnumerable<string>>(),
|
|
||||||
showPath,
|
|
||||||
(string) data.overview,
|
|
||||||
null, //trailer
|
|
||||||
null, //genres (no info with this request)
|
|
||||||
GetStatus((string) data.status),
|
|
||||||
GetYear((string) data.firstAired),
|
|
||||||
null, //endYear
|
|
||||||
string.Format("{0}={1}|", Provider, (string) data.id));
|
|
||||||
return (await GetShowByID(GetID(show.ExternalIDs))).Set(show.Slug, show.Path) ?? show;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.WriteLine("&TheTvDB Provider couldn't work for this show: " + showName + ".\nError Code: " + response.StatusCode + " Message: " + response.StatusDescription);
|
|
||||||
response.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (WebException ex)
|
|
||||||
{
|
|
||||||
Debug.WriteLine("&TheTvDB Provider couldn't work for this show: " + showName + ".\nError Code: " + ex.Status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Show() { Slug = ToSlug(showName), Title = showName, Path = showPath };
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Show> GetShowByID(string id)
|
|
||||||
{
|
|
||||||
string token = await Authentificate();
|
|
||||||
|
|
||||||
if (token == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
WebRequest request = WebRequest.Create("https://api.thetvdb.com/series/" + id);
|
|
||||||
request.Method = "GET";
|
|
||||||
request.Timeout = 12000;
|
|
||||||
request.ContentType = "application/json";
|
|
||||||
request.Headers.Add(HttpRequestHeader.Authorization, "Bearer " + token);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync();
|
|
||||||
|
|
||||||
if (response.StatusCode == HttpStatusCode.OK)
|
|
||||||
{
|
|
||||||
Stream stream = response.GetResponseStream();
|
|
||||||
if (stream != null)
|
|
||||||
{
|
|
||||||
using StreamReader reader = new StreamReader(stream);
|
|
||||||
string content = await reader.ReadToEndAsync();
|
|
||||||
stream.Close();
|
|
||||||
response.Close();
|
|
||||||
|
|
||||||
dynamic model = JsonConvert.DeserializeObject(content);
|
|
||||||
dynamic data = model.data;
|
|
||||||
|
|
||||||
Show show = new Show(-1,
|
|
||||||
null, //Slug
|
|
||||||
(string) data.seriesName,
|
|
||||||
((JArray) data.aliases).ToObject<IEnumerable<string>>(),
|
|
||||||
null, //Path
|
|
||||||
(string) data.overview,
|
|
||||||
null, //Trailer
|
|
||||||
GetGenres(((JArray) data.genre).ToObject<string[]>()),
|
|
||||||
GetStatus((string) data.status),
|
|
||||||
GetYear((string) data.firstAired),
|
|
||||||
null, //endYear
|
|
||||||
$"TvDB={id}|");
|
|
||||||
await GetImages(show);
|
|
||||||
return show;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Debug.WriteLine("&TheTvDB Provider couldn't work for the show with the id: " + id + ".\nError Code: " + response.StatusCode + " Message: " + response.StatusDescription);
|
|
||||||
response.Close();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
catch(WebException ex)
|
|
||||||
{
|
|
||||||
Debug.WriteLine("&TheTvDB Provider couldn't work for the show with the id: " + id + ".\nError Code: " + ex.Status);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Show> GetImages(Show show)
|
|
||||||
{
|
|
||||||
Debug.WriteLine("&Getting images for: " + show.Title);
|
|
||||||
string id = GetID(show.ExternalIDs);
|
|
||||||
|
|
||||||
if (id == null)
|
|
||||||
return show;
|
|
||||||
|
|
||||||
string token = await Authentificate();
|
|
||||||
|
|
||||||
if (token == null)
|
|
||||||
return show;
|
|
||||||
|
|
||||||
Dictionary<ImageType, string> imageTypes = new Dictionary<ImageType, string> { { ImageType.Poster, "poster" }, { ImageType.Background, "fanart" } };
|
|
||||||
|
|
||||||
foreach (KeyValuePair<ImageType, string> type in imageTypes)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
WebRequest request = WebRequest.Create("https://api.thetvdb.com/series/" + id + "/images/query?keyType=" + type.Value);
|
|
||||||
request.Method = "GET";
|
|
||||||
request.Timeout = 12000;
|
|
||||||
request.ContentType = "application/json";
|
|
||||||
request.Headers.Add(HttpRequestHeader.Authorization, "Bearer " + token);
|
|
||||||
|
|
||||||
HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync();
|
|
||||||
|
|
||||||
if (response.StatusCode == HttpStatusCode.OK)
|
|
||||||
{
|
|
||||||
Stream stream = response.GetResponseStream();
|
|
||||||
if (stream != null)
|
|
||||||
{
|
|
||||||
using StreamReader reader = new StreamReader(stream);
|
|
||||||
string content = await reader.ReadToEndAsync();
|
|
||||||
stream.Close();
|
|
||||||
response.Close();
|
|
||||||
|
|
||||||
dynamic model = JsonConvert.DeserializeObject(content);
|
|
||||||
//Should implement language selection here
|
|
||||||
dynamic data = ((IEnumerable<dynamic>) model.data)
|
|
||||||
.OrderByDescending(x => x.ratingsInfo.average)
|
|
||||||
.ThenByDescending(x => x.ratingsInfo.count).FirstOrDefault();
|
|
||||||
if (data != null)
|
|
||||||
SetImage(show, "https://www.thetvdb.com/banners/" + data.fileName, type.Key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.WriteLine("&TheTvDB Provider couldn't get " + type + " for the show with the id: " + id + ".\nError Code: " + response.StatusCode + " Message: " + response.StatusDescription);
|
|
||||||
response.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (WebException ex)
|
|
||||||
{
|
|
||||||
Debug.WriteLine("&TheTvDB Provider couldn't get " + type + " for the show with the id: " + id + ".\nError Code: " + ex.Status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return show;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Season> GetSeason(string showName, long seasonNumber)
|
|
||||||
{
|
|
||||||
return new Season(-1, -1, seasonNumber, "Season " + seasonNumber, null, null, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<string> GetSeasonImage(string showName, long seasonNumber)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Episode> GetEpisode(string externalIDs, long seasonNumber, long episodeNumber, long absoluteNumber, string episodePath)
|
|
||||||
{
|
|
||||||
string id = GetID(externalIDs);
|
|
||||||
|
|
||||||
if (id == null)
|
|
||||||
return new Episode(seasonNumber, episodeNumber, absoluteNumber, null, null, null, -1, null, externalIDs);
|
|
||||||
|
|
||||||
string token = await Authentificate();
|
|
||||||
|
|
||||||
if (token == null)
|
|
||||||
return new Episode(seasonNumber, episodeNumber, absoluteNumber, null, null, null, -1, null, externalIDs);
|
|
||||||
|
|
||||||
WebRequest request;
|
|
||||||
if (absoluteNumber != -1)
|
|
||||||
request = WebRequest.Create("https://api.thetvdb.com/series/" + id + "/episodes/query?absoluteNumber=" + absoluteNumber);
|
|
||||||
else
|
|
||||||
request = WebRequest.Create("https://api.thetvdb.com/series/" + id + "/episodes/query?airedSeason=" + seasonNumber + "&airedEpisode=" + episodeNumber);
|
|
||||||
|
|
||||||
request.Method = "GET";
|
|
||||||
request.Timeout = 12000;
|
|
||||||
request.ContentType = "application/json";
|
|
||||||
request.Headers.Add(HttpRequestHeader.Authorization, "Bearer " + token);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync();
|
|
||||||
|
|
||||||
if (response.StatusCode == HttpStatusCode.OK)
|
|
||||||
{
|
|
||||||
Stream stream = response.GetResponseStream();
|
|
||||||
if (stream != null)
|
|
||||||
{
|
|
||||||
using StreamReader reader = new StreamReader(stream);
|
|
||||||
string content = await reader.ReadToEndAsync();
|
|
||||||
stream.Close();
|
|
||||||
response.Close();
|
|
||||||
|
|
||||||
dynamic data = JsonConvert.DeserializeObject(content);
|
|
||||||
dynamic episode = data.data[0];
|
|
||||||
|
|
||||||
DateTime dateTime = DateTime.ParseExact((string)episode.firstAired, "yyyy-MM-dd", CultureInfo.InvariantCulture);
|
|
||||||
|
|
||||||
if (absoluteNumber == -1)
|
|
||||||
absoluteNumber = (long?)episode.absoluteNumber ?? -1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
seasonNumber = episode.airedSeason;
|
|
||||||
episodeNumber = episode.airedEpisodeNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Episode(seasonNumber, episodeNumber, absoluteNumber, (string)episode.episodeName, (string)episode.overview, dateTime, -1, "https://www.thetvdb.com/banners/" + episode.filename, string.Format("TvDB={0}|", episode.id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Debug.WriteLine("&TheTvDB Provider couldn't work for the episode number: " + episodeNumber + ".\nError Code: " + response.StatusCode + " Message: " + response.StatusDescription);
|
|
||||||
response.Close();
|
|
||||||
return new Episode(seasonNumber, episodeNumber, absoluteNumber, null, null, null, -1, null, externalIDs);
|
|
||||||
}
|
|
||||||
catch (WebException ex)
|
|
||||||
{
|
|
||||||
Debug.WriteLine("&TheTvDB Provider couldn't work for the episode number: " + episodeNumber + ".\nError Code: " + ex.Status);
|
|
||||||
return new Episode(seasonNumber, episodeNumber, absoluteNumber, null, null, null, -1, null, externalIDs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<List<People>> GetPeople(string externalIDs)
|
|
||||||
{
|
|
||||||
string id = GetID(externalIDs);
|
|
||||||
|
|
||||||
if (id == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
string token = await Authentificate();
|
|
||||||
|
|
||||||
if (token == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
WebRequest request = WebRequest.Create("https://api.thetvdb.com/series/" + id + "/actors");
|
|
||||||
request.Method = "GET";
|
|
||||||
request.Timeout = 12000;
|
|
||||||
request.ContentType = "application/json";
|
|
||||||
request.Headers.Add(HttpRequestHeader.Authorization, "Bearer " + token);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync();
|
|
||||||
|
|
||||||
if (response.StatusCode == HttpStatusCode.OK)
|
|
||||||
{
|
|
||||||
Stream stream = response.GetResponseStream();
|
|
||||||
if (stream != null)
|
|
||||||
{
|
|
||||||
using StreamReader reader = new StreamReader(stream);
|
|
||||||
string content = await reader.ReadToEndAsync();
|
|
||||||
stream.Close();
|
|
||||||
response.Close();
|
|
||||||
|
|
||||||
dynamic data = JsonConvert.DeserializeObject(content);
|
|
||||||
return (((IEnumerable<dynamic>)data.data).OrderBy(x => x.sortOrder)).ToList().ConvertAll(x => { return new People(-1, ToSlug((string)x.name), (string)x.name, (string)x.role, null, "https://www.thetvdb.com/banners/" + (string)x.image, string.Format("TvDB={0}|", x.id)); });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Debug.WriteLine("&TheTvDB Provider couldn't work for the actors of the show: " + id + ".\nError Code: " + response.StatusCode + " Message: " + response.StatusDescription);
|
|
||||||
response.Close();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
catch (WebException ex)
|
|
||||||
{
|
|
||||||
Debug.WriteLine("&TheTvDB Provider couldn't work for the actors of the show: " + id + ".\nError Code: " + ex.Status);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -27,8 +27,6 @@ namespace Kyoo.InternalAPI
|
|||||||
void LoadProviders()
|
void LoadProviders()
|
||||||
{
|
{
|
||||||
providers.Clear();
|
providers.Clear();
|
||||||
providers.Add(new ProviderTheTvDB());
|
|
||||||
|
|
||||||
string pluginFolder = config.GetValue<string>("providerPlugins");
|
string pluginFolder = config.GetValue<string>("providerPlugins");
|
||||||
|
|
||||||
if (Directory.Exists(pluginFolder))
|
if (Directory.Exists(pluginFolder))
|
@ -29,6 +29,8 @@
|
|||||||
<Content Remove="$(SpaRoot)**" />
|
<Content Remove="$(SpaRoot)**" />
|
||||||
<None Remove="$(SpaRoot)**" />
|
<None Remove="$(SpaRoot)**" />
|
||||||
<None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
|
<None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
|
||||||
|
<None Remove="Controllers\MetadataProvider\**" />
|
||||||
|
<Content Remove="Controllers\MetadataProvider\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -44,12 +46,17 @@
|
|||||||
<EmbeddedResource Include="kyoo.sh">
|
<EmbeddedResource Include="kyoo.sh">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Remove="Controllers\MetadataProvider\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Kyoo.Common\Kyoo.Common.csproj" />
|
<ProjectReference Include="..\Kyoo.Common\Kyoo.Common.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Remove="Controllers\MetadataProvider\**" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
|
<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
|
||||||
<!-- Ensure Node.js is installed -->
|
<!-- Ensure Node.js is installed -->
|
||||||
<Exec Command="node --version" ContinueOnError="true">
|
<Exec Command="node --version" ContinueOnError="true">
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\Kyoo.Common\Kyoo.Common.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
Loading…
x
Reference in New Issue
Block a user