Fix some stuff
This commit is contained in:
parent
53b6f8b27f
commit
03408687a8
|
@ -310,7 +310,8 @@ namespace Tesses.YouTubeDownloader
|
||||||
{
|
{
|
||||||
foreach(var item in Videos)
|
foreach(var item in Videos)
|
||||||
{
|
{
|
||||||
if(await baseCls.FileExistsAsync($"Info/{item}.json"))
|
VideoId? id = VideoId.TryParse(item);
|
||||||
|
if(id.HasValue && await baseCls.VideoExistsAsync(id.Value))
|
||||||
{
|
{
|
||||||
yield return await baseCls.GetVideoInfoAsync(item);
|
yield return await baseCls.GetVideoInfoAsync(item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,9 +89,10 @@ namespace Tesses.YouTubeDownloader
|
||||||
}
|
}
|
||||||
public async Task WriteAllBytesAsync(string path,byte[] data,CancellationToken token=default(CancellationToken))
|
public async Task WriteAllBytesAsync(string path,byte[] data,CancellationToken token=default(CancellationToken))
|
||||||
{
|
{
|
||||||
|
MemoryStream ms = new MemoryStream(data);
|
||||||
using(var s=await CreateAsync(path))
|
using(var s=await CreateAsync(path))
|
||||||
{
|
{
|
||||||
await s.WriteAsync(data,0,data.Length,token);
|
await ms.CopyToAsync(s,4096,token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public EventHandler<ConsoleWriteEventArgs> ConsoleWrite;
|
public EventHandler<ConsoleWriteEventArgs> ConsoleWrite;
|
||||||
|
|
|
@ -141,17 +141,14 @@ namespace Tesses.YouTubeDownloader
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<byte[]> ReadAllBytesAsync(string path,CancellationToken token=default(CancellationToken))
|
public async Task<byte[]> ReadAllBytesAsync(string path,CancellationToken token=default(CancellationToken))
|
||||||
{using(var strm = await OpenReadAsync(path))
|
{
|
||||||
|
MemoryStream memoryStream=new MemoryStream();
|
||||||
|
using(var strm = await OpenReadAsync(path))
|
||||||
{
|
{
|
||||||
byte[] data=new byte[strm.Length];
|
await strm.CopyToAsync(memoryStream,4096,token);
|
||||||
|
|
||||||
await strm.ReadAsync(data,0,data.Length,token);
|
|
||||||
if(token.IsCancellationRequested)
|
|
||||||
{
|
|
||||||
return new byte[0];
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
return memoryStream.ToArray();
|
||||||
|
|
||||||
}
|
}
|
||||||
public virtual async IAsyncEnumerable<string> GetPlaylistIdsAsync()
|
public virtual async IAsyncEnumerable<string> GetPlaylistIdsAsync()
|
||||||
|
|
|
@ -482,8 +482,10 @@ internal class SegmentedHttpStream : Stream
|
||||||
|
|
||||||
public async Task ReplacePersonalPlaylistAsync(string name, IEnumerable<ListContentItem> items)
|
public async Task ReplacePersonalPlaylistAsync(string name, IEnumerable<ListContentItem> items)
|
||||||
{
|
{
|
||||||
DeletePersonalPlaylist(name);
|
var content = new MultipartFormDataContent();
|
||||||
await AddToPersonalPlaylistAsync(name,items);
|
content.Add(new StringContent(name), "name");
|
||||||
|
content.Add(new StringContent(JsonConvert.SerializeObject(items.ToList())), "data");
|
||||||
|
await client.PostAsync($"{url}api/v2/ReplaceList",content);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task RemoveItemFromPersonalPlaylistAsync(string name, VideoId id)
|
public async Task RemoveItemFromPersonalPlaylistAsync(string name, VideoId id)
|
||||||
|
@ -516,7 +518,7 @@ internal class SegmentedHttpStream : Stream
|
||||||
try{
|
try{
|
||||||
|
|
||||||
|
|
||||||
client.GetStringAsync($"{url}api/v2/DeleteList?name={WebUtility.UrlEncode(name)}").GetAwaiter().GetResult();
|
Task.Run(()=>client.GetStringAsync($"{url}api/v2/DeleteList?name={WebUtility.UrlEncode(name)}")).GetAwaiter().GetResult();
|
||||||
|
|
||||||
}catch(Exception ex)
|
}catch(Exception ex)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue