Archived
1
0

Core refactoring (app doesn't work)

This commit is contained in:
Michael Gordeev
2020-05-09 23:16:19 +03:00
parent 2b1f06dd93
commit 2a987e33a2
35 changed files with 1135 additions and 817 deletions
+48
View File
@@ -0,0 +1,48 @@
using Google.Apis.YouTube.v3.Data;
using System;
using YoutubeExplode;
namespace FoxTube.Models
{
public class VideoItem
{
public Video Meta { get; set; }
public YoutubeExplode.Videos.Video AdditionalMeta { get; set; }
public YoutubeExplode.Channels.Channel ChannelMeta { get; set; }
public string TimeLabel { get; set; }
public string ViewsLabel { get; set; }
public int LiveLabelOpacity => Meta?.LiveStreamingDetails == null ? 0 : 1;
public string LiveLabel
{
get
{
if (Meta?.LiveStreamingDetails == null)
return "";
else if (Meta.LiveStreamingDetails.ActualStartTime.HasValue)
return "LIVE";
else if (Meta.LiveStreamingDetails.ScheduledStartTime.HasValue)
return $"Live in {Meta.LiveStreamingDetails.ScheduledStartTime - DateTime.Now}";
else
return "Upcoming";
}
}
public VideoItem(Video meta)
{
Meta = meta;
LoadInfo();
}
private async void LoadInfo()
{
YoutubeClient client = new YoutubeClient(UserManagement.Service.HttpClient);
AdditionalMeta = await client.Videos.GetAsync(Meta.Id);
ChannelMeta = await client.Channels.GetByVideoAsync(Meta.Id);
TimeLabel = $"{AdditionalMeta?.Duration} • {AdditionalMeta.UploadDate.DateTime.GetFriendlyDate()}";
ViewsLabel = $"{AdditionalMeta?.Engagement.ViewCount} views";
}
}
}