-
Notifications
You must be signed in to change notification settings - Fork 0
Track.GetDirectLink(string downloadInfoUrl, string codec = "mp3")
Returns a link to the track (file to music, you can download)
Example:
using System;
using System.Linq;
using Newtonsoft.Json.Linq;
using YandexMusicApi;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Token.token = "YOURTOKEN";
JObject result = Track.GetDownloadInfoWithToken("34976783"); //TrackID: Imagine Dragons
Console.WriteLine(result);
var resultData = result.GetValue("result");
resultData = resultData[0];
foreach (var i in resultData.ToList())
{
Console.WriteLine(i);
}
string url = resultData.ToList()[3].ToList()[0].ToString();
Console.WriteLine("\n" + url);
Console.WriteLine(Track.GetDirectLink(url));
}
}
}
Output:
{ "invocationInfo": { "req-id": "1652294538517297-13590772004246103511", "hostname": "music-stable-back-sas-28.sas.yp-c.yandex.net", "exec-duration-millis": 2 }, "result": [ { "codec": "mp3", "gain": false, "preview": false, "downloadInfoUrl": "https://storage.mds.yandex.net/file-download-info/1751270_2f9bf813.107036630.1.34976783/2?sign=398f4beb5fe63a3b7426aa0a05fe61c09875a75638ac67b8220d453af40069c4&ts=627c03c6&offset=29427", "direct": false, "bitrateInKbps": 192 }, { "codec": "mp3", "gain": false, "preview": false, "downloadInfoUrl": "https://storage.mds.yandex.net/file-download-info/1751270_2f9bf813.107036630.5.34976783/320?sign=1740466daf8684c9a55f7bc33ce97496c3a6d0010b47e30386d35f953b59cfb8&ts=627c03c6&offset=29439", "direct": false, "bitrateInKbps": 320 }, { "codec": "aac", "gain": true, "preview": false, "downloadInfoUrl": "https://storage.mds.yandex.net/file-download-info/1751270_2f9bf813.107036630.9.34976783/g128?sign=44dcf9f2a6e4eee78ecfc8887ccbac8d9f404294a4e3715647e6c04253d9f091&ts=627c03c6", "direct": false, "bitrateInKbps": 128 } ] } "codec": "mp3" "gain": false "preview": false "downloadInfoUrl": "https://storage.mds.yandex.net/file-download-info/1751270_2f9bf813.107036630.1.34976783/2?sign=398f4beb5fe63a3b7426aa0a05fe61c09875a75638ac67b8220d453af40069c4&ts=627c03c6&offset=29427" "direct": false "bitrateInKbps": 192
s09iva.storage.yandex.net/rmusic/U2FsdGVkX1-s1pfhxUlhUk7YVca9PcAtIjKRY1OzIbr3K4cj-36Pi-gnAAFe3KvGyEdk8nzhCnmmvdzuhH-hTEMWr1k9aqNHnJKtnhxv4iE/ac5a3d7428632ac69d08de83ea2bd701a7036eb9aacffc711648b4d4c43b950c/294270005dec1a3acdd2d-1