88 lines
3.2 KiB
C#
88 lines
3.2 KiB
C#
|
using System.Text;
|
||
|
using YoutubeExplode.Common;
|
||
|
using YoutubeExplode.Videos;
|
||
|
|
||
|
public class SavedVideo
|
||
|
{
|
||
|
public SavedVideo()
|
||
|
{
|
||
|
Id = "";
|
||
|
Title = "";
|
||
|
AuthorChannelId = "";
|
||
|
AuthorTitle = "";
|
||
|
Description = "";
|
||
|
Keywords = new string[0];
|
||
|
Likes = 0;
|
||
|
Dislikes = 0;
|
||
|
Views = 0;
|
||
|
Duration = TimeSpan.Zero;
|
||
|
UploadDate=new DateTime(1992,8,20);
|
||
|
AddDate=DateTime.Now;
|
||
|
LegacyVideo=false;
|
||
|
}
|
||
|
public SavedVideo(Video video)
|
||
|
{
|
||
|
Id=video.Id;
|
||
|
Title = video.Title;
|
||
|
AuthorChannelId = video.Author.ChannelId;
|
||
|
AuthorTitle = video.Author.ChannelTitle;
|
||
|
Description = video.Description;
|
||
|
Keywords=video.Keywords.ToArray();
|
||
|
Likes=video.Engagement.LikeCount;
|
||
|
Dislikes = video.Engagement.DislikeCount;
|
||
|
Views = video.Engagement.ViewCount;
|
||
|
Duration = video.Duration.Value;
|
||
|
UploadDate = video.UploadDate.DateTime;
|
||
|
AddDate=DateTime.Now;
|
||
|
LegacyVideo=false;
|
||
|
}
|
||
|
public bool LegacyVideo {get;set;}
|
||
|
|
||
|
|
||
|
public Video ToVideo()
|
||
|
{
|
||
|
List<Thumbnail> thumbnails=new List<Thumbnail>();
|
||
|
thumbnails.Add(new Thumbnail($"https://s.ytimg.com/vi/{Id}/default.jpg",new YoutubeExplode.Common.Resolution(120,90)));
|
||
|
thumbnails.Add(new Thumbnail($"https://s.ytimg.com/vi/{Id}/hqdefault.jpg",new YoutubeExplode.Common.Resolution(480,360)));
|
||
|
thumbnails.Add(new Thumbnail($"https://s.ytimg.com/vi/{Id}/mqdefault.jpg",new YoutubeExplode.Common.Resolution(320,180)));
|
||
|
|
||
|
return new Video(Id,Title,new YoutubeExplode.Common.Author(AuthorChannelId,AuthorTitle),new DateTimeOffset(UploadDate),Description,Duration,thumbnails,Keywords.ToList(),new Engagement(Views,Likes,Dislikes));
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
public DateTime AddDate {get;set;}
|
||
|
public string Title { get; set; }
|
||
|
public DateTime UploadDate { get; set; }
|
||
|
public string[] Keywords { get; set; }
|
||
|
public string Id { get; set; }
|
||
|
public string AuthorTitle { get; set; }
|
||
|
public string AuthorChannelId { get; set; }
|
||
|
|
||
|
public string Description { get; set; }
|
||
|
|
||
|
public TimeSpan Duration { get; set; }
|
||
|
|
||
|
public long Views { get; set; }
|
||
|
public long Likes { get; set; }
|
||
|
public long Dislikes { get; set; }
|
||
|
|
||
|
|
||
|
|
||
|
public override string ToString()
|
||
|
{
|
||
|
StringBuilder b=new StringBuilder();
|
||
|
b.AppendLine($"Title: {Title}");
|
||
|
b.AppendLine($"AuthorTitle: {AuthorTitle}");
|
||
|
DateTime date=UploadDate;
|
||
|
|
||
|
b.AppendLine($"Upload Date: {date.ToShortDateString()}");
|
||
|
|
||
|
b.AppendLine($"Likes: {Likes}, Dislikes: {Dislikes}, Views: {Views}");
|
||
|
b.AppendLine($"Duration: {Duration.ToString()}");
|
||
|
b.AppendLine($"Tags: {string.Join(", ",Keywords)}");
|
||
|
b.AppendLine("Description:");
|
||
|
b.AppendLine(Description);
|
||
|
return b.ToString();
|
||
|
}
|
||
|
}
|