diff --git a/Tesses.YouTubeDownloader/TYTDIDownloaderStorageProxy.cs b/Tesses.YouTubeDownloader/TYTDIDownloaderStorageProxy.cs index 94d3d43..97a384f 100644 --- a/Tesses.YouTubeDownloader/TYTDIDownloaderStorageProxy.cs +++ b/Tesses.YouTubeDownloader/TYTDIDownloaderStorageProxy.cs @@ -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 callback) + { + var store = Downloader as ITYTDBase; + if(store != null && callback != null) await callback(store); + } + public void DownloaderAsITYTDBase(Action 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 GetPersonalPlaylistContentsAsync(string name) { - IAsyncEnumerable 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 GetPersonalPlaylistsAsync() { - await foreach(var item in Storage.GetPersonalPlaylistsAsync()) - { - yield return await Task.FromResult(item); - } - + if(Downloader == null) yield break; + IAsyncEnumerable 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 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 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); + } diff --git a/Tesses.YouTubeDownloader/Tesses.YouTubeDownloader.csproj b/Tesses.YouTubeDownloader/Tesses.YouTubeDownloader.csproj index 46c987d..1b4329b 100644 --- a/Tesses.YouTubeDownloader/Tesses.YouTubeDownloader.csproj +++ b/Tesses.YouTubeDownloader/Tesses.YouTubeDownloader.csproj @@ -7,9 +7,9 @@ Tesses.YouTubeDownloader Mike Nolan Tesses - 1.2.1 - 1.2.1 - 1.2.1 + 1.2.2 + 1.2.2 + 1.2.2 A YouTube Downloader LGPL-3.0-only true