Added duration and tags to videos
This commit is contained in:
@ -26,6 +26,12 @@ namespace YTManager.Controllers {
|
||||
// Channel on youtube that owns this video
|
||||
public string Channel;
|
||||
|
||||
// Duration of the video in seconds.
|
||||
public int Seconds;
|
||||
|
||||
// What tags are relevant with this video.
|
||||
public List<string> Tags;
|
||||
|
||||
// Populate this struct using a model video.
|
||||
public Video_ForAPI(Models.Video video) {
|
||||
Title = video.Title;
|
||||
@ -33,6 +39,8 @@ namespace YTManager.Controllers {
|
||||
ID = video.YoutubeID;
|
||||
Thumbnail = video.ThumbnailURL;
|
||||
Channel = video.Channel.Title;
|
||||
Seconds = (int)video.Duration.TotalSeconds;
|
||||
Tags = video.Tags?.Select(t => t.Name).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,9 +58,10 @@ namespace YTManager.Controllers {
|
||||
public async Task<IActionResult> GetVideos() {
|
||||
// Get all the relevant videos.
|
||||
var vids = await db.Videos
|
||||
.Include(v => v.Channel)
|
||||
.OrderByDescending(i => i.AddedToYT)
|
||||
.Take(max_per_query)
|
||||
.Include(v => v.Channel)
|
||||
.Include(v => v.Tags)
|
||||
.ToListAsync();
|
||||
|
||||
// Convert them to what we will send out.
|
||||
@ -69,10 +78,11 @@ namespace YTManager.Controllers {
|
||||
public async Task<IActionResult> Get_Channel_Videos([FromRoute] string channelName) {
|
||||
// Get all the relevant videos.
|
||||
var vids = await db.Videos
|
||||
.Include(v => v.Channel)
|
||||
.Where(v => v.Channel.Title == channelName)
|
||||
.OrderByDescending(i => i.AddedToYT)
|
||||
.Take(max_per_query)
|
||||
.Include(v => v.Channel)
|
||||
.Include(v => v.Tags)
|
||||
.ToListAsync();
|
||||
|
||||
// Convert them to what we will send out.
|
||||
|
Reference in New Issue
Block a user