tytd-server/Server/Models/InfoType.cs

56 lines
1.8 KiB
C#
Raw Normal View History

2021-09-25 06:18:12 +00:00
using YoutubeExplode.Channels;
using YoutubeExplode.Playlists;
using YoutubeExplode.Videos;
namespace youtube_downloader.Server.Models
2021-06-25 08:30:45 +00:00
{
public enum InfoType
{
Video=0,
Playlist=1,
Channel=2,
User=3,
ClosedCaptions=4
}
2021-09-25 06:18:12 +00:00
public class IDResolutionTypeTriplet
{
public string Id { get; set; }
public InfoType Type { get; set; }
public TessesYoutubeDownloader.Server.Models.Resolution Resolution { get; set; }
public InfomationQueueItem ToInfomationQueueItem(bool download=true)
{
switch(Type)
{
case InfoType.Video:
VideoId? vid = VideoId.TryParse(Id);
if (vid.HasValue)
{
return new InfomationQueueItem(vid.Value, Resolution, download);
}
break;
case InfoType.Playlist:
PlaylistId? pid = PlaylistId.TryParse(Id);
if (pid.HasValue)
{
return new InfomationQueueItem(pid.Value, Resolution, download);
}
break;
case InfoType.Channel:
ChannelId? cid = ChannelId.TryParse(Id);
if (cid.HasValue)
{
return new InfomationQueueItem(cid.Value, Resolution, download);
}
break;
case InfoType.User:
UserName? user = UserName.TryParse(Id);
if (user.HasValue)
{
return new InfomationQueueItem(user.Value, Resolution, download);
}
break;
}
return null;
}
}
2021-06-25 08:30:45 +00:00
}