mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-01 04:34:50 -04:00
Implementing the season creator.
This commit is contained in:
parent
69a8ec1c18
commit
9706c840c9
@ -54,17 +54,17 @@ namespace Kyoo.InternalAPI
|
||||
Regex regex = new Regex(patern, RegexOptions.IgnoreCase);
|
||||
Match match = regex.Match(file);
|
||||
|
||||
string ShowPath = Path.GetDirectoryName(file);
|
||||
string ShowTitle = match.Groups["ShowTitle"].Value;
|
||||
string showPath = Path.GetDirectoryName(file);
|
||||
string showName = match.Groups["ShowTitle"].Value;
|
||||
bool seasonSuccess = long.TryParse(match.Groups["Season"].Value, out long seasonNumber);
|
||||
bool episodeSucess = long.TryParse(match.Groups["Episode"].Value, out long episodeNumber);
|
||||
|
||||
Debug.WriteLine("&ShowPath: " + ShowPath + " Show: " + ShowTitle + " season: " + seasonNumber + " episode: " + episodeNumber);
|
||||
Debug.WriteLine("&ShowPath: " + showPath + " Show: " + showName + " season: " + seasonNumber + " episode: " + episodeNumber);
|
||||
|
||||
if (!libraryManager.IsShowRegistered(ShowPath, out long showID))
|
||||
if (!libraryManager.IsShowRegistered(showPath, out long showID))
|
||||
{
|
||||
Debug.WriteLine("&Should register show: " + ShowTitle);
|
||||
Show show = await metadataProvider.GetShowFromName(ShowTitle, ShowPath);
|
||||
Debug.WriteLine("&Should register show: " + showName);
|
||||
Show show = await metadataProvider.GetShowFromName(showName, showPath);
|
||||
showID = libraryManager.RegisterShow(show);
|
||||
}
|
||||
|
||||
@ -72,8 +72,9 @@ namespace Kyoo.InternalAPI
|
||||
|
||||
if(!libraryManager.IsSeasonRegistered(showID, seasonNumber, out long seasonID))
|
||||
{
|
||||
Debug.WriteLine("&Should register season: " + ShowTitle + " - " + seasonNumber);
|
||||
Season season = await metadataProvider.GetSeason(showID, seasonNumber);
|
||||
Debug.WriteLine("&Should register season: " + showName + " - " + seasonNumber);
|
||||
Season season = await metadataProvider.GetSeason(showName, seasonNumber);
|
||||
season.ShowID = showID;
|
||||
showID = libraryManager.RegisterSeason(season);
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,8 @@ namespace Kyoo.InternalAPI
|
||||
Task<Show> GetImages(Show show);
|
||||
|
||||
//For the seasons
|
||||
Task<Season> GetSeason(string showName, int seasonNumber);
|
||||
Task<Season> GetSeason(string showName, long seasonNumber);
|
||||
|
||||
Task<string> GetSeasonImage(string showName, long seasonNumber);
|
||||
}
|
||||
}
|
||||
|
@ -214,6 +214,8 @@ namespace Kyoo.InternalAPI.MetadataProvider
|
||||
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";
|
||||
@ -245,13 +247,23 @@ namespace Kyoo.InternalAPI.MetadataProvider
|
||||
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 Task<Season> GetSeason(string showName, int seasonNumber)
|
||||
public Task<Season> GetSeason(string showName, long seasonNumber)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return new Season(-1, -1, seasonNumber, "Season " + seasonNumber, null, null, null, null);
|
||||
}
|
||||
|
||||
public Task<string> GetSeasonImage(string showName, long seasonNumber)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using Kyoo.Models;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
@ -25,7 +26,11 @@ namespace Kyoo.InternalAPI
|
||||
providers.Clear();
|
||||
providers.Add(new ProviderTheTvDB());
|
||||
|
||||
string[] pluginsPaths = Directory.GetFiles(config.GetValue<string>("providerPlugins"));
|
||||
string pluginFolder = config.GetValue<string>("providerPlugins");
|
||||
|
||||
if (Directory.Exists(pluginFolder))
|
||||
{
|
||||
string[] pluginsPaths = Directory.GetFiles(pluginFolder);
|
||||
List<Assembly> plugins = new List<Assembly>();
|
||||
List<Type> types = new List<Type>();
|
||||
|
||||
@ -52,6 +57,7 @@ namespace Kyoo.InternalAPI
|
||||
|
||||
providers.AddRange(providersPlugins.ConvertAll<IMetadataProvider>(x => Activator.CreateInstance(x) as IMetadataProvider));
|
||||
}
|
||||
}
|
||||
|
||||
//public Show MergeShows(Show baseShow, Show newShow)
|
||||
//{
|
||||
@ -80,5 +86,15 @@ namespace Kyoo.InternalAPI
|
||||
{
|
||||
return providers[0].GetShowFromName(showName, showPath);
|
||||
}
|
||||
|
||||
public Task<Season> GetSeason(string showName, long seasonNumber)
|
||||
{
|
||||
return providers[0].GetSeason(showName, seasonNumber);
|
||||
}
|
||||
|
||||
public Task<string> GetSeasonImage(string showName, long seasonNumber)
|
||||
{
|
||||
return providers[0].GetSeasonImage(showName, seasonNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,14 +3,28 @@
|
||||
public class Season
|
||||
{
|
||||
public readonly long id;
|
||||
public readonly long ShowID;
|
||||
public long ShowID;
|
||||
|
||||
public long seasonNumber;
|
||||
public string Title;
|
||||
public string Overview;
|
||||
public long year;
|
||||
public long? year;
|
||||
|
||||
public string ImgPrimary;
|
||||
public string ExternalIDs;
|
||||
|
||||
public Season() { }
|
||||
|
||||
public Season(long id, long showID, long seasonNumber, string title, string overview, long? year, string imgPrimary, string externalIDs)
|
||||
{
|
||||
this.id = id;
|
||||
ShowID = showID;
|
||||
this.seasonNumber = seasonNumber;
|
||||
Title = title;
|
||||
Overview = overview;
|
||||
this.year = year;
|
||||
ImgPrimary = imgPrimary;
|
||||
ExternalIDs = externalIDs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user