-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/3.0.0' into master
- Loading branch information
Showing
51 changed files
with
812 additions
and
922 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using YandexMusicResolver.Loaders; | ||
|
||
namespace YandexMusicResolver.AudioItems { | ||
public class YandexMusicAlbum : YandexMusicDataContainer<List<YandexMusicTrack>> { | ||
internal YandexMusicAlbum(long id, long year, List<YandexMusicArtist> artists, string? artworkUrl, long trackCount, string genre, string title, | ||
YandexMusicPlaylistLoader loader) : base(async () => (await loader.LoadAlbum(id.ToString()))!.Data.ToList()) { | ||
Id = id; | ||
Year = year; | ||
Artists = artists; | ||
ArtworkUrl = artworkUrl; | ||
TrackCount = trackCount; | ||
Genre = genre; | ||
Title = title; | ||
} | ||
|
||
internal YandexMusicAlbum(long id, long year, List<YandexMusicArtist> artists, string? artworkUrl, long trackCount, string genre, string title, | ||
List<YandexMusicTrack> tracks) : base(tracks) { | ||
Id = id; | ||
Year = year; | ||
Artists = artists; | ||
ArtworkUrl = artworkUrl; | ||
TrackCount = trackCount; | ||
Genre = genre; | ||
Title = title; | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Album id | ||
/// </summary> | ||
public long Id { get; } | ||
|
||
/// <summary> | ||
/// Album release year | ||
/// </summary> | ||
public long Year { get; } | ||
|
||
/// <summary> | ||
/// Album artists | ||
/// </summary> | ||
public List<YandexMusicArtist> Artists { get; } | ||
|
||
/// <summary> | ||
/// Track image uri | ||
/// </summary> | ||
public string? ArtworkUrl { get; } | ||
|
||
/// <summary> | ||
/// Album tracks count | ||
/// </summary> | ||
public long TrackCount { get; } | ||
|
||
/// <summary> | ||
/// Album genre | ||
/// </summary> | ||
public string Genre { get; } | ||
|
||
/// <summary> | ||
/// Track title | ||
/// </summary> | ||
public string Title { get; } | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
YandexMusicResolver/Responces/MetaArtist.cs → ...cResolver/AudioItems/YandexMusicArtist.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
YandexMusicResolver/AudioItems/YandexMusicDataContainer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace YandexMusicResolver.AudioItems { | ||
/// <summary> | ||
/// Represents class that contains data which could be loaded | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public abstract class YandexMusicDataContainer<T> { | ||
private Func<Task<T>> loadDataFactory; | ||
private Task<T>? _loadDataTask; | ||
|
||
/// <summary> | ||
/// Create instance of <see cref="YandexMusicDataContainer{T}"/> | ||
/// </summary> | ||
/// <param name="loadDataFactory">Data creation factory</param> | ||
public YandexMusicDataContainer(Func<Task<T>> loadDataFactory) { | ||
this.loadDataFactory = loadDataFactory; | ||
} | ||
|
||
/// <summary> | ||
/// Create instance of <see cref="YandexMusicDataContainer{T}"/> | ||
/// </summary> | ||
/// <param name="data">Target data</param> | ||
public YandexMusicDataContainer(T data) { | ||
var task = Task.FromResult(data); | ||
loadDataFactory = () => task; | ||
_loadDataTask = task; | ||
} | ||
|
||
private Task<T> LoadDataTask => _loadDataTask ??= loadDataFactory(); | ||
|
||
/// <summary> | ||
/// Load target data | ||
/// </summary> | ||
/// <returns>Task</returns> | ||
public Task<T> LoadDataAsync() { | ||
return LoadDataTask; | ||
} | ||
|
||
/// <summary> | ||
/// Return true if data already loaded | ||
/// </summary> | ||
public bool IsDataLoaded => _loadDataTask?.IsCompleted ?? false; | ||
|
||
/// <summary> | ||
/// Synchronously wait for data loading | ||
/// </summary> | ||
public T Data => LoadDataAsync().ConfigureAwait(false).GetAwaiter().GetResult(); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
YandexMusicResolver/Responces/MetaOwner.cs → ...icResolver/AudioItems/YandexMusicOwner.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.