-
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/2.1.0' into master
- Loading branch information
Showing
48 changed files
with
1,394 additions
and
143 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<table align="center"><tr><td align="center" width="9999"> | ||
<img src="https://download.cdn.yandex.net/from/yandex.ru/support/ru/music/files/icon_main.png" align="center" alt="Project icon" height="150"> | ||
|
||
<h1 style="margin:-30px auto auto auto">YandexMusicResolver</h1> | ||
|
||
A library aimed at searching, resolving and getting direct links to tracks, playlists or albums in Yandex.Music. Can work without authorization. | ||
</td></tr> | ||
</table> | ||
|
||
## Getting started | ||
|
||
<ol type="1"> | ||
|
||
<li> | ||
|
||
Add [nuget package](https://www.nuget.org/packages/YandexMusicResolver/) to your project: | ||
|
||
``` | ||
dotnet add package YandexMusicResolver | ||
``` | ||
or | ||
``` | ||
Install-Package YandexMusicResolver -Version 2.0.0 | ||
``` | ||
</li> | ||
|
||
<li> | ||
|
||
Create configuration instance (`FileYandexConfig` this is the default implementation to save the config to a file) : | ||
|
||
```c# | ||
var config = new FileYandexConfig("path to store config"); | ||
``` | ||
or use empty config (if you don't want save anything): | ||
```c# | ||
var config = new EmptyYandexConfig(); | ||
``` | ||
After that call `Load` to load config: | ||
```c# | ||
config.Load(); | ||
``` | ||
</li> | ||
|
||
<li> | ||
|
||
Create an instance of `YandexMusicMainResolver` and pass config to it | ||
```c# | ||
var yandexMusicMainResolver = new YandexMusicMainResolver(config); | ||
``` | ||
After that we can use `YandexMusicMainResolver` methods and other loaders methods. | ||
</li> | ||
|
||
</ol> | ||
|
||
Example code for getting direct track download url: | ||
```c# | ||
var fileYandexConfig = new FileYandexConfig("yandex.config"); | ||
fileYandexConfig.Load(); | ||
var yandexMusicMainResolver = new YandexMusicMainResolver(fileYandexConfig); | ||
var directUrl = await yandexMusicMainResolver.DirectUrlLoader.GetDirectUrl("55561798", "mp3"); | ||
Console.WriteLine(directUrl); | ||
``` | ||
**Warn:** Yandex will return a link to a 30-seconds track if you do not log in (do not use a config with a valid token). | ||
|
||
Methods to assist with authorization can be found in `YandexMusicAuth`. | ||
|
||
For additional examples you can take a look at unit test project. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using System; | ||
#nullable enable | ||
using System; | ||
using System.Net; | ||
using YandexMusicResolver.Config; | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
using System; | ||
using System.Runtime.Serialization; | ||
using YandexMusicResolver.Responces; | ||
|
||
namespace YandexMusicResolver { | ||
/// <summary> | ||
/// Represents errors that returned from yandex api. | ||
/// </summary> | ||
[Serializable] | ||
public class YandexApiResponseException : Exception { | ||
/// <summary> | ||
/// Contains info about error from yandex api | ||
/// </summary> | ||
public MetaError ApiMetaError { get; private set; } | ||
|
||
/// <inheritdoc /> | ||
public YandexApiResponseException(MetaError apiMetaError) { | ||
ApiMetaError = apiMetaError; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public YandexApiResponseException(string message, MetaError apiMetaError) : base(message) { | ||
ApiMetaError = apiMetaError; | ||
} | ||
|
||
protected YandexApiResponseException( | ||
SerializationInfo info, | ||
StreamingContext context) : base(info, context) { } | ||
} | ||
} |
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 |
---|---|---|
@@ -1,15 +1,35 @@ | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace YandexMusicResolver.AudioItems { | ||
/// <summary> | ||
/// Represents playlist from Yandex Music | ||
/// </summary> | ||
public class YandexMusicPlaylist : IAudioItem { | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="YandexMusicPlaylist"/> class. | ||
/// </summary> | ||
/// <param name="title">Playlist title</param> | ||
/// <param name="tracks">Collection with tracks</param> | ||
/// <param name="isSearchResult">Is this playlist is search result</param> | ||
public YandexMusicPlaylist(string title, ReadOnlyCollection<YandexMusicTrack> tracks, bool isSearchResult) { | ||
Title = title; | ||
Tracks = tracks; | ||
IsSearchResult = isSearchResult; | ||
} | ||
|
||
/// <summary> | ||
/// Playlist title | ||
/// </summary> | ||
public string Title { get; } | ||
|
||
/// <summary> | ||
/// Collection with tracks in playlist | ||
/// </summary> | ||
public ReadOnlyCollection<YandexMusicTrack> Tracks { get; } | ||
|
||
/// <summary> | ||
/// Is this playlist a search result | ||
/// </summary> | ||
public bool IsSearchResult { get; } | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
using System.Net; | ||
|
||
namespace YandexMusicResolver.Config { | ||
/// <summary> | ||
/// Represents <see cref="IYandexConfig"/> implementation placeholder | ||
/// </summary> | ||
public class EmptyYandexConfig : IYandexConfig { | ||
public void Load() { | ||
|
||
} | ||
/// <inheritdoc /> | ||
public void Load() { } | ||
|
||
public void Save() { | ||
|
||
} | ||
/// <inheritdoc /> | ||
public void Save() { } | ||
|
||
/// <inheritdoc /> | ||
public string? YandexLogin { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public string? YandexPassword { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public string? YandexToken { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public IWebProxy? YandexProxy { get; set; } | ||
} | ||
} |
Oops, something went wrong.