MusicCatalogue.Data 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MusicCatalogue.Data --version 1.1.0                
NuGet\Install-Package MusicCatalogue.Data -Version 1.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MusicCatalogue.Data" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MusicCatalogue.Data --version 1.1.0                
#r "nuget: MusicCatalogue.Data, 1.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MusicCatalogue.Data as a Cake Addin
#addin nuget:?package=MusicCatalogue.Data&version=1.1.0

// Install MusicCatalogue.Data as a Cake Tool
#tool nuget:?package=MusicCatalogue.Data&version=1.1.0                

MusicCatalogue

Build Status GitHub issues Coverage Status Releases License: MIT Language Language GitHub code size in bytes

Overview

  • To be completed once the web service and GUI have been implemented

The Console Lookup Tool

  • The application provides a simple command line interface for looking up albums one at a time
  • The results are stored in a local SQLite database and subsequent searches for the same album return results from there rather than by querying the external APIs (see below)
  • The following command line arguments are required:
    • Artist name
    • Album title
  • Both should be enclosed in double-quotes
  • For example:
MusicCatalogue.LookupTool "John Coltrane" "Blue Train"
  • The output lists the album details and the number, title and duration of each track:

Console Lookup Tool

Web Service

Facilities

  • The REST Web Service implements endpoints for
    • Authenticating registered users
    • Retrieving artist details from the local database
    • Retrieving album and track details from the local database
    • Looking up albums via the external APIs (see below)
  • The external lookup uses the "album lookup" algorithm described under "Album Lookup", below
  • Swagger documentation exposed at:
/swagger/index.html
  • For full details of the service endpoints, it's recommended to build and run the service and review the documentation exposed at the above URL

Authentication

  • The service uses bearer token authentication, so clients should:
    • Use the /users/authenticate endpoint to get a token
    • Set the authorization header in subsequent requests:
Authorization: Bearer <token>

Database Users

  • To authenticate, users must have a record in the USERS table of the database associating a username with their hashed password
  • The following is a code snippet for adding a user to the database:
var userName = "SomeUser";
var password = "ThePassword";
var context = new MusicCatalogueDbContextFactory().CreateDbContext(Array.Empty<string>());
var factory = new MusicCatalogueFactory(context);
Task.Run(() => factory.Users.AddAsync(userName, password)).Wait();

GUI

  • Under development

Application Configuration File

  • The console application and web service use a common configuration file format, described in this section

General Settings and Database Connection String

  • The appsettings.json file in the console application project contains the following keys for controlling the application:
Section Key Purpose
ApplicationSettings LogFile Path and name of the log file. If this is blank, no log file is created
ApplicationSettings MinimumLogLevel Minimum message severity to log (Debug, Info, Warning or Error)
ApplicationSettings ApiEndpoints Set of endpoint definitions for external APIs
ApplicationSettings ApiServiceKeys Set of API key definitions for external APIs
ConnectionStrings MusicCatalogueDB SQLite connection string for the database

External API Configuration

  • The lookup tool and web service include integration with the TheAudioDB public API for artist, album and track details lookup:

TheAudioDB

  • To use the integration, a RapidAPI subscription is needed, as this includes an API key needed to acces the APIs
  • Signup is free, but daily free usage is restricted with a nominal charge being made for requests above the free limit
  • The integration is configured via the following keys in the configuration file:
Section Sub-Section Purpose
ApplicationSettings ApiEndpoints A list of endpoint definitions, each containing the endpoint type, service and endpoint URL
ApplicationSettings ApiServiceKeys A list of entries mapping each service to the API key needed to access that service
ApiEndpoint Definitions
  • An example API endpoint definition is shown below:
{
  "EndpointType": "Albums",
  "Service": "TheAudioDB",
  "Url": "https://theaudiodb.p.rapidapi.com/searchalbum.php"
}
  • Possible values for the endpoint type are:
Type Description
Albums Endpoint used to retrieve album details given an artist name and album title
Tracks Endpoint used to retrieve track details given an album ID returned by the albums endpoint
  • Currently, only the TheAudioDB APIs are supported
ApiServiceKey Definitions
  • An example key definition for a service is shown below:
{
  "Service": "TheAudioDB",
  "Key": "put-your-RapidPI-key-here"
}

Album Lookup

  • The local SQLite database is searched preferentially for album details
  • The external APIs are only used if an artist and/or album aren't found locally
  • Details returned by the external APIs are stored in the local database provided the returned data is complete:
    • The artist is found
    • The album is found
    • The album has at least one track associated with it
  • Consequently, subsequent searches with the same criteria will return data from the local database, not the APIs
  • Artist names, album titles and track names are stored in title case
  • Searches convert the search criteria to title case when looking details up in the database

SQLite Database

Database Schema

Database Schema

  • Note that the "Duration" field on the TRACKS table denotes the track duration in ms

Database Management

  • The application uses Entity Framework Core and initial creation and management of the database is achieved using EF Core database migrations
  • To create the database for the first time, first install the .NET Core SDK and then install the "dotnet ef" tool:
dotnet tool install --global dotnet-ef
  • Update the database path in the "appsettings.json" file in the terminal application project to point to the required database location
  • Build the solution
  • Open a terminal window and change to the MusicCatalogue.Data project
  • Run the following command, making sure to use the path separator appropriate for your OS:
dotnet ef database update -s ../MusicCatalogue.LookupTool/MusicCatalogue.LookupTool.csproj
  • If the database doesn't exist, it will create it
  • It will then bring the database up to date by applying all pending migrations

Authors

Feedback

To file issues or suggestions, please use the Issues page for this project on GitHub.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MusicCatalogue.Data:

Package Downloads
MusicCatalogue.Logic

Music Catalogue Business Logic

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.26.0 104 8/29/2024
1.25.0 108 8/28/2024
1.23.0 216 12/9/2023
1.22.0 152 12/2/2023
1.21.0 137 11/30/2023
1.20.0 117 11/28/2023
1.19.0 144 11/20/2023
1.18.0 129 11/18/2023
1.17.0 135 11/18/2023
1.16.0 135 11/16/2023
1.15.0 127 11/15/2023
1.14.0 132 11/15/2023
1.13.0 128 11/14/2023
1.12.0 131 11/13/2023
1.11.0 124 11/13/2023
1.10.0 140 11/12/2023
1.9.0 135 11/10/2023
1.8.0 127 11/10/2023
1.7.0 127 11/9/2023
1.6.0 162 10/29/2023
1.5.0 139 10/12/2023
1.3.0 146 10/10/2023
1.2.0 142 10/8/2023
1.1.0 145 10/4/2023
1.0.0 155 10/3/2023