mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-02 21:24:20 -04:00
Adding season support.
This commit is contained in:
parent
95aa65d443
commit
3a378a0ac9
@ -12,10 +12,12 @@ namespace Kyoo.InternalAPI
|
|||||||
List<People> GetDirectors(long showID);
|
List<People> GetDirectors(long showID);
|
||||||
List<People> GetPeople(long showID);
|
List<People> GetPeople(long showID);
|
||||||
List<Genre> GetGenreForShow(long showID);
|
List<Genre> GetGenreForShow(long showID);
|
||||||
|
List<Season> GetSeasons(long showID);
|
||||||
|
|
||||||
//Public read
|
//Public read
|
||||||
IEnumerable<Library> GetLibraries();
|
IEnumerable<Library> GetLibraries();
|
||||||
Show GetShowBySlug(string slug);
|
Show GetShowBySlug(string slug);
|
||||||
|
Season GetSeason(string showSlug, long seasonNumber);
|
||||||
People GetPeopleBySlug(string slug);
|
People GetPeopleBySlug(string slug);
|
||||||
Genre GetGenreBySlug(string slug);
|
Genre GetGenreBySlug(string slug);
|
||||||
Studio GetStudioBySlug(string slug);
|
Studio GetStudioBySlug(string slug);
|
||||||
|
@ -223,7 +223,42 @@ namespace Kyoo.InternalAPI
|
|||||||
SQLiteDataReader reader = cmd.ExecuteReader();
|
SQLiteDataReader reader = cmd.ExecuteReader();
|
||||||
|
|
||||||
if (reader.Read())
|
if (reader.Read())
|
||||||
return Show.FromReader(reader).SetGenres(this).SetStudio(this).SetDirectors(this).SetPeople(this);
|
return Show.FromReader(reader).SetGenres(this).SetStudio(this).SetDirectors(this).SetSeasons(this).SetPeople(this);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Season> GetSeasons(long showID)
|
||||||
|
{
|
||||||
|
string query = "SELECT * FROM seasons WHERE showID = $showID;";
|
||||||
|
|
||||||
|
using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection))
|
||||||
|
{
|
||||||
|
cmd.Parameters.AddWithValue("$showID", showID);
|
||||||
|
SQLiteDataReader reader = cmd.ExecuteReader();
|
||||||
|
|
||||||
|
List<Season> seasons = new List<Season>();
|
||||||
|
|
||||||
|
while (reader.Read())
|
||||||
|
seasons.Add(Season.FromReader(reader));
|
||||||
|
|
||||||
|
return seasons;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Season GetSeason(string showSlug, long seasonNumber)
|
||||||
|
{
|
||||||
|
string query = "SELECT * FROM seasons JOIN shows ON shows.id = seasons.showID WHERE shows.slug = $showSlug AND seasons.seasonNumber = $seasonNumber;";
|
||||||
|
|
||||||
|
using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection))
|
||||||
|
{
|
||||||
|
cmd.Parameters.AddWithValue("$showSlug", showSlug);
|
||||||
|
cmd.Parameters.AddWithValue("$seasonNumber", seasonNumber);
|
||||||
|
SQLiteDataReader reader = cmd.ExecuteReader();
|
||||||
|
|
||||||
|
if (reader.Read())
|
||||||
|
return Season.FromReader(reader);
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -28,5 +28,17 @@ namespace Kyoo.Models
|
|||||||
ImgPrimary = imgPrimary;
|
ImgPrimary = imgPrimary;
|
||||||
ExternalIDs = externalIDs;
|
ExternalIDs = externalIDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Season FromReader(System.Data.SQLite.SQLiteDataReader reader)
|
||||||
|
{
|
||||||
|
return new Season((long)reader["id"],
|
||||||
|
(long)reader["showID"],
|
||||||
|
(long)reader["seasonNumber"],
|
||||||
|
reader["title"] as string,
|
||||||
|
reader["overview"] as string,
|
||||||
|
reader["year"] as long?,
|
||||||
|
reader["imgPrimary"] as string,
|
||||||
|
reader["externalIDs"] as string);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ namespace Kyoo.Models
|
|||||||
//Used in the rest API excusively.
|
//Used in the rest API excusively.
|
||||||
public Studio studio;
|
public Studio studio;
|
||||||
public IEnumerable<People> directors;
|
public IEnumerable<People> directors;
|
||||||
|
public IEnumerable<Season> seasons;
|
||||||
public IEnumerable<People> people;
|
public IEnumerable<People> people;
|
||||||
|
|
||||||
|
|
||||||
@ -133,6 +134,12 @@ namespace Kyoo.Models
|
|||||||
people = manager.GetPeople(id);
|
people = manager.GetPeople(id);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Show SetSeasons(ILibraryManager manager)
|
||||||
|
{
|
||||||
|
seasons = manager.GetSeasons(id);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Status { Finished, Airing }
|
public enum Status { Finished, Airing }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user