This commit is contained in:
Demetria Lovato 2021-06-24 00:47:40 -07:00
parent bf72e8f89e
commit 15340aab60
7 changed files with 52 additions and 21 deletions

Binary file not shown.

View File

@ -322,16 +322,28 @@ namespace youtube_downloader.Server.Functions
private async Task _DownloadChannel(ChannelId id,Resolution res)
{
var c=await ytc.Channels.GetAsync(id);
SavedChannel c2 = SavedChannel.FromChannel(c, _DownloadThumbnail);
string infpath = GetPath(true, "Channel", id + ".json");
File.WriteAllText(infpath, JsonConvert.SerializeObject(c2));
var cvids = await ytc.Channels.GetUploadsAsync(id).ToListAsync();
foreach(var v in cvids)
try
{
await _DownloadVideo(v.Id, res);
}
var c = await ytc.Channels.GetAsync(id);
SavedChannel c2 = SavedChannel.FromChannel(c, _DownloadThumbnail);
string infpath = GetPath(true, "Channel", id + ".json");
File.WriteAllText(infpath, JsonConvert.SerializeObject(c2));
try
{
await ytc.Channels.GetUploadsAsync(c.Id).ForEachAsync(async (v) =>
{
await _DownloadVideo(v.Id, res);
});
}
catch (Exception ex)
{
_ = ex;
}
}catch(Exception ex2)
{
_ = ex2;
}
}
private async Task _DownloadPlaylist(PlaylistId id,Resolution res)
{
@ -341,17 +353,26 @@ namespace youtube_downloader.Server.Functions
}
private async Task _DownloadUser(UserName name, Resolution res)
{
try {
var c = await ytc.Channels.GetByUserAsync(name);
SavedChannel c2 = SavedChannel.FromChannel(c, _DownloadThumbnail);
string infpath = GetPath(true, "Channel", c.Id + ".json");
File.WriteAllText(infpath, JsonConvert.SerializeObject(c2));
var cvids = await ytc.Channels.GetUploadsAsync(c2.Id).ToListAsync();
foreach (var v in cvids)
try
{
await _DownloadVideo(v.Id, res);
await ytc.Channels.GetUploadsAsync(c.Id).ForEachAsync(async(v) =>
{
await _DownloadVideo(v.Id, res);
});
}catch(Exception ex)
{
_ = ex;
}
}
}catch(Exception ex2)
{
_ = ex2;
}
}
public static void DownloadVideo(string id,Resolution res)
{
VideoId? v = VideoId.TryParse(id);

View File

@ -10,9 +10,10 @@ namespace TessesYoutubeDownloader.Server.Models
{
public static async Task<SavedPlaylist> FromPlaylistId(Resolution res,YoutubeExplode.YoutubeClient ytc,YoutubeExplode.Playlists.PlaylistId id,Action<string,Resolution> addToQueue, Action<int, int, string,string> downloadThumbnail)
{
SavedPlaylist pl2 = new SavedPlaylist();
pl2.Videos = new List<string>();
try {
var pl=await ytc.Playlists.GetAsync(id);
var a = pl.Author;
pl2.AuthorChannelId = a.ChannelId;
@ -25,14 +26,23 @@ namespace TessesYoutubeDownloader.Server.Models
{
downloadThumbnail(thumb.Resolution.Width, thumb.Resolution.Height,id, thumb.Url);
}
var cvids = await ytc.Playlists.GetVideosAsync(id).ToListAsync();
foreach (var v in cvids)
try
{
addToQueue(v.Id,res);
pl2.Videos.Add(v.Id);
await ytc.Playlists.GetVideosAsync(id).ForEachAsync((v) =>
{
addToQueue(v.Id, res);
pl2.Videos.Add(v.Id);
});
}catch(Exception ex)
{
_ = ex;
}
}catch(Exception ex2)
{
_ = ex2;
}
return pl2;
}
public List<string> Videos { get; set; }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.