Made Personal Lists on Downloader in proxy

This commit is contained in:
Mike Nolan 2022-11-01 01:00:57 -05:00
parent 75fe70a1e7
commit ce2cd5b0f9
2 changed files with 44 additions and 32 deletions

View File

@ -149,6 +149,16 @@ namespace Tesses.YouTubeDownloader
var store = Storage as IWritable;
if(store != null && callback != null) await callback(store);
}
public async Task DownloaderAsITYTDBaseAsync(Func<ITYTDBase,Task> callback)
{
var store = Downloader as ITYTDBase;
if(store != null && callback != null) await callback(store);
}
public void DownloaderAsITYTDBase(Action<ITYTDBase> callback)
{
var store = Downloader as ITYTDBase;
if(store != null && callback != null) callback(store);
}
public DownloaderMigration Migration
@ -332,13 +342,9 @@ namespace Tesses.YouTubeDownloader
public async IAsyncEnumerable<ListContentItem> GetPersonalPlaylistContentsAsync(string name)
{
IAsyncEnumerable<ListContentItem> items=null;
StorageAsStorage((e)=>{
items=e.GetPersonalPlaylistContentsAsync(name);
});
if(items == null) yield break;
await foreach(var item in items)
if(Downloader == null) yield break;
await foreach(var item in Downloader.GetPersonalPlaylistContentsAsync(name))
{
yield return await Task.FromResult(item);
}
@ -431,11 +437,17 @@ namespace Tesses.YouTubeDownloader
public async IAsyncEnumerable<string> GetPersonalPlaylistsAsync()
{
await foreach(var item in Storage.GetPersonalPlaylistsAsync())
{
yield return await Task.FromResult(item);
}
if(Downloader == null) yield break;
IAsyncEnumerable<string> items=null;
DownloaderAsITYTDBase((e)=>{
items=e.GetPersonalPlaylistsAsync();
});
if(items == null) yield break;
await foreach(var item in items)
{
yield return await Task.FromResult(item);
}
}
public async Task<(string Path, bool Delete)> GetRealUrlOrPathAsync(string path)
@ -630,43 +642,43 @@ namespace Tesses.YouTubeDownloader
public async Task AddToPersonalPlaylistAsync(string name, IEnumerable<ListContentItem> items)
{
await StorageAsStorageAsync(async(e)=>{
await e.AddToPersonalPlaylistAsync(name,items);
});
if(Downloader ==null) return;
await Downloader.AddToPersonalPlaylistAsync(name,items);
}
public async Task ReplacePersonalPlaylistAsync(string name, IEnumerable<ListContentItem> items)
{
await StorageAsStorageAsync(async(e)=>{
await e.ReplacePersonalPlaylistAsync(name,items);
});
if(Downloader ==null) return;
await Downloader.ReplacePersonalPlaylistAsync(name,items);
}
public async Task RemoveItemFromPersonalPlaylistAsync(string name, VideoId id)
{
await StorageAsStorageAsync(async(e)=>{
await e.RemoveItemFromPersonalPlaylistAsync(name,id);
});
if(Downloader ==null) return;
await Downloader.RemoveItemFromPersonalPlaylistAsync(name,id);
}
public async Task SetResolutionForItemInPersonalPlaylistAsync(string name, VideoId id, Resolution resolution)
{
await StorageAsStorageAsync(async(e)=>{
await e.SetResolutionForItemInPersonalPlaylistAsync(name,id,resolution);
});
if(Downloader ==null) return;
await Downloader.SetResolutionForItemInPersonalPlaylistAsync(name,id,resolution);
}
public bool PersonalPlaylistExists(string name)
{
if(Storage ==null) return false;
return Storage.PersonalPlaylistExists(name);
if(Downloader ==null) return false;
return Downloader.PersonalPlaylistExists(name);
}
public void DeletePersonalPlaylist(string name)
{
StorageAsStorage((e)=>{
e.DeletePersonalPlaylist(name);
});
if(Downloader ==null) return;
Downloader.DeletePersonalPlaylist(name);
}

View File

@ -7,9 +7,9 @@
<PackageId>Tesses.YouTubeDownloader</PackageId>
<Author>Mike Nolan</Author>
<Company>Tesses</Company>
<Version>1.2.1</Version>
<AssemblyVersion>1.2.1</AssemblyVersion>
<FileVersion>1.2.1</FileVersion>
<Version>1.2.2</Version>
<AssemblyVersion>1.2.2</AssemblyVersion>
<FileVersion>1.2.2</FileVersion>
<Description>A YouTube Downloader</Description>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>