DeezNET 1.1.0
See the version list below for details.
dotnet add package DeezNET --version 1.1.0
NuGet\Install-Package DeezNET -Version 1.1.0
<PackageReference Include="DeezNET" Version="1.1.0" />
paket add DeezNET --version 1.1.0
#r "nuget: DeezNET, 1.1.0"
// Install DeezNET as a Cake Addin #addin nuget:?package=DeezNET&version=1.1.0 // Install DeezNET as a Cake Tool #tool nuget:?package=DeezNET&version=1.1.0
DeezNET
A .NET Deezer API wrapper and track downloading library. There's a CLI tool in there as well.
Dear Deezer
If you would like this repository to be taken down, please send me a cease and desist.<br> You may e-mail it to me here: me@trev.app.
Or go through the standard GitHub DMCA procedure, but that isn't as fun.
Dependencies
- Newtonsoft.Json for every API call
- BouncyCastle.Cryptography for decrypting track data (
client.Downloader.GetRawTrackBytes()
) - TagLibSharp for applying metadata to decrypted track data (
client.Downloader.ApplyMetadataToTrackBytes()
)
Overview
DeezNET is built around a core class, DeezerClient
. That class itself does very little, under it is Downloader
, GWApi
, and PublicApi
.
Downloader
provides functions for downloading tracks by their ID, as well as applying metadata. It requires an ARL supplied toDeezerClient
to function.GWApi
is a wrapper for the backend API used by Deezer. It requires an ARL supplied toDeezerClient
to function.PublicApi
is a wrapper for the public Deezer API. It does not require an ARL.
All API calls return a Newtonsoft.JSON JToken as I did not want to deal with parsing everything into model classes since there are many different API endpoints.
In addition to DeezerClient
, there is DeezerURL
which is a class for parsing Deezer URLs into their entity type and ID. It also handles unshortening the standard Deezer share URLs (deezer.page.link).
Examples
Getting Track Info (PublicApi
)
var client = new DeezerClient();
var trackData = await client.PublicApi.GetTrack(1903638027);
Console.WriteLine($"{trackData["title"]!} by {trackData["contributors"]!.First()["name"]!}");
// Output: Let You Down by Dawid Podsiadło
Getting Track Info (GWApi
)
var client = new DeezerClient();
await client.SetARL("[ARL]");
var trackData = await client.GWApi.GetTrack(1903638027);
Console.WriteLine($"{trackData["SNG_TITLE"]!} by {trackData["ART_NAME"]!}");
// Output: Let You Down by Dawid Podsiadło
Downloading a Track by ID
var client = new DeezerClient();
await client.SetARL("[ARL]");
var trackBytes = await client.Downloader.GetRawTrackBytes(1903638027, DeezNET.Data.Bitrate.FLAC);
trackBytes = await client.Downloader.ApplyMetadataToTrackBytes(1903638027, trackBytes); // if you want metadata
File.WriteAllBytes(Path.Combine(Environment.CurrentDirectory, "LYD.flac"), trackBytes);
// Saves a metadata-applied FLAC of Let You Down by Dawid Podsiadło to your current working directory
Downloading an Album by URL
var client = new DeezerClient();
await client.SetARL("[ARL]");
var urlData = DeezerURL.Parse("https://deezer.page.link/uwdUFsjkJbGkngSm7"); // this is a short URL, can also be a full one like "https://www.deezer.com/us/album/548556802"
var tracksInAlbum = await urlData.GetAssociatedTracks(client);
foreach (var track in tracksInAlbum)
{
var trackBytes = await client.Downloader.GetRawTrackBytes(track, DeezNET.Data.Bitrate.FLAC);
trackBytes = await client.Downloader.ApplyMetadataToTrackBytes(track, trackBytes); // if you want metadata
File.WriteAllBytes(Path.Combine(Environment.CurrentDirectory, $"{track}.flac"), trackBytes);
}
// Saves metadata-applied FLACs of every track in GLOOM DIVISION by I DONT KNOW HOW BUT THEY FOUND ME to your current working directory
DeezCLI
USAGE
DeezCLI <url> [options]
DESCRIPTION
Downloads the given URL.
PARAMETERS
* url The URL of the item to download. Can be a shortened URL.
OPTIONS
-b|--bitrate The preferred bitrate when downloading. Falls back to a lower quality if unavailable. Choices: "MP3_128", "MP3_320", "FLAC". Default: "FLAC".
-m|--add-metadata Whether to attach metadata to the downloaded audio file. Default: "True".
-o|--output The directory to save downloaded media to. Default: Current Working Directory.
-a|--arl The account ARL to download with. A paid plan allows for higher quality downloads. Some regions do not have full tracks available without a premium account. Default: "".
-l|--top-limit The max amount of tracks to download. Only applicable when downloading an artist's top tracks. Default: "100".
-c|--concurrent The max amount of allowed concurrent track downloads. Default: "3".
-d|--folder-template The folder path template to use when saving tracks to file. Default: "%albumartist%/%album%/".
-f|--file-template The file path template to use when saving tracks to file. Default: "%track% - %title%.%ext%".
-h|--help Shows help text.
--version Shows version information.
AVAILABLE TEMPLATE VARIABLES
%title%
%album%
%albumartist%
%artist%
%albumartists%
%artists%
%track%
%trackcount%
%trackid%
%albumid%
%artistid%
%ext%
%year%
Credits
- This project is heavily based on deemix-py and deezer-py, both under the GNU GPLv3 License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- BouncyCastle.Cryptography (>= 2.4.0)
- Newtonsoft.Json (>= 13.0.3)
- TagLibSharp (>= 2.3.0)
-
net8.0
- BouncyCastle.Cryptography (>= 2.4.0)
- Newtonsoft.Json (>= 13.0.3)
- TagLibSharp (>= 2.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.