mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 18:57:24 +00:00
Refactors the book, artist, and album slices across the stack
This commit is contained in:
1 parent
8aaf9fe64e
commit
ea6eb9f796
439 files changed
+28235
-3156
No files matched your search
@@ -2,15 +2,15 @@
|
||||
|
||||
- [Lumina API](#lumina-api)
|
||||
- [Album](#album)
|
||||
- [Add Album](#add-album)
|
||||
- [Add Album Request](#add-album-request)
|
||||
- [Add Album Response](#add-album-response)
|
||||
- [Get Artist Albums](#get-artist-albums)
|
||||
- [Get Artist Albums Request](#get-artist-albums-request)
|
||||
- [Get Artist Albums Response](#get-artist-albums-response)
|
||||
- [Get Artist Albums Lite](#get-artist-albums-lite)
|
||||
- [Get Artist Albums Lite Request](#get-artist-albums-lite-request)
|
||||
- [Get Artist Albums Lite Response](#get-artist-albums-lite-response)
|
||||
- [Add Album](#add-album)
|
||||
- [Add Album Request](#add-album-request)
|
||||
- [Add Album Response](#add-album-response)
|
||||
- [Get Album](#get-album)
|
||||
- [Get Album Request](#get-album-request)
|
||||
- [Get Album Response](#get-album-response)
|
||||
@@ -21,135 +21,16 @@
|
||||
|
||||
## Album
|
||||
|
||||
### Get Artist Albums
|
||||
|
||||
#### Get Artist Albums Request
|
||||
|
||||
```js
|
||||
GET api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums
|
||||
```
|
||||
|
||||
#### Get Artist Albums Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"title": "A Night at the Opera",
|
||||
"originalTitle": "A Night at the Opera",
|
||||
"description": "The fourth studio album by the British rock band Queen, released in 1975. It was the most expensive album ever recorded at the time of its release.",
|
||||
"releaseType": "Album",
|
||||
"releaseStatus": "Official",
|
||||
"totalDiscs": 1,
|
||||
"totalTracks": 12,
|
||||
"mediaFormat": "CD",
|
||||
"barcode": "0042282778329",
|
||||
"catalogNumber": "EMC 4008",
|
||||
"musicBrainzReleaseId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
|
||||
"musicBrainzReleaseGroupId": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e",
|
||||
"musicBrainzReleaseArtistId": "c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f",
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null,
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.5,
|
||||
"maxValue": 5,
|
||||
"source": "MusicBrainz",
|
||||
"voteCount": 2345
|
||||
},
|
||||
{
|
||||
"value": 4.8,
|
||||
"maxValue": 5,
|
||||
"source": "LastFm",
|
||||
"voteCount": 1234
|
||||
}
|
||||
],
|
||||
"originalReleaseDate": "1975-11-21",
|
||||
"originalReleaseYear": 1975,
|
||||
"reReleaseDate": null,
|
||||
"reReleaseYear": null,
|
||||
"releaseCountry": "GB",
|
||||
"releaseVersion": "Remastered",
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"languageNativeName": "English",
|
||||
"originalLanguageCode": "en",
|
||||
"originalLanguageName": "English",
|
||||
"originalLanguageNativeName": "English",
|
||||
"genres": [
|
||||
{
|
||||
"name": "Rock"
|
||||
},
|
||||
{
|
||||
"name": "Progressive Rock"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"name": "classic"
|
||||
},
|
||||
{
|
||||
"name": "vinyl"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
|
||||
### Get Artist Albums Lite
|
||||
|
||||
#### Get Artist Albums Lite Request
|
||||
|
||||
```js
|
||||
GET api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/lite?currentPage=1&perPage=10
|
||||
```
|
||||
|
||||
| Query Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| `currentPage` | `int` | Optional. The page of results to retrieve. |
|
||||
| `perPage` | `int` | Optional. The maximum number of albums to retrieve per page. |
|
||||
|
||||
#### Get Artist Albums Lite Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"id": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"title": "A Night at the Opera",
|
||||
"totalTracks": 12
|
||||
}
|
||||
],
|
||||
"currentPage": 1,
|
||||
"perPage": 10,
|
||||
"count": 1,
|
||||
"numberOfPages": 1
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Add Album
|
||||
|
||||
#### Add Album Request
|
||||
|
||||
```js
|
||||
POST api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums
|
||||
POST api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"metadata": {
|
||||
"title": "A Night at the Opera",
|
||||
"originalTitle": "A Night at the Opera",
|
||||
@@ -191,7 +72,7 @@ POST api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums
|
||||
"musicBrainzReleaseId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
|
||||
"musicBrainzReleaseGroupId": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e",
|
||||
"musicBrainzReleaseArtistId": "c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f",
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "0e7b4a6c-5f8d-6b9e-ca0b-3c4d5e6f7a8b", "role": "Producer" },
|
||||
{ "contributorId": "1a8c5b7d-6a9e-7c0f-db1c-4d5e6f7a8b9c", "role": "Engineer" }
|
||||
],
|
||||
@@ -211,8 +92,6 @@ POST api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums
|
||||
],
|
||||
"tracks": [
|
||||
{
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
@@ -260,7 +139,7 @@ POST api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums
|
||||
"musicBrainzRecordingId": "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
|
||||
"musicBrainzTrackId": "e5f6a7b8-c9d0-4e1f-2a3b-4c5d6e7f8a9b",
|
||||
"musicBrainzWorkId": "f6a7b8c9-d0e1-4f2a-3b4c-5d6e7f8a9b0c",
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e", "role": "Guitar" }
|
||||
],
|
||||
@@ -287,22 +166,20 @@ POST api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums
|
||||
]
|
||||
},
|
||||
{
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"path": "/music/queen/a-night-at-the-opera/02-youre-my-best-friend.flac",
|
||||
"path": "/music/queen/a-night-at-the-opera/07-youre-my-best-friend.flac",
|
||||
"metadata": {
|
||||
"title": "You're My Best Friend",
|
||||
"originalTitle": "You're My Best Friend",
|
||||
"description": "A song by the British rock band Queen. It was written by John Deacon and originally released on the album A Night at the Opera in 1975.",
|
||||
"durationInSeconds": 157,
|
||||
"description": "A song by the British rock band Queen, written by bass guitarist John Deacon. It was originally released on the album A Night at the Opera in 1975 and as a single in 1976.",
|
||||
"durationInSeconds": 181,
|
||||
"sampleRate": 44100,
|
||||
"channels": 2,
|
||||
"bitDepth": 16,
|
||||
"audioCodec": "FLAC",
|
||||
"bitrate": 895,
|
||||
"bitrate": 912,
|
||||
"releaseInfo": {
|
||||
"originalReleaseDate": "1975-06-18",
|
||||
"originalReleaseYear": 1975,
|
||||
"originalReleaseDate": "1976-06-18",
|
||||
"originalReleaseYear": 1976,
|
||||
"reReleaseDate": null,
|
||||
"reReleaseYear": null,
|
||||
"releaseCountry": "GB",
|
||||
@@ -320,23 +197,23 @@ POST api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums
|
||||
},
|
||||
"genres": [
|
||||
{ "name": "Rock" },
|
||||
{ "name": "Pop" }
|
||||
{ "name": "Pop Rock" }
|
||||
],
|
||||
"tags": [
|
||||
{ "name": "classic" },
|
||||
{ "name": "pop" }
|
||||
{ "name": "love" }
|
||||
]
|
||||
},
|
||||
"trackNumber": 2,
|
||||
"trackNumber": 7,
|
||||
"discNumber": 1,
|
||||
"script": "Latn",
|
||||
"key": "CMajor",
|
||||
"bpm": 128,
|
||||
"key": "BMajor",
|
||||
"bpm": 118,
|
||||
"work": "You're My Best Friend",
|
||||
"musicBrainzRecordingId": "a0b1c2d3-e4f5-4a6b-8c7d-9e0f1a2b3c4d",
|
||||
"musicBrainzTrackId": "b1c2d3e4-f5a6-4b7c-9d0e-1f2a3b4c5d6e",
|
||||
"musicBrainzWorkId": "c2d3e4f5-a6b7-4c8d-9e0f-1a2b3c4d5e6f",
|
||||
"credits": [
|
||||
"musicBrainzRecordingId": "0f3e4d5c-6b7a-4f8e-9d0c-1b2a3c4d5e6f",
|
||||
"musicBrainzTrackId": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
|
||||
"musicBrainzWorkId": "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e",
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "8c5f2e4a-3d6b-4f7c-ae8f-1a2b3c4d5e6f", "role": "BassGuitar" }
|
||||
],
|
||||
@@ -345,21 +222,21 @@ POST api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums
|
||||
"value": 4.2,
|
||||
"maxValue": 5,
|
||||
"source": "MusicBrainz",
|
||||
"voteCount": 1890
|
||||
"voteCount": 1234
|
||||
},
|
||||
{
|
||||
"value": 4.1,
|
||||
"value": 4.4,
|
||||
"maxValue": 5,
|
||||
"source": "LastFm",
|
||||
"voteCount": 987
|
||||
"voteCount": 567
|
||||
}
|
||||
],
|
||||
"moods": [
|
||||
{ "name": "upbeat" },
|
||||
{ "name": "happy" }
|
||||
{ "name": "happy" },
|
||||
{ "name": "warm" }
|
||||
],
|
||||
"isrcs": [
|
||||
{ "value": "GBUM71029605" }
|
||||
{ "value": "GBUM71029609" }
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -372,35 +249,54 @@ POST api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums
|
||||
201 Created
|
||||
```
|
||||
|
||||
The response carries the full details of the newly created album, using the same shape as the [Get Album Response](#get-album-response).
|
||||
|
||||
|
||||
### Get Album
|
||||
|
||||
#### Get Album Request
|
||||
|
||||
```js
|
||||
GET api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f
|
||||
```
|
||||
|
||||
#### Get Album Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"title": "A Night at the Opera",
|
||||
"originalTitle": "A Night at the Opera",
|
||||
"description": "The fourth studio album by the British rock band Queen, released in 1975. It was the most expensive album ever recorded at the time of its release.",
|
||||
"releaseType": "Album",
|
||||
"releaseStatus": "Official",
|
||||
"totalDiscs": 1,
|
||||
"totalTracks": 12,
|
||||
"metadata": {
|
||||
"title": "A Night at the Opera",
|
||||
"originalTitle": "A Night at the Opera",
|
||||
"description": "The fourth studio album by the British rock band Queen, released in 1975. It was the most expensive album ever recorded at the time of its release.",
|
||||
"releaseType": "Album",
|
||||
"releaseStatus": "Official",
|
||||
"totalDiscs": 1,
|
||||
"totalTracks": 12,
|
||||
"releaseInfo": {
|
||||
"originalReleaseDate": "1975-11-21",
|
||||
"originalReleaseYear": 1975,
|
||||
"reReleaseDate": null,
|
||||
"reReleaseYear": null,
|
||||
"releaseCountry": "GB",
|
||||
"releaseVersion": "Remastered"
|
||||
},
|
||||
"language": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"originalLanguage": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"genres": [
|
||||
{
|
||||
"name": "Rock"
|
||||
},
|
||||
{
|
||||
"name": "Progressive Rock"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"name": "classic"
|
||||
},
|
||||
{
|
||||
"name": "vinyl"
|
||||
}
|
||||
]
|
||||
},
|
||||
"mediaFormat": "CD",
|
||||
"barcode": "0042282778329",
|
||||
"catalogNumber": "EMC 4008",
|
||||
@@ -409,6 +305,16 @@ GET api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2
|
||||
"musicBrainzReleaseArtistId": "c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f",
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null,
|
||||
"contributors": [
|
||||
{
|
||||
"contributorId": "0e7b4a6c-5f8d-6b9e-ca0b-3c4d5e6f7a8b",
|
||||
"role": "Producer"
|
||||
},
|
||||
{
|
||||
"contributorId": "1a8c5b7d-6a9e-7c0f-db1c-4d5e6f7a8b9c",
|
||||
"role": "Engineer"
|
||||
}
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.5,
|
||||
@@ -423,50 +329,428 @@ GET api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2
|
||||
"voteCount": 1234
|
||||
}
|
||||
],
|
||||
"originalReleaseDate": "1975-11-21",
|
||||
"originalReleaseYear": 1975,
|
||||
"reReleaseDate": null,
|
||||
"reReleaseYear": null,
|
||||
"releaseCountry": "GB",
|
||||
"releaseVersion": "Remastered",
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"languageNativeName": "English",
|
||||
"originalLanguageCode": "en",
|
||||
"originalLanguageName": "English",
|
||||
"originalLanguageNativeName": "English",
|
||||
"genres": [
|
||||
"tracks": [
|
||||
{
|
||||
"name": "Rock"
|
||||
"id": "9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f",
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
"description": "A song by the British rock band Queen. It was written by Freddie Mercury and originally released on the album A Night at the Opera in 1975.",
|
||||
"releaseInfo": {
|
||||
"originalReleaseDate": "1975-10-31",
|
||||
"originalReleaseYear": 1975,
|
||||
"reReleaseDate": null,
|
||||
"reReleaseYear": null,
|
||||
"releaseCountry": "GB",
|
||||
"releaseVersion": "Original"
|
||||
},
|
||||
"language": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"originalLanguage": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"tags": [
|
||||
{ "name": "classic" },
|
||||
{ "name": "epic" }
|
||||
],
|
||||
"genres": [
|
||||
{ "name": "Rock" },
|
||||
{ "name": "Progressive Rock" }
|
||||
],
|
||||
"durationInSeconds": 354,
|
||||
"sampleRate": 44100,
|
||||
"channels": 2,
|
||||
"bitDepth": 16,
|
||||
"audioCodec": "FLAC",
|
||||
"bitrate": 980
|
||||
},
|
||||
"trackNumber": 1,
|
||||
"discNumber": 1,
|
||||
"script": "Latn",
|
||||
"key": "CMajor",
|
||||
"bpm": 72,
|
||||
"work": "Bohemian Rhapsody",
|
||||
"musicBrainzRecordingId": "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
|
||||
"musicBrainzTrackId": "e5f6a7b8-c9d0-4e1f-2a3b-4c5d6e7f8a9b",
|
||||
"musicBrainzWorkId": "f6a7b8c9-d0e1-4f2a-3b4c-5d6e7f8a9b0c",
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null,
|
||||
"contributors": [
|
||||
{
|
||||
"contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d",
|
||||
"role": "Vocals"
|
||||
},
|
||||
{
|
||||
"contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e",
|
||||
"role": "Guitar"
|
||||
}
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.5,
|
||||
"maxValue": 5,
|
||||
"source": "MusicBrainz",
|
||||
"voteCount": 2345
|
||||
},
|
||||
{
|
||||
"value": 4.8,
|
||||
"maxValue": 5,
|
||||
"source": "LastFm",
|
||||
"voteCount": 1234
|
||||
}
|
||||
],
|
||||
"moods": [
|
||||
{ "name": "dramatic" },
|
||||
{ "name": "anxious" }
|
||||
],
|
||||
"isrcs": [
|
||||
{ "value": "GBUM71029604" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Progressive Rock"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"name": "classic"
|
||||
},
|
||||
{
|
||||
"name": "vinyl"
|
||||
"id": "8e1f2a3b-4c5d-4e6f-8a9b-0c1d2e3f4a5b",
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/07-youre-my-best-friend.flac",
|
||||
"metadata": {
|
||||
"title": "You're My Best Friend",
|
||||
"originalTitle": "You're My Best Friend",
|
||||
"description": "A song by the British rock band Queen, written by bass guitarist John Deacon. It was originally released on the album A Night at the Opera in 1975 and as a single in 1976.",
|
||||
"releaseInfo": {
|
||||
"originalReleaseDate": "1976-06-18",
|
||||
"originalReleaseYear": 1976,
|
||||
"reReleaseDate": null,
|
||||
"reReleaseYear": null,
|
||||
"releaseCountry": "GB",
|
||||
"releaseVersion": "Original"
|
||||
},
|
||||
"language": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"originalLanguage": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"tags": [
|
||||
{ "name": "classic" },
|
||||
{ "name": "love" }
|
||||
],
|
||||
"genres": [
|
||||
{ "name": "Rock" },
|
||||
{ "name": "Pop Rock" }
|
||||
],
|
||||
"durationInSeconds": 181,
|
||||
"sampleRate": 44100,
|
||||
"channels": 2,
|
||||
"bitDepth": 16,
|
||||
"audioCodec": "FLAC",
|
||||
"bitrate": 912
|
||||
},
|
||||
"trackNumber": 7,
|
||||
"discNumber": 1,
|
||||
"script": "Latn",
|
||||
"key": "BMajor",
|
||||
"bpm": 118,
|
||||
"work": "You're My Best Friend",
|
||||
"musicBrainzRecordingId": "0f3e4d5c-6b7a-4f8e-9d0c-1b2a3c4d5e6f",
|
||||
"musicBrainzTrackId": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
|
||||
"musicBrainzWorkId": "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e",
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null,
|
||||
"contributors": [
|
||||
{
|
||||
"contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d",
|
||||
"role": "Vocals"
|
||||
},
|
||||
{
|
||||
"contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e",
|
||||
"role": "Guitar"
|
||||
}
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.2,
|
||||
"maxValue": 5,
|
||||
"source": "MusicBrainz",
|
||||
"voteCount": 1234
|
||||
},
|
||||
{
|
||||
"value": 4.4,
|
||||
"maxValue": 5,
|
||||
"source": "LastFm",
|
||||
"voteCount": 567
|
||||
}
|
||||
],
|
||||
"moods": [
|
||||
{ "name": "happy" },
|
||||
{ "name": "warm" }
|
||||
],
|
||||
"isrcs": [
|
||||
{ "value": "GBUM71029609" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Get Artist Albums
|
||||
|
||||
#### Get Artist Albums Request
|
||||
|
||||
```js
|
||||
GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums
|
||||
```
|
||||
|
||||
#### Get Artist Albums Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"metadata": {
|
||||
"title": "A Night at the Opera",
|
||||
"originalTitle": "A Night at the Opera",
|
||||
"description": "The fourth studio album by the British rock band Queen, released in 1975. It was the most expensive album ever recorded at the time of its release.",
|
||||
"releaseType": "Album",
|
||||
"releaseStatus": "Official",
|
||||
"totalDiscs": 1,
|
||||
"totalTracks": 12,
|
||||
"releaseInfo": {
|
||||
"originalReleaseDate": "1975-11-21",
|
||||
"originalReleaseYear": 1975,
|
||||
"reReleaseDate": null,
|
||||
"reReleaseYear": null,
|
||||
"releaseCountry": "GB",
|
||||
"releaseVersion": "Remastered"
|
||||
},
|
||||
"language": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"originalLanguage": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"genres": [
|
||||
{
|
||||
"name": "Rock"
|
||||
},
|
||||
{
|
||||
"name": "Progressive Rock"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"name": "classic"
|
||||
},
|
||||
{
|
||||
"name": "vinyl"
|
||||
}
|
||||
]
|
||||
},
|
||||
"mediaFormat": "CD",
|
||||
"barcode": "0042282778329",
|
||||
"catalogNumber": "EMC 4008",
|
||||
"musicBrainzReleaseId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
|
||||
"musicBrainzReleaseGroupId": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e",
|
||||
"musicBrainzReleaseArtistId": "c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f",
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null,
|
||||
"contributors": [
|
||||
{
|
||||
"contributorId": "0e7b4a6c-5f8d-6b9e-ca0b-3c4d5e6f7a8b",
|
||||
"role": "Producer"
|
||||
},
|
||||
{
|
||||
"contributorId": "1a8c5b7d-6a9e-7c0f-db1c-4d5e6f7a8b9c",
|
||||
"role": "Engineer"
|
||||
}
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.5,
|
||||
"maxValue": 5,
|
||||
"source": "MusicBrainz",
|
||||
"voteCount": 2345
|
||||
},
|
||||
{
|
||||
"value": 4.8,
|
||||
"maxValue": 5,
|
||||
"source": "LastFm",
|
||||
"voteCount": 1234
|
||||
}
|
||||
],
|
||||
"tracks": []
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
|
||||
### Get Artist Albums Lite
|
||||
|
||||
#### Get Artist Albums Lite Request
|
||||
|
||||
```js
|
||||
GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/lite?currentPage=1&perPage=10
|
||||
```
|
||||
|
||||
| Query Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| `currentPage` | `int` | Optional. The page of results to retrieve. |
|
||||
| `perPage` | `int` | Optional. The maximum number of albums to retrieve per page. |
|
||||
|
||||
#### Get Artist Albums Lite Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"id": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"title": "A Night at the Opera",
|
||||
"totalTracks": 12
|
||||
}
|
||||
],
|
||||
"currentPage": 1,
|
||||
"perPage": 10,
|
||||
"count": 1,
|
||||
"numberOfPages": 1
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Get Album
|
||||
|
||||
#### Get Album Request
|
||||
|
||||
```js
|
||||
GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f
|
||||
```
|
||||
|
||||
#### Get Album Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"metadata": {
|
||||
"title": "A Night at the Opera",
|
||||
"originalTitle": "A Night at the Opera",
|
||||
"description": "The fourth studio album by the British rock band Queen, released in 1975. It was the most expensive album ever recorded at the time of its release.",
|
||||
"releaseType": "Album",
|
||||
"releaseStatus": "Official",
|
||||
"totalDiscs": 1,
|
||||
"totalTracks": 12,
|
||||
"releaseInfo": {
|
||||
"originalReleaseDate": "1975-11-21",
|
||||
"originalReleaseYear": 1975,
|
||||
"reReleaseDate": null,
|
||||
"reReleaseYear": null,
|
||||
"releaseCountry": "GB",
|
||||
"releaseVersion": "Remastered"
|
||||
},
|
||||
"language": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"originalLanguage": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"genres": [
|
||||
{
|
||||
"name": "Rock"
|
||||
},
|
||||
{
|
||||
"name": "Progressive Rock"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"name": "classic"
|
||||
},
|
||||
{
|
||||
"name": "vinyl"
|
||||
}
|
||||
]
|
||||
},
|
||||
"mediaFormat": "CD",
|
||||
"barcode": "0042282778329",
|
||||
"catalogNumber": "EMC 4008",
|
||||
"musicBrainzReleaseId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
|
||||
"musicBrainzReleaseGroupId": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e",
|
||||
"musicBrainzReleaseArtistId": "c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f",
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null,
|
||||
"contributors": [
|
||||
{
|
||||
"contributorId": "0e7b4a6c-5f8d-6b9e-ca0b-3c4d5e6f7a8b",
|
||||
"role": "Producer"
|
||||
},
|
||||
{
|
||||
"contributorId": "1a8c5b7d-6a9e-7c0f-db1c-4d5e6f7a8b9c",
|
||||
"role": "Engineer"
|
||||
}
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.5,
|
||||
"maxValue": 5,
|
||||
"source": "MusicBrainz",
|
||||
"voteCount": 2345
|
||||
},
|
||||
{
|
||||
"value": 4.8,
|
||||
"maxValue": 5,
|
||||
"source": "LastFm",
|
||||
"voteCount": 1234
|
||||
}
|
||||
],
|
||||
"tracks": []
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Update Album
|
||||
|
||||
#### Update Album Request
|
||||
|
||||
```js
|
||||
PUT api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f
|
||||
PUT api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"metadata": {
|
||||
"title": "A Night at the Opera",
|
||||
"originalTitle": "A Night at the Opera",
|
||||
@@ -508,7 +792,7 @@ PUT api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2
|
||||
"musicBrainzReleaseId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
|
||||
"musicBrainzReleaseGroupId": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e",
|
||||
"musicBrainzReleaseArtistId": "c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f",
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "0e7b4a6c-5f8d-6b9e-ca0b-3c4d5e6f7a8b", "role": "Producer" },
|
||||
{ "contributorId": "1a8c5b7d-6a9e-7c0f-db1c-4d5e6f7a8b9c", "role": "Engineer" }
|
||||
],
|
||||
@@ -541,7 +825,7 @@ The response carries the full details of the updated album, using the same shape
|
||||
### Delete Album
|
||||
|
||||
```js
|
||||
DELETE api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f
|
||||
DELETE api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f
|
||||
```
|
||||
|
||||
```js
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#### Add Artist Request
|
||||
|
||||
```js
|
||||
POST api/v1/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists
|
||||
POST api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists
|
||||
```
|
||||
|
||||
```json
|
||||
@@ -34,7 +34,7 @@ POST api/v1/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists
|
||||
"name": "Queen",
|
||||
"website": "https://www.queenonline.com",
|
||||
"musicBrainzArtistId": "6f9c0b2a-1d3e-4a5b-8c7d-9e0f1a2b3c4d",
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e", "role": "Guitar" }
|
||||
],
|
||||
@@ -81,7 +81,7 @@ POST api/v1/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists
|
||||
"musicBrainzReleaseId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
|
||||
"musicBrainzReleaseGroupId": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e",
|
||||
"musicBrainzReleaseArtistId": "c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f",
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "0e7b4a6c-5f8d-6b9e-ca0b-3c4d5e6f7a8b", "role": "Producer" },
|
||||
{ "contributorId": "1a8c5b7d-6a9e-7c0f-db1c-4d5e6f7a8b9c", "role": "Engineer" }
|
||||
],
|
||||
@@ -155,7 +155,7 @@ POST api/v1/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists
|
||||
"isrcs": [
|
||||
{ "value": "GBUM71029604" }
|
||||
],
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e", "role": "Guitar" }
|
||||
],
|
||||
@@ -229,7 +229,7 @@ POST api/v1/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists
|
||||
"isrcs": [
|
||||
{ "value": "GBUM71029609" }
|
||||
],
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "8c5f2e4a-3d6b-4f7c-ae8f-1a2b3c4d5e6f", "role": "BassGuitar" }
|
||||
],
|
||||
@@ -267,23 +267,238 @@ POST api/v1/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists
|
||||
"name": "Queen",
|
||||
"website": "https://www.queenonline.com",
|
||||
"musicBrainzArtistId": "6f9c0b2a-1d3e-4a5b-8c7d-9e0f1a2b3c4d",
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e", "role": "Guitar" }
|
||||
],
|
||||
"albums": [
|
||||
{
|
||||
"id": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"metadata": {
|
||||
"title": "A Night at the Opera",
|
||||
"originalTitle": "A Night at the Opera",
|
||||
"description": "The fourth studio album by the British rock band Queen, released in 1975. It was the most expensive album ever recorded at the time of its release.",
|
||||
"releaseType": "Album",
|
||||
"releaseStatus": "Official",
|
||||
"totalDiscs": 1,
|
||||
"totalTracks": 12,
|
||||
"releaseInfo": {
|
||||
"originalReleaseDate": "1975-11-21",
|
||||
"originalReleaseYear": 1975,
|
||||
"reReleaseDate": null,
|
||||
"reReleaseYear": null,
|
||||
"releaseCountry": "GB",
|
||||
"releaseVersion": "Remastered"
|
||||
},
|
||||
"language": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"originalLanguage": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"genres": [
|
||||
{
|
||||
"name": "Rock"
|
||||
},
|
||||
{
|
||||
"name": "Progressive Rock"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"name": "classic"
|
||||
},
|
||||
{
|
||||
"name": "vinyl"
|
||||
}
|
||||
]
|
||||
},
|
||||
"mediaFormat": "CD",
|
||||
"barcode": "0042282778329",
|
||||
"catalogNumber": "EMC 4008",
|
||||
"musicBrainzReleaseId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
|
||||
"musicBrainzReleaseGroupId": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e",
|
||||
"musicBrainzReleaseArtistId": "c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f",
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null,
|
||||
"contributors": [
|
||||
{
|
||||
"contributorId": "0e7b4a6c-5f8d-6b9e-ca0b-3c4d5e6f7a8b",
|
||||
"role": "Producer"
|
||||
},
|
||||
{
|
||||
"contributorId": "1a8c5b7d-6a9e-7c0f-db1c-4d5e6f7a8b9c",
|
||||
"role": "Engineer"
|
||||
}
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.5,
|
||||
"maxValue": 5,
|
||||
"source": "MusicBrainz",
|
||||
"voteCount": 2345
|
||||
},
|
||||
{
|
||||
"value": 4.8,
|
||||
"maxValue": 5,
|
||||
"source": "LastFm",
|
||||
"voteCount": 1234
|
||||
}
|
||||
],
|
||||
"tracks": [
|
||||
{
|
||||
"id": "9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f",
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
"description": "A song by the British rock band Queen. It was written by Freddie Mercury and originally released on the album A Night at the Opera in 1975.",
|
||||
"releaseInfo": { "originalReleaseDate": "1975-10-31", "originalReleaseYear": 1975, "reReleaseDate": null, "reReleaseYear": null, "releaseCountry": "GB", "releaseVersion": "Original" },
|
||||
"language": { "languageCode": "en", "languageName": "English", "nativeName": "English" },
|
||||
"originalLanguage": { "languageCode": "en", "languageName": "English", "nativeName": "English" },
|
||||
"tags": [ { "name": "classic" }, { "name": "epic" } ],
|
||||
"genres": [ { "name": "Rock" }, { "name": "Progressive Rock" } ],
|
||||
"durationInSeconds": 354,
|
||||
"sampleRate": 44100,
|
||||
"channels": 2,
|
||||
"bitDepth": 16,
|
||||
"audioCodec": "FLAC",
|
||||
"bitrate": 980
|
||||
},
|
||||
"trackNumber": 1,
|
||||
"discNumber": 1,
|
||||
"script": "Latn",
|
||||
"key": "CMajor",
|
||||
"bpm": 72,
|
||||
"work": "Bohemian Rhapsody",
|
||||
"musicBrainzRecordingId": "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
|
||||
"musicBrainzTrackId": "e5f6a7b8-c9d0-4e1f-2a3b-4c5d6e7f8a9b",
|
||||
"musicBrainzWorkId": "f6a7b8c9-d0e1-4f2a-3b4c-5d6e7f8a9b0c",
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null,
|
||||
"contributors": [
|
||||
{
|
||||
"contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d",
|
||||
"role": "Vocals"
|
||||
},
|
||||
{
|
||||
"contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e",
|
||||
"role": "Guitar"
|
||||
}
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.5,
|
||||
"maxValue": 5,
|
||||
"source": "MusicBrainz",
|
||||
"voteCount": 2345
|
||||
},
|
||||
{
|
||||
"value": 4.8,
|
||||
"maxValue": 5,
|
||||
"source": "LastFm",
|
||||
"voteCount": 1234
|
||||
}
|
||||
],
|
||||
"moods": [
|
||||
{ "name": "dramatic" },
|
||||
{ "name": "anxious" }
|
||||
],
|
||||
"isrcs": [
|
||||
{ "value": "GBUM71029604" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "8e1f2a3b-4c5d-4e6f-8a9b-0c1d2e3f4a5b",
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/07-youre-my-best-friend.flac",
|
||||
"metadata": {
|
||||
"title": "You're My Best Friend",
|
||||
"originalTitle": "You're My Best Friend",
|
||||
"description": "A song by the British rock band Queen, written by bass guitarist John Deacon. It was originally released on the album A Night at the Opera in 1975 and as a single in 1976.",
|
||||
"releaseInfo": { "originalReleaseDate": "1976-06-18", "originalReleaseYear": 1976, "reReleaseDate": null, "reReleaseYear": null, "releaseCountry": "GB", "releaseVersion": "Original" },
|
||||
"language": { "languageCode": "en", "languageName": "English", "nativeName": "English" },
|
||||
"originalLanguage": { "languageCode": "en", "languageName": "English", "nativeName": "English" },
|
||||
"tags": [ { "name": "classic" }, { "name": "love" } ],
|
||||
"genres": [ { "name": "Rock" }, { "name": "Pop Rock" } ],
|
||||
"durationInSeconds": 181,
|
||||
"sampleRate": 44100,
|
||||
"channels": 2,
|
||||
"bitDepth": 16,
|
||||
"audioCodec": "FLAC",
|
||||
"bitrate": 912
|
||||
},
|
||||
"trackNumber": 7,
|
||||
"discNumber": 1,
|
||||
"script": "Latn",
|
||||
"key": "BMajor",
|
||||
"bpm": 118,
|
||||
"work": "You're My Best Friend",
|
||||
"musicBrainzRecordingId": "0f3e4d5c-6b7a-4f8e-9d0c-1b2a3c4d5e6f",
|
||||
"musicBrainzTrackId": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
|
||||
"musicBrainzWorkId": "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e",
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null,
|
||||
"contributors": [
|
||||
{
|
||||
"contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d",
|
||||
"role": "Vocals"
|
||||
},
|
||||
{
|
||||
"contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e",
|
||||
"role": "Guitar"
|
||||
}
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.2,
|
||||
"maxValue": 5,
|
||||
"source": "MusicBrainz",
|
||||
"voteCount": 1234
|
||||
},
|
||||
{
|
||||
"value": 4.4,
|
||||
"maxValue": 5,
|
||||
"source": "LastFm",
|
||||
"voteCount": 567
|
||||
}
|
||||
],
|
||||
"moods": [
|
||||
{ "name": "happy" },
|
||||
{ "name": "warm" }
|
||||
],
|
||||
"isrcs": [
|
||||
{ "value": "GBUM71029609" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Get Artists
|
||||
|
||||
#### Get Artists Request
|
||||
|
||||
```js
|
||||
GET api/v1/artists?libraryId=3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a¤tPage=1&perPage=10&searchTerm=queen
|
||||
GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists?currentPage=1&perPage=10&searchTerm=queen
|
||||
```
|
||||
|
||||
| Query Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| `libraryId` | `string` (GUID) | Required. The Id of the media library whose artists are retrieved. |
|
||||
| `currentPage` | `int` | Optional. The page of results to retrieve. |
|
||||
| `perPage` | `int` | Optional. The maximum number of artists to retrieve per page. |
|
||||
| `searchTerm` | `string` | Optional. The search term used to filter the artists by name. |
|
||||
@@ -303,6 +518,8 @@ GET api/v1/artists?libraryId=3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a¤tPage=1&
|
||||
"name": "Queen",
|
||||
"website": "https://www.queenonline.com",
|
||||
"musicBrainzArtistId": "6f9c0b2a-1d3e-4a5b-8c7d-9e0f1a2b3c4d",
|
||||
"contributors": [],
|
||||
"albums": [],
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null
|
||||
}
|
||||
@@ -320,12 +537,11 @@ GET api/v1/artists?libraryId=3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a¤tPage=1&
|
||||
#### Get Artists Lite Request
|
||||
|
||||
```js
|
||||
GET api/v1/artists/lite?libraryId=3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a¤tPage=1&perPage=10&searchTerm=queen
|
||||
GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/lite?currentPage=1&perPage=10&searchTerm=queen
|
||||
```
|
||||
|
||||
| Query Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| `libraryId` | `string` (GUID) | Required. The Id of the media library whose artists are retrieved. |
|
||||
| `currentPage` | `int` | Optional. The page of results to retrieve. |
|
||||
| `perPage` | `int` | Optional. The maximum number of artists to retrieve per page. |
|
||||
| `searchTerm` | `string` | Optional. The search term used to filter the artists by name. |
|
||||
@@ -357,7 +573,7 @@ GET api/v1/artists/lite?libraryId=3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a¤tPa
|
||||
#### Get Artist Request
|
||||
|
||||
```js
|
||||
GET api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a
|
||||
GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/{artistId}
|
||||
```
|
||||
|
||||
#### Get Artist Response
|
||||
@@ -373,6 +589,11 @@ GET api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a
|
||||
"name": "Queen",
|
||||
"website": "https://www.queenonline.com",
|
||||
"musicBrainzArtistId": "6f9c0b2a-1d3e-4a5b-8c7d-9e0f1a2b3c4d",
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e", "role": "Guitar" }
|
||||
],
|
||||
"albums": [],
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null
|
||||
}
|
||||
@@ -384,18 +605,230 @@ GET api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a
|
||||
#### Update Artist Request
|
||||
|
||||
```js
|
||||
PUT api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a
|
||||
PUT api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/{artistId}
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"name": "Queen",
|
||||
"website": "https://www.queenonline.com",
|
||||
"musicBrainzArtistId": "6f9c0b2a-1d3e-4a5b-8c7d-9e0f1a2b3c4d",
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e", "role": "Guitar" }
|
||||
],
|
||||
"albums": [
|
||||
{
|
||||
"metadata": {
|
||||
"title": "A Night at the Opera",
|
||||
"originalTitle": "A Night at the Opera",
|
||||
"description": "The fourth studio album by the British rock band Queen, released in 1975. It was the most expensive album ever recorded at the time of its release.",
|
||||
"releaseInfo": {
|
||||
"originalReleaseDate": "1975-11-21",
|
||||
"originalReleaseYear": 1975,
|
||||
"reReleaseDate": null,
|
||||
"reReleaseYear": null,
|
||||
"releaseCountry": "GB",
|
||||
"releaseVersion": "Remastered"
|
||||
},
|
||||
"language": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"originalLanguage": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"tags": [
|
||||
{ "name": "classic" },
|
||||
{ "name": "vinyl" }
|
||||
],
|
||||
"genres": [
|
||||
{ "name": "Rock" },
|
||||
{ "name": "Progressive Rock" }
|
||||
],
|
||||
"releaseType": "Album",
|
||||
"releaseStatus": "Official",
|
||||
"totalDiscs": 1,
|
||||
"totalTracks": 12
|
||||
},
|
||||
"mediaFormat": "CD",
|
||||
"barcode": "0042282778329",
|
||||
"catalogNumber": "EMC 4008",
|
||||
"musicBrainzReleaseId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
|
||||
"musicBrainzReleaseGroupId": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e",
|
||||
"musicBrainzReleaseArtistId": "c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f",
|
||||
"contributors": [
|
||||
{ "contributorId": "0e7b4a6c-5f8d-6b9e-ca0b-3c4d5e6f7a8b", "role": "Producer" },
|
||||
{ "contributorId": "1a8c5b7d-6a9e-7c0f-db1c-4d5e6f7a8b9c", "role": "Engineer" }
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.5,
|
||||
"maxValue": 5,
|
||||
"source": "MusicBrainz",
|
||||
"voteCount": 2345
|
||||
},
|
||||
{
|
||||
"value": 4.8,
|
||||
"maxValue": 5,
|
||||
"source": "LastFm",
|
||||
"voteCount": 1234
|
||||
}
|
||||
],
|
||||
"tracks": [
|
||||
{
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
"description": "A song by the British rock band Queen. It was written by Freddie Mercury and originally released on the album A Night at the Opera in 1975.",
|
||||
"releaseInfo": {
|
||||
"originalReleaseDate": "1975-10-31",
|
||||
"originalReleaseYear": 1975,
|
||||
"reReleaseDate": null,
|
||||
"reReleaseYear": null,
|
||||
"releaseCountry": "GB",
|
||||
"releaseVersion": "Original"
|
||||
},
|
||||
"language": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"originalLanguage": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"tags": [
|
||||
{ "name": "classic" },
|
||||
{ "name": "epic" }
|
||||
],
|
||||
"genres": [
|
||||
{ "name": "Rock" },
|
||||
{ "name": "Progressive Rock" }
|
||||
],
|
||||
"durationInSeconds": 354,
|
||||
"sampleRate": 44100,
|
||||
"channels": 2,
|
||||
"bitDepth": 16,
|
||||
"audioCodec": "FLAC",
|
||||
"bitrate": 980
|
||||
},
|
||||
"trackNumber": 1,
|
||||
"discNumber": 1,
|
||||
"script": "Latn",
|
||||
"key": "CMajor",
|
||||
"bpm": 72,
|
||||
"work": "Bohemian Rhapsody",
|
||||
"musicBrainzRecordingId": "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
|
||||
"musicBrainzTrackId": "e5f6a7b8-c9d0-4e1f-2a3b-4c5d6e7f8a9b",
|
||||
"musicBrainzWorkId": "f6a7b8c9-d0e1-4f2a-3b4c-5d6e7f8a9b0c",
|
||||
"moods": [
|
||||
{ "name": "dramatic" },
|
||||
{ "name": "anxious" }
|
||||
],
|
||||
"isrcs": [
|
||||
{ "value": "GBUM71029604" }
|
||||
],
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e", "role": "Guitar" }
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.5,
|
||||
"maxValue": 5,
|
||||
"source": "MusicBrainz",
|
||||
"voteCount": 2345
|
||||
},
|
||||
{
|
||||
"value": 4.8,
|
||||
"maxValue": 5,
|
||||
"source": "LastFm",
|
||||
"voteCount": 1234
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "/music/queen/a-night-at-the-opera/07-youre-my-best-friend.flac",
|
||||
"metadata": {
|
||||
"title": "You're My Best Friend",
|
||||
"originalTitle": "You're My Best Friend",
|
||||
"description": "A song by the British rock band Queen, written by bass guitarist John Deacon. It was originally released on the album A Night at the Opera in 1975 and as a single in 1976.",
|
||||
"releaseInfo": {
|
||||
"originalReleaseDate": "1976-06-18",
|
||||
"originalReleaseYear": 1976,
|
||||
"reReleaseDate": null,
|
||||
"reReleaseYear": null,
|
||||
"releaseCountry": "GB",
|
||||
"releaseVersion": "Original"
|
||||
},
|
||||
"language": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"originalLanguage": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"tags": [
|
||||
{ "name": "classic" },
|
||||
{ "name": "love" }
|
||||
],
|
||||
"genres": [
|
||||
{ "name": "Rock" },
|
||||
{ "name": "Pop Rock" }
|
||||
],
|
||||
"durationInSeconds": 181,
|
||||
"sampleRate": 44100,
|
||||
"channels": 2,
|
||||
"bitDepth": 16,
|
||||
"audioCodec": "FLAC",
|
||||
"bitrate": 912
|
||||
},
|
||||
"trackNumber": 7,
|
||||
"discNumber": 1,
|
||||
"script": "Latn",
|
||||
"key": "BMajor",
|
||||
"bpm": 118,
|
||||
"work": "You're My Best Friend",
|
||||
"musicBrainzRecordingId": "0f3e4d5c-6b7a-4f8e-9d0c-1b2a3c4d5e6f",
|
||||
"musicBrainzTrackId": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
|
||||
"musicBrainzWorkId": "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e",
|
||||
"moods": [
|
||||
{ "name": "happy" },
|
||||
{ "name": "warm" }
|
||||
],
|
||||
"isrcs": [
|
||||
{ "value": "GBUM71029609" }
|
||||
],
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "8c5f2e4a-3d6b-4f7c-ae8f-1a2b3c4d5e6f", "role": "BassGuitar" }
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.2,
|
||||
"maxValue": 5,
|
||||
"source": "MusicBrainz",
|
||||
"voteCount": 1234
|
||||
},
|
||||
{
|
||||
"value": 4.4,
|
||||
"maxValue": 5,
|
||||
"source": "LastFm",
|
||||
"voteCount": 567
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
@@ -413,6 +846,222 @@ PUT api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a
|
||||
"name": "Queen",
|
||||
"website": "https://www.queenonline.com",
|
||||
"musicBrainzArtistId": "6f9c0b2a-1d3e-4a5b-8c7d-9e0f1a2b3c4d",
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e", "role": "Guitar" }
|
||||
],
|
||||
"albums": [
|
||||
{
|
||||
"id": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"metadata": {
|
||||
"title": "A Night at the Opera",
|
||||
"originalTitle": "A Night at the Opera",
|
||||
"description": "The fourth studio album by the British rock band Queen, released in 1975. It was the most expensive album ever recorded at the time of its release.",
|
||||
"releaseType": "Album",
|
||||
"releaseStatus": "Official",
|
||||
"totalDiscs": 1,
|
||||
"totalTracks": 12,
|
||||
"releaseInfo": {
|
||||
"originalReleaseDate": "1975-11-21",
|
||||
"originalReleaseYear": 1975,
|
||||
"reReleaseDate": null,
|
||||
"reReleaseYear": null,
|
||||
"releaseCountry": "GB",
|
||||
"releaseVersion": "Remastered"
|
||||
},
|
||||
"language": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"originalLanguage": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"genres": [
|
||||
{
|
||||
"name": "Rock"
|
||||
},
|
||||
{
|
||||
"name": "Progressive Rock"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"name": "classic"
|
||||
},
|
||||
{
|
||||
"name": "vinyl"
|
||||
}
|
||||
]
|
||||
},
|
||||
"mediaFormat": "CD",
|
||||
"barcode": "0042282778329",
|
||||
"catalogNumber": "EMC 4008",
|
||||
"musicBrainzReleaseId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
|
||||
"musicBrainzReleaseGroupId": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e",
|
||||
"musicBrainzReleaseArtistId": "c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f",
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null,
|
||||
"contributors": [
|
||||
{
|
||||
"contributorId": "0e7b4a6c-5f8d-6b9e-ca0b-3c4d5e6f7a8b",
|
||||
"role": "Producer"
|
||||
},
|
||||
{
|
||||
"contributorId": "1a8c5b7d-6a9e-7c0f-db1c-4d5e6f7a8b9c",
|
||||
"role": "Engineer"
|
||||
}
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.5,
|
||||
"maxValue": 5,
|
||||
"source": "MusicBrainz",
|
||||
"voteCount": 2345
|
||||
},
|
||||
{
|
||||
"value": 4.8,
|
||||
"maxValue": 5,
|
||||
"source": "LastFm",
|
||||
"voteCount": 1234
|
||||
}
|
||||
],
|
||||
"tracks": [
|
||||
{
|
||||
"id": "9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f",
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
"description": "A song by the British rock band Queen. It was written by Freddie Mercury and originally released on the album A Night at the Opera in 1975.",
|
||||
"releaseInfo": { "originalReleaseDate": "1975-10-31", "originalReleaseYear": 1975, "reReleaseDate": null, "reReleaseYear": null, "releaseCountry": "GB", "releaseVersion": "Original" },
|
||||
"language": { "languageCode": "en", "languageName": "English", "nativeName": "English" },
|
||||
"originalLanguage": { "languageCode": "en", "languageName": "English", "nativeName": "English" },
|
||||
"tags": [ { "name": "classic" }, { "name": "epic" } ],
|
||||
"genres": [ { "name": "Rock" }, { "name": "Progressive Rock" } ],
|
||||
"durationInSeconds": 354,
|
||||
"sampleRate": 44100,
|
||||
"channels": 2,
|
||||
"bitDepth": 16,
|
||||
"audioCodec": "FLAC",
|
||||
"bitrate": 980
|
||||
},
|
||||
"trackNumber": 1,
|
||||
"discNumber": 1,
|
||||
"script": "Latn",
|
||||
"key": "CMajor",
|
||||
"bpm": 72,
|
||||
"work": "Bohemian Rhapsody",
|
||||
"musicBrainzRecordingId": "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
|
||||
"musicBrainzTrackId": "e5f6a7b8-c9d0-4e1f-2a3b-4c5d6e7f8a9b",
|
||||
"musicBrainzWorkId": "f6a7b8c9-d0e1-4f2a-3b4c-5d6e7f8a9b0c",
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null,
|
||||
"contributors": [
|
||||
{
|
||||
"contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d",
|
||||
"role": "Vocals"
|
||||
},
|
||||
{
|
||||
"contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e",
|
||||
"role": "Guitar"
|
||||
}
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.5,
|
||||
"maxValue": 5,
|
||||
"source": "MusicBrainz",
|
||||
"voteCount": 2345
|
||||
},
|
||||
{
|
||||
"value": 4.8,
|
||||
"maxValue": 5,
|
||||
"source": "LastFm",
|
||||
"voteCount": 1234
|
||||
}
|
||||
],
|
||||
"moods": [
|
||||
{ "name": "dramatic" },
|
||||
{ "name": "anxious" }
|
||||
],
|
||||
"isrcs": [
|
||||
{ "value": "GBUM71029604" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "8e1f2a3b-4c5d-4e6f-8a9b-0c1d2e3f4a5b",
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/07-youre-my-best-friend.flac",
|
||||
"metadata": {
|
||||
"title": "You're My Best Friend",
|
||||
"originalTitle": "You're My Best Friend",
|
||||
"description": "A song by the British rock band Queen, written by bass guitarist John Deacon. It was originally released on the album A Night at the Opera in 1975 and as a single in 1976.",
|
||||
"releaseInfo": { "originalReleaseDate": "1976-06-18", "originalReleaseYear": 1976, "reReleaseDate": null, "reReleaseYear": null, "releaseCountry": "GB", "releaseVersion": "Original" },
|
||||
"language": { "languageCode": "en", "languageName": "English", "nativeName": "English" },
|
||||
"originalLanguage": { "languageCode": "en", "languageName": "English", "nativeName": "English" },
|
||||
"tags": [ { "name": "classic" }, { "name": "love" } ],
|
||||
"genres": [ { "name": "Rock" }, { "name": "Pop Rock" } ],
|
||||
"durationInSeconds": 181,
|
||||
"sampleRate": 44100,
|
||||
"channels": 2,
|
||||
"bitDepth": 16,
|
||||
"audioCodec": "FLAC",
|
||||
"bitrate": 912
|
||||
},
|
||||
"trackNumber": 7,
|
||||
"discNumber": 1,
|
||||
"script": "Latn",
|
||||
"key": "BMajor",
|
||||
"bpm": 118,
|
||||
"work": "You're My Best Friend",
|
||||
"musicBrainzRecordingId": "0f3e4d5c-6b7a-4f8e-9d0c-1b2a3c4d5e6f",
|
||||
"musicBrainzTrackId": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
|
||||
"musicBrainzWorkId": "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e",
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null,
|
||||
"contributors": [
|
||||
{
|
||||
"contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d",
|
||||
"role": "Vocals"
|
||||
},
|
||||
{
|
||||
"contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e",
|
||||
"role": "Guitar"
|
||||
}
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.2,
|
||||
"maxValue": 5,
|
||||
"source": "MusicBrainz",
|
||||
"voteCount": 1234
|
||||
},
|
||||
{
|
||||
"value": 4.4,
|
||||
"maxValue": 5,
|
||||
"source": "LastFm",
|
||||
"voteCount": 567
|
||||
}
|
||||
],
|
||||
"moods": [
|
||||
{ "name": "happy" },
|
||||
{ "name": "warm" }
|
||||
],
|
||||
"isrcs": [
|
||||
{ "value": "GBUM71029609" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": "2025-02-01T12:00:00.0000000Z"
|
||||
}
|
||||
@@ -422,7 +1071,7 @@ PUT api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a
|
||||
### Delete Artist
|
||||
|
||||
```js
|
||||
DELETE api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a
|
||||
DELETE api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/{artistId}
|
||||
```
|
||||
|
||||
```js
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#### Get Album Tracks Request
|
||||
|
||||
```js
|
||||
GET api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks
|
||||
GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks
|
||||
```
|
||||
|
||||
#### Get Album Tracks Response
|
||||
@@ -42,9 +42,22 @@ GET api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
"description": "A song by the British rock band Queen. It was written by Freddie Mercury and originally released on the album A Night at the Opera in 1975.",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
"description": "A song by the British rock band Queen. It was written by Freddie Mercury and originally released on the album A Night at the Opera in 1975.",
|
||||
"releaseInfo": { "originalReleaseDate": "1975-10-31", "originalReleaseYear": 1975, "reReleaseDate": null, "reReleaseYear": null, "releaseCountry": "GB", "releaseVersion": "Original" },
|
||||
"language": { "languageCode": "en", "languageName": "English", "nativeName": "English" },
|
||||
"originalLanguage": { "languageCode": "en", "languageName": "English", "nativeName": "English" },
|
||||
"tags": [ { "name": "classic" }, { "name": "epic" } ],
|
||||
"genres": [ { "name": "Rock" }, { "name": "Progressive Rock" } ],
|
||||
"durationInSeconds": 354,
|
||||
"sampleRate": 44100,
|
||||
"channels": 2,
|
||||
"bitDepth": 16,
|
||||
"audioCodec": "FLAC",
|
||||
"bitrate": 980
|
||||
},
|
||||
"trackNumber": 1,
|
||||
"discNumber": 1,
|
||||
"script": "Latn",
|
||||
@@ -56,6 +69,16 @@ GET api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2
|
||||
"musicBrainzWorkId": "f6a7b8c9-d0e1-4f2a-3b4c-5d6e7f8a9b0c",
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null,
|
||||
"contributors": [
|
||||
{
|
||||
"contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d",
|
||||
"role": "Vocals"
|
||||
},
|
||||
{
|
||||
"contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e",
|
||||
"role": "Guitar"
|
||||
}
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.5,
|
||||
@@ -70,40 +93,6 @@ GET api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2
|
||||
"voteCount": 1234
|
||||
}
|
||||
],
|
||||
"durationInSeconds": 354,
|
||||
"sampleRate": 44100,
|
||||
"channels": 2,
|
||||
"bitDepth": 16,
|
||||
"audioCodec": "FLAC",
|
||||
"bitrate": 980,
|
||||
"originalReleaseDate": "1975-10-31",
|
||||
"originalReleaseYear": 1975,
|
||||
"reReleaseDate": null,
|
||||
"reReleaseYear": null,
|
||||
"releaseCountry": "GB",
|
||||
"releaseVersion": "Original",
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"languageNativeName": "English",
|
||||
"originalLanguageCode": "en",
|
||||
"originalLanguageName": "English",
|
||||
"originalLanguageNativeName": "English",
|
||||
"genres": [
|
||||
{
|
||||
"name": "Rock"
|
||||
},
|
||||
{
|
||||
"name": "Progressive Rock"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"name": "classic"
|
||||
},
|
||||
{
|
||||
"name": "epic"
|
||||
}
|
||||
],
|
||||
"moods": [
|
||||
{
|
||||
"name": "dramatic"
|
||||
@@ -127,7 +116,7 @@ GET api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2
|
||||
#### Get Album Tracks Lite Request
|
||||
|
||||
```js
|
||||
GET api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/lite?currentPage=1&perPage=10
|
||||
GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/lite?currentPage=1&perPage=10
|
||||
```
|
||||
|
||||
| Query Parameter | Type | Description |
|
||||
@@ -164,13 +153,11 @@ GET api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2
|
||||
#### Add Track Request
|
||||
|
||||
```js
|
||||
POST api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks
|
||||
POST api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
@@ -218,7 +205,7 @@ POST api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c
|
||||
"musicBrainzRecordingId": "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
|
||||
"musicBrainzTrackId": "e5f6a7b8-c9d0-4e1f-2a3b-4c5d6e7f8a9b",
|
||||
"musicBrainzWorkId": "f6a7b8c9-d0e1-4f2a-3b4c-5d6e7f8a9b0c",
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e", "role": "Guitar" }
|
||||
],
|
||||
@@ -260,7 +247,7 @@ The response carries the full details of the newly created track, using the same
|
||||
#### Get Track Request
|
||||
|
||||
```js
|
||||
GET api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f
|
||||
GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f
|
||||
```
|
||||
|
||||
#### Get Track Response
|
||||
@@ -275,9 +262,22 @@ GET api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
"description": "A song by the British rock band Queen. It was written by Freddie Mercury and originally released on the album A Night at the Opera in 1975.",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
"description": "A song by the British rock band Queen. It was written by Freddie Mercury and originally released on the album A Night at the Opera in 1975.",
|
||||
"releaseInfo": { "originalReleaseDate": "1975-10-31", "originalReleaseYear": 1975, "reReleaseDate": null, "reReleaseYear": null, "releaseCountry": "GB", "releaseVersion": "Original" },
|
||||
"language": { "languageCode": "en", "languageName": "English", "nativeName": "English" },
|
||||
"originalLanguage": { "languageCode": "en", "languageName": "English", "nativeName": "English" },
|
||||
"tags": [ { "name": "classic" }, { "name": "epic" } ],
|
||||
"genres": [ { "name": "Rock" }, { "name": "Progressive Rock" } ],
|
||||
"durationInSeconds": 354,
|
||||
"sampleRate": 44100,
|
||||
"channels": 2,
|
||||
"bitDepth": 16,
|
||||
"audioCodec": "FLAC",
|
||||
"bitrate": 980
|
||||
},
|
||||
"trackNumber": 1,
|
||||
"discNumber": 1,
|
||||
"script": "Latn",
|
||||
@@ -289,6 +289,16 @@ GET api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2
|
||||
"musicBrainzWorkId": "f6a7b8c9-d0e1-4f2a-3b4c-5d6e7f8a9b0c",
|
||||
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
|
||||
"updatedOnUtc": null,
|
||||
"contributors": [
|
||||
{
|
||||
"contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d",
|
||||
"role": "Vocals"
|
||||
},
|
||||
{
|
||||
"contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e",
|
||||
"role": "Guitar"
|
||||
}
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.5,
|
||||
@@ -303,40 +313,6 @@ GET api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2
|
||||
"voteCount": 1234
|
||||
}
|
||||
],
|
||||
"durationInSeconds": 354,
|
||||
"sampleRate": 44100,
|
||||
"channels": 2,
|
||||
"bitDepth": 16,
|
||||
"audioCodec": "FLAC",
|
||||
"bitrate": 980,
|
||||
"originalReleaseDate": "1975-10-31",
|
||||
"originalReleaseYear": 1975,
|
||||
"reReleaseDate": null,
|
||||
"reReleaseYear": null,
|
||||
"releaseCountry": "GB",
|
||||
"releaseVersion": "Original",
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"languageNativeName": "English",
|
||||
"originalLanguageCode": "en",
|
||||
"originalLanguageName": "English",
|
||||
"originalLanguageNativeName": "English",
|
||||
"genres": [
|
||||
{
|
||||
"name": "Rock"
|
||||
},
|
||||
{
|
||||
"name": "Progressive Rock"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"name": "classic"
|
||||
},
|
||||
{
|
||||
"name": "epic"
|
||||
}
|
||||
],
|
||||
"moods": [
|
||||
{
|
||||
"name": "dramatic"
|
||||
@@ -359,14 +335,11 @@ GET api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2
|
||||
#### Update Track Request
|
||||
|
||||
```js
|
||||
PUT api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f
|
||||
PUT api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"trackId": "9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
@@ -414,7 +387,7 @@ PUT api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2
|
||||
"musicBrainzRecordingId": "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
|
||||
"musicBrainzTrackId": "e5f6a7b8-c9d0-4e1f-2a3b-4c5d6e7f8a9b",
|
||||
"musicBrainzWorkId": "f6a7b8c9-d0e1-4f2a-3b4c-5d6e7f8a9b0c",
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e", "role": "Guitar" }
|
||||
],
|
||||
@@ -454,7 +427,7 @@ The response carries the full details of the updated track, using the same shape
|
||||
### Delete Track
|
||||
|
||||
```js
|
||||
DELETE api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f
|
||||
DELETE api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f
|
||||
```
|
||||
|
||||
```js
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
## [Audio Library Aggregate](#audio-library-aggregate)
|
||||
|
||||
The audio library aggregate is the aggregate root of the `MusicLibrary` aggregate, which models the music of a media library. An artist is the aggregate root, owning its albums, and each album owns its tracks. Albums and tracks carry full metadata: title, description, release information, languages, genres and tags, and the tracks additionally carry the audio characteristics of their file, their moods and their ISRC codes. The credits of the media contributors that make up an artist, or that performed on an album or a track, are carried as `MusicMediaContributorCredit` value objects.
|
||||
The audio library aggregate is the aggregate root of the `MusicLibrary` aggregate, which models the music of a media library. An artist is the aggregate root, owning its albums, and each album owns its tracks. Albums and tracks carry full metadata: title, description, release information, languages, genres and tags, and the tracks additionally carry the audio characteristics of their file, their moods and their ISRC codes. The media contributors that make up an artist, or that performed on an album or a track, are carried as `MusicMediaContributor` value objects.
|
||||
|
||||
### [Artist](#artist)
|
||||
|
||||
@@ -20,7 +20,7 @@ class Artist
|
||||
string name,
|
||||
Optional<string> website,
|
||||
Optional<MusicBrainzId> musicBrainzArtistId,
|
||||
List<MusicMediaContributorCredit> credits,
|
||||
List<MusicMediaContributor> contributors,
|
||||
List<Album> albums);
|
||||
}
|
||||
```
|
||||
@@ -38,7 +38,7 @@ class Artist
|
||||
"musicBrainzArtistId": {
|
||||
"value": "00000000-0000-0000-0000-000000000000"
|
||||
},
|
||||
"credits": [],
|
||||
"contributors": [],
|
||||
"albums": [
|
||||
{
|
||||
"value": "00000000-0000-0000-0000-000000000000"
|
||||
@@ -60,7 +60,7 @@ class Album
|
||||
Optional<MusicBrainzId> musicBrainzReleaseId,
|
||||
Optional<MusicBrainzId> musicBrainzReleaseGroupId,
|
||||
Optional<MusicBrainzId> musicBrainzReleaseArtistId,
|
||||
List<MusicMediaContributorCredit> credits,
|
||||
List<MusicMediaContributor> contributors,
|
||||
List<AudioRating> ratings,
|
||||
List<Track> tracks);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ class Album
|
||||
"musicBrainzReleaseArtistId": {
|
||||
"value": "00000000-0000-0000-0000-000000000000"
|
||||
},
|
||||
"credits": [],
|
||||
"contributors": [],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.5,
|
||||
@@ -163,7 +163,7 @@ class Track
|
||||
Optional<MusicBrainzId> musicBrainzRecordingId,
|
||||
Optional<MusicBrainzId> musicBrainzTrackId,
|
||||
Optional<MusicBrainzId> musicBrainzWorkId,
|
||||
List<MusicMediaContributorCredit> credits,
|
||||
List<MusicMediaContributor> contributors,
|
||||
List<AudioRating> ratings);
|
||||
}
|
||||
```
|
||||
@@ -238,7 +238,7 @@ class Track
|
||||
"musicBrainzWorkId": {
|
||||
"value": "00000000-0000-0000-0000-000000000000"
|
||||
},
|
||||
"credits": [],
|
||||
"contributors": [],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.5,
|
||||
|
||||
@@ -27,7 +27,7 @@ class Book
|
||||
Optional<string> barnesAndNobleId,
|
||||
Optional<string> appleBooksId,
|
||||
List<Isbn> isbns,
|
||||
List<BookMediaContributorCredit> contributors,
|
||||
List<BookMediaContributor> contributors,
|
||||
List<BookRating> ratings);
|
||||
}
|
||||
```
|
||||
@@ -46,7 +46,7 @@ class Book
|
||||
"originalReleaseYear": 1954,
|
||||
"reReleaseDate": "2001-09-06",
|
||||
"reReleaseYear": 2001,
|
||||
"releaseCountry": "uk",
|
||||
"releaseCountry": "GB",
|
||||
"releaseVersion": "50th Anniversary Edition"
|
||||
},
|
||||
"genres": [
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
POST {{host}}/api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums
|
||||
POST {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"metadata": {
|
||||
"title": "A Night at the Opera",
|
||||
"originalTitle": "A Night at the Opera",
|
||||
@@ -45,7 +44,7 @@ Content-Type: application/json
|
||||
"musicBrainzReleaseId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
|
||||
"musicBrainzReleaseGroupId": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e",
|
||||
"musicBrainzReleaseArtistId": "c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f",
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "0e7b4a6c-5f8d-6b9e-ca0b-3c4d5e6f7a8b", "role": "Producer" },
|
||||
{ "contributorId": "1a8c5b7d-6a9e-7c0f-db1c-4d5e6f7a8b9c", "role": "Engineer" }
|
||||
],
|
||||
@@ -65,8 +64,6 @@ Content-Type: application/json
|
||||
],
|
||||
"tracks": [
|
||||
{
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
@@ -114,7 +111,7 @@ Content-Type: application/json
|
||||
"musicBrainzRecordingId": "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
|
||||
"musicBrainzTrackId": "e5f6a7b8-c9d0-4e1f-2a3b-4c5d6e7f8a9b",
|
||||
"musicBrainzWorkId": "f6a7b8c9-d0e1-4f2a-3b4c-5d6e7f8a9b0c",
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e", "role": "Guitar" }
|
||||
],
|
||||
@@ -141,8 +138,6 @@ Content-Type: application/json
|
||||
]
|
||||
},
|
||||
{
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"path": "/music/queen/a-night-at-the-opera/07-youre-my-best-friend.flac",
|
||||
"metadata": {
|
||||
"title": "You're My Best Friend",
|
||||
@@ -190,7 +185,7 @@ Content-Type: application/json
|
||||
"musicBrainzRecordingId": "0f3e4d5c-6b7a-4f8e-9d0c-1b2a3c4d5e6f",
|
||||
"musicBrainzTrackId": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
|
||||
"musicBrainzWorkId": "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e",
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "8c5f2e4a-3d6b-4f7c-ae8f-1a2b3c4d5e6f", "role": "BassGuitar" }
|
||||
],
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
DELETE {{host}}/api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f
|
||||
DELETE {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -1,2 +1,2 @@
|
||||
GET {{host}}/api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f
|
||||
GET {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
GET {{host}}/api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks
|
||||
GET {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
GET {{host}}/api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/lite?currentPage=1&perPage=10
|
||||
GET {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/lite?currentPage=1&perPage=10
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -1,10 +1,8 @@
|
||||
PUT {{host}}/api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f
|
||||
PUT {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"metadata": {
|
||||
"title": "A Night at the Opera",
|
||||
"originalTitle": "A Night at the Opera",
|
||||
@@ -46,7 +44,7 @@ Content-Type: application/json
|
||||
"musicBrainzReleaseId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
|
||||
"musicBrainzReleaseGroupId": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e",
|
||||
"musicBrainzReleaseArtistId": "c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f",
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "0e7b4a6c-5f8d-6b9e-ca0b-3c4d5e6f7a8b", "role": "Producer" },
|
||||
{ "contributorId": "1a8c5b7d-6a9e-7c0f-db1c-4d5e6f7a8b9c", "role": "Engineer" }
|
||||
],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
POST {{host}}/api/v1/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists
|
||||
POST {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
Content-Type: application/json
|
||||
|
||||
@@ -6,7 +6,7 @@ Content-Type: application/json
|
||||
"name": "Queen",
|
||||
"website": "https://www.queenonline.com",
|
||||
"musicBrainzArtistId": "6f9c0b2a-1d3e-4a5b-8c7d-9e0f1a2b3c4d",
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e", "role": "Guitar" }
|
||||
],
|
||||
@@ -53,7 +53,7 @@ Content-Type: application/json
|
||||
"musicBrainzReleaseId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
|
||||
"musicBrainzReleaseGroupId": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e",
|
||||
"musicBrainzReleaseArtistId": "c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f",
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "0e7b4a6c-5f8d-6b9e-ca0b-3c4d5e6f7a8b", "role": "Producer" },
|
||||
{ "contributorId": "1a8c5b7d-6a9e-7c0f-db1c-4d5e6f7a8b9c", "role": "Engineer" }
|
||||
],
|
||||
@@ -127,7 +127,7 @@ Content-Type: application/json
|
||||
"isrcs": [
|
||||
{ "value": "GBUM71029604" }
|
||||
],
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e", "role": "Guitar" }
|
||||
],
|
||||
@@ -201,7 +201,7 @@ Content-Type: application/json
|
||||
"isrcs": [
|
||||
{ "value": "GBUM71029609" }
|
||||
],
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "8c5f2e4a-3d6b-4f7c-ae8f-1a2b3c4d5e6f", "role": "BassGuitar" }
|
||||
],
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
DELETE {{host}}/api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a
|
||||
DELETE {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/{{$guid}}
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -1,2 +1,2 @@
|
||||
GET {{host}}/api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a
|
||||
GET {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/{{$guid}}
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
GET {{host}}/api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums
|
||||
GET {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/{{$guid}}/albums
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
GET {{host}}/api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/lite?currentPage=1&perPage=10
|
||||
GET {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/{{$guid}}/albums/lite?currentPage=1&perPage=10
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -1,2 +1,2 @@
|
||||
GET {{host}}/api/v1/artists?libraryId=3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a¤tPage=1&perPage=10&searchTerm=queen
|
||||
GET {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists?currentPage=1&perPage=10&searchTerm=queen
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
GET {{host}}/api/v1/artists/lite?libraryId=3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a¤tPage=1&perPage=10&searchTerm=queen
|
||||
GET {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/lite?currentPage=1&perPage=10&searchTerm=queen
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
+215
-3
@@ -1,14 +1,226 @@
|
||||
PUT {{host}}/api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a
|
||||
PUT {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/{{$guid}}
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"name": "Queen",
|
||||
"website": "https://www.queenonline.com",
|
||||
"musicBrainzArtistId": "6f9c0b2a-1d3e-4a5b-8c7d-9e0f1a2b3c4d",
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e", "role": "Guitar" }
|
||||
],
|
||||
"albums": [
|
||||
{
|
||||
"metadata": {
|
||||
"title": "A Night at the Opera",
|
||||
"originalTitle": "A Night at the Opera",
|
||||
"description": "The fourth studio album by the British rock band Queen, released in 1975. It was the most expensive album ever recorded at the time of its release.",
|
||||
"releaseInfo": {
|
||||
"originalReleaseDate": "1975-11-21",
|
||||
"originalReleaseYear": 1975,
|
||||
"reReleaseDate": null,
|
||||
"reReleaseYear": null,
|
||||
"releaseCountry": "GB",
|
||||
"releaseVersion": "Remastered"
|
||||
},
|
||||
"language": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"originalLanguage": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"tags": [
|
||||
{ "name": "classic" },
|
||||
{ "name": "vinyl" }
|
||||
],
|
||||
"genres": [
|
||||
{ "name": "Rock" },
|
||||
{ "name": "Progressive Rock" }
|
||||
],
|
||||
"releaseType": "Album",
|
||||
"releaseStatus": "Official",
|
||||
"totalDiscs": 1,
|
||||
"totalTracks": 12
|
||||
},
|
||||
"mediaFormat": "CD",
|
||||
"barcode": "0042282778329",
|
||||
"catalogNumber": "EMC 4008",
|
||||
"musicBrainzReleaseId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
|
||||
"musicBrainzReleaseGroupId": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e",
|
||||
"musicBrainzReleaseArtistId": "c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f",
|
||||
"contributors": [
|
||||
{ "contributorId": "0e7b4a6c-5f8d-6b9e-ca0b-3c4d5e6f7a8b", "role": "Producer" },
|
||||
{ "contributorId": "1a8c5b7d-6a9e-7c0f-db1c-4d5e6f7a8b9c", "role": "Engineer" }
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.5,
|
||||
"maxValue": 5,
|
||||
"source": "MusicBrainz",
|
||||
"voteCount": 2345
|
||||
},
|
||||
{
|
||||
"value": 4.8,
|
||||
"maxValue": 5,
|
||||
"source": "LastFm",
|
||||
"voteCount": 1234
|
||||
}
|
||||
],
|
||||
"tracks": [
|
||||
{
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
"originalTitle": "Bohemian Rhapsody",
|
||||
"description": "A song by the British rock band Queen. It was written by Freddie Mercury and originally released on the album A Night at the Opera in 1975.",
|
||||
"releaseInfo": {
|
||||
"originalReleaseDate": "1975-10-31",
|
||||
"originalReleaseYear": 1975,
|
||||
"reReleaseDate": null,
|
||||
"reReleaseYear": null,
|
||||
"releaseCountry": "GB",
|
||||
"releaseVersion": "Original"
|
||||
},
|
||||
"language": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"originalLanguage": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"tags": [
|
||||
{ "name": "classic" },
|
||||
{ "name": "epic" }
|
||||
],
|
||||
"genres": [
|
||||
{ "name": "Rock" },
|
||||
{ "name": "Progressive Rock" }
|
||||
],
|
||||
"durationInSeconds": 354,
|
||||
"sampleRate": 44100,
|
||||
"channels": 2,
|
||||
"bitDepth": 16,
|
||||
"audioCodec": "FLAC",
|
||||
"bitrate": 980
|
||||
},
|
||||
"trackNumber": 1,
|
||||
"discNumber": 1,
|
||||
"script": "Latn",
|
||||
"key": "CMajor",
|
||||
"bpm": 72,
|
||||
"work": "Bohemian Rhapsody",
|
||||
"musicBrainzRecordingId": "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
|
||||
"musicBrainzTrackId": "e5f6a7b8-c9d0-4e1f-2a3b-4c5d6e7f8a9b",
|
||||
"musicBrainzWorkId": "f6a7b8c9-d0e1-4f2a-3b4c-5d6e7f8a9b0c",
|
||||
"moods": [
|
||||
{ "name": "dramatic" },
|
||||
{ "name": "anxious" }
|
||||
],
|
||||
"isrcs": [
|
||||
{ "value": "GBUM71029604" }
|
||||
],
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e", "role": "Guitar" }
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.5,
|
||||
"maxValue": 5,
|
||||
"source": "MusicBrainz",
|
||||
"voteCount": 2345
|
||||
},
|
||||
{
|
||||
"value": 4.8,
|
||||
"maxValue": 5,
|
||||
"source": "LastFm",
|
||||
"voteCount": 1234
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "/music/queen/a-night-at-the-opera/07-youre-my-best-friend.flac",
|
||||
"metadata": {
|
||||
"title": "You're My Best Friend",
|
||||
"originalTitle": "You're My Best Friend",
|
||||
"description": "A song by the British rock band Queen, written by bass guitarist John Deacon. It was originally released on the album A Night at the Opera in 1975 and as a single in 1976.",
|
||||
"releaseInfo": {
|
||||
"originalReleaseDate": "1976-06-18",
|
||||
"originalReleaseYear": 1976,
|
||||
"reReleaseDate": null,
|
||||
"reReleaseYear": null,
|
||||
"releaseCountry": "GB",
|
||||
"releaseVersion": "Original"
|
||||
},
|
||||
"language": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"originalLanguage": {
|
||||
"languageCode": "en",
|
||||
"languageName": "English",
|
||||
"nativeName": "English"
|
||||
},
|
||||
"tags": [
|
||||
{ "name": "classic" },
|
||||
{ "name": "love" }
|
||||
],
|
||||
"genres": [
|
||||
{ "name": "Rock" },
|
||||
{ "name": "Pop Rock" }
|
||||
],
|
||||
"durationInSeconds": 181,
|
||||
"sampleRate": 44100,
|
||||
"channels": 2,
|
||||
"bitDepth": 16,
|
||||
"audioCodec": "FLAC",
|
||||
"bitrate": 912
|
||||
},
|
||||
"trackNumber": 7,
|
||||
"discNumber": 1,
|
||||
"script": "Latn",
|
||||
"key": "BMajor",
|
||||
"bpm": 118,
|
||||
"work": "You're My Best Friend",
|
||||
"musicBrainzRecordingId": "0f3e4d5c-6b7a-4f8e-9d0c-1b2a3c4d5e6f",
|
||||
"musicBrainzTrackId": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
|
||||
"musicBrainzWorkId": "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e",
|
||||
"moods": [
|
||||
{ "name": "happy" },
|
||||
{ "name": "warm" }
|
||||
],
|
||||
"isrcs": [
|
||||
{ "value": "GBUM71029609" }
|
||||
],
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "8c5f2e4a-3d6b-4f7c-ae8f-1a2b3c4d5e6f", "role": "BassGuitar" }
|
||||
],
|
||||
"ratings": [
|
||||
{
|
||||
"value": 4.2,
|
||||
"maxValue": 5,
|
||||
"source": "MusicBrainz",
|
||||
"voteCount": 1234
|
||||
},
|
||||
{
|
||||
"value": 4.4,
|
||||
"maxValue": 5,
|
||||
"source": "LastFm",
|
||||
"voteCount": 567
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
POST {{host}}/api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks
|
||||
POST {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
@@ -52,7 +50,7 @@ Content-Type: application/json
|
||||
"musicBrainzRecordingId": "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
|
||||
"musicBrainzTrackId": "e5f6a7b8-c9d0-4e1f-2a3b-4c5d6e7f8a9b",
|
||||
"musicBrainzWorkId": "f6a7b8c9-d0e1-4f2a-3b4c-5d6e7f8a9b0c",
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e", "role": "Guitar" }
|
||||
],
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
DELETE {{host}}/api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f
|
||||
DELETE {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -1,2 +1,2 @@
|
||||
GET {{host}}/api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f
|
||||
GET {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -1,11 +1,8 @@
|
||||
PUT {{host}}/api/v1/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f
|
||||
PUT {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a/albums/e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f/tracks/9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"artistId": "d7c41e6a-9f2b-4b1c-9a3e-7f6e5d4c3b2a",
|
||||
"albumId": "e8d52f7b-0a3c-4c2d-ab4f-8a7b6c5d4e3f",
|
||||
"trackId": "9f0e1d2c-3b4a-4c6d-8e7f-9a0b1c2d3e4f",
|
||||
"path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
"metadata": {
|
||||
"title": "Bohemian Rhapsody",
|
||||
@@ -53,7 +50,7 @@ Content-Type: application/json
|
||||
"musicBrainzRecordingId": "d4e5f6a7-b8c9-4d0e-1f2a-3b4c5d6e7f8a",
|
||||
"musicBrainzTrackId": "e5f6a7b8-c9d0-4e1f-2a3b-4c5d6e7f8a9b",
|
||||
"musicBrainzWorkId": "f6a7b8c9-d0e1-4f2a-3b4c-5d6e7f8a9b0c",
|
||||
"credits": [
|
||||
"contributors": [
|
||||
{ "contributorId": "6a3f0c2d-1b4e-4f5a-8c6d-9e0f1a2b3c4d", "role": "Vocals" },
|
||||
{ "contributorId": "7b4e1d3f-2c5a-4e6b-9d7e-0f1a2b3c4d5e", "role": "Guitar" }
|
||||
],
|
||||
|
||||
+2
-1
@@ -1 +1,2 @@
|
||||
GET {{host}}/api/v1/books/{{$guid}}
|
||||
GET {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/books/{{$guid}}
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
PUT {{host}}/api/v1/books/{{$guid}}/cover
|
||||
PUT {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/books/{{$guid}}/cover
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
Content-Type: multipart/form-data; boundary=LuminaBoundary
|
||||
|
||||
--LuminaBoundary
|
||||
Content-Disposition: form-data; name="file"; filename="cover.jpg"
|
||||
Content-Disposition: form-data; name="cover"; filename="cover.jpg"
|
||||
Content-Type: image/jpeg
|
||||
|
||||
< ./cover.jpg
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
GET {{host}}/api/v1/books/{{$guid}}/reading/availability
|
||||
GET {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/books/{{$guid}}/reading/availability
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
GET {{host}}/api/v1/books/{{$guid}}/reading/manifest
|
||||
GET {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/books/{{$guid}}/reading/manifest
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
GET {{host}}/api/v1/books/{{$guid}}/reading/resources/0f4d6e2b1c9a4f3e8d7c6b5a4f3e2d1c
|
||||
GET {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/books/{{$guid}}/reading/resources/0f4d6e2b1c9a4f3e8d7c6b5a4f3e2d1c
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
GET {{host}}/api/v1/books/{{$guid}}/reading/sections/chapter1
|
||||
GET {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/books/{{$guid}}/reading/sections/chapter1
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -1,7 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
@@ -68,7 +67,7 @@ internal static class CalibreMapper
|
||||
/// <returns>The release information of the book, always present even when the publication date is missing.</returns>
|
||||
private static ReleaseInfoDto BuildReleaseInfo(DateTimeOffset? publishDate)
|
||||
{
|
||||
// the release info must always be present, even when the publication date is missing, so that the metadata can be applied to the book
|
||||
// The release info must always be present, even when the publication date is missing, so that the metadata can be applied to the book.
|
||||
if (publishDate is null)
|
||||
{
|
||||
return new ReleaseInfoDto(
|
||||
@@ -124,20 +123,20 @@ internal static class CalibreMapper
|
||||
List<MediaContributorDto> result = [];
|
||||
HashSet<string> seen = new(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
void Add(string? displayName, string role, MediaContributorRoleCategory category)
|
||||
void Add(string? displayName, MediaContributorRole role)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(displayName) || !seen.Add($"{displayName}|{role}"))
|
||||
return;
|
||||
result.Add(new MediaContributorDto(
|
||||
Name: new MediaContributorNameDto(DisplayName: displayName.Trim(), LegalName: null),
|
||||
Role: new MediaContributorRoleDto(Name: role, Category: category))
|
||||
Role: role)
|
||||
);
|
||||
}
|
||||
|
||||
foreach (OpfCreatorDto creator in creators)
|
||||
Add(creator.Name, "Author", MediaContributorRoleCategory.Author);
|
||||
Add(creator.Name, MediaContributorRole.Author);
|
||||
foreach (OpfContributorDto contributor in contributors)
|
||||
Add(contributor.Name, MapContributorRole(contributor.Role), MapContributorCategory(contributor.Role));
|
||||
Add(contributor.Name, MapContributorRole(contributor.Role));
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -189,7 +188,7 @@ internal static class CalibreMapper
|
||||
private static string? NormalizeIsbn(string isbn)
|
||||
{
|
||||
string normalized = new string([.. isbn.Where(character => character is not '-' && !char.IsWhiteSpace(character))]).ToUpperInvariant();
|
||||
// valid ISBNs must be 10 or 13 characters in length, all characters except the last one must be digits, and the last one must be a digit for ISBN-13 and X for ISBN-10
|
||||
// Valid ISBNs must be 10 or 13 characters in length, all characters except the last one must be digits, and the last one must be a digit for ISBN-13 and X for ISBN-10.
|
||||
if ((normalized.Length != 10 && normalized.Length != 13) ||
|
||||
normalized[..^1].Any(character => !char.IsDigit(character)) ||
|
||||
(!char.IsDigit(normalized[^1]) && !(normalized.Length == 10 && normalized[^1] == 'X')))
|
||||
@@ -214,30 +213,20 @@ internal static class CalibreMapper
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maps a creator or contributor role code into a role name.
|
||||
/// Maps a creator or contributor role code into the canonical role.
|
||||
/// </summary>
|
||||
/// <param name="role">The role code to map.</param>
|
||||
/// <returns>The mapped role name.</returns>
|
||||
private static string MapContributorRole(string? role)
|
||||
{
|
||||
return string.Equals(role, "aut", StringComparison.OrdinalIgnoreCase) ? "Author" : string.IsNullOrWhiteSpace(role) ? "Contributor" : role;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maps a creator or contributor role code into the canonical category of the role.
|
||||
/// </summary>
|
||||
/// <param name="role">The role code to map.</param>
|
||||
/// <returns>The canonical category of the role.</returns>
|
||||
private static MediaContributorRoleCategory MapContributorCategory(string? role)
|
||||
/// <returns>The canonical role.</returns>
|
||||
private static MediaContributorRole MapContributorRole(string? role)
|
||||
{
|
||||
if (string.Equals(role, "aut", StringComparison.OrdinalIgnoreCase) || role?.Contains("author", StringComparison.OrdinalIgnoreCase) == true)
|
||||
return MediaContributorRoleCategory.Author;
|
||||
return MediaContributorRole.Author;
|
||||
if (string.Equals(role, "ill", StringComparison.OrdinalIgnoreCase))
|
||||
return MediaContributorRoleCategory.Illustrator;
|
||||
return MediaContributorRole.Illustrator;
|
||||
if (string.Equals(role, "trl", StringComparison.OrdinalIgnoreCase))
|
||||
return MediaContributorRoleCategory.Translator;
|
||||
return MediaContributorRole.Translator;
|
||||
if (string.Equals(role, "bkp", StringComparison.OrdinalIgnoreCase))
|
||||
return MediaContributorRoleCategory.Publisher;
|
||||
return MediaContributorRoleCategory.Other;
|
||||
return MediaContributorRole.Publisher;
|
||||
return MediaContributorRole.Other;
|
||||
}
|
||||
}
|
||||
@@ -59,8 +59,8 @@ internal static partial class OpenLibraryMapper
|
||||
/// <param name="authors">The authors of the book.</param>
|
||||
/// <param name="ratings">The ratings of the book, or <see langword="null"/> when no ratings were found.</param>
|
||||
/// <param name="fallback">The search document used as a fallback source of data, or <see langword="null"/>.</param>
|
||||
/// <returns>The mapped book request.</returns>
|
||||
public static AddBookRequest MapDetailed(
|
||||
/// <returns>The mapped book metadata.</returns>
|
||||
public static BookMetadataDto MapDetailed(
|
||||
BookMetadataLookupDto lookup,
|
||||
OpenLibraryEditionResponse? edition,
|
||||
OpenLibraryWorkResponse? work,
|
||||
@@ -99,26 +99,23 @@ internal static partial class OpenLibraryMapper
|
||||
string? releaseCountry = edition?.PublishPlaces.FirstOrDefault() ?? fallback?.PublishPlaces.FirstOrDefault();
|
||||
string? releaseVersion = edition?.EditionName;
|
||||
|
||||
return new AddBookRequest(
|
||||
lookup.LibraryId,
|
||||
lookup.Path,
|
||||
new WrittenContentMetadataDto(
|
||||
title,
|
||||
work?.OriginalTitle,
|
||||
description,
|
||||
new ReleaseInfoDto(
|
||||
originalRelease.Date,
|
||||
originalYear,
|
||||
editionRelease.Date,
|
||||
editionRelease.Date?.Year ?? editionRelease.Year,
|
||||
MapReleaseCountry(releaseCountry),
|
||||
NullIfWhiteSpace(releaseVersion)),
|
||||
[.. genreNames.Select(name => new GenreDto(name))],
|
||||
[.. subjects.Select(name => new TagDto(name))],
|
||||
MapLanguage(currentLanguageCode),
|
||||
MapLanguage(originalLanguageCode),
|
||||
edition?.Publishers.FirstOrDefault() ?? fallback?.Publishers.FirstOrDefault(),
|
||||
edition?.NumberOfPages ?? fallback?.NumberOfPagesMedian),
|
||||
return new BookMetadataDto(
|
||||
title,
|
||||
work?.OriginalTitle,
|
||||
description,
|
||||
new ReleaseInfoDto(
|
||||
originalRelease.Date,
|
||||
originalYear,
|
||||
editionRelease.Date,
|
||||
editionRelease.Date?.Year ?? editionRelease.Year,
|
||||
MapReleaseCountry(releaseCountry),
|
||||
NullIfWhiteSpace(releaseVersion)),
|
||||
[.. genreNames.Select(name => new GenreDto(name))],
|
||||
[.. subjects.Select(name => new TagDto(name))],
|
||||
MapLanguage(currentLanguageCode),
|
||||
MapLanguage(originalLanguageCode),
|
||||
edition?.Publishers.FirstOrDefault() ?? fallback?.Publishers.FirstOrDefault(),
|
||||
edition?.NumberOfPages ?? fallback?.NumberOfPagesMedian,
|
||||
MapFormat(edition?.PhysicalFormat),
|
||||
NullIfWhiteSpace(edition?.EditionName),
|
||||
ParseVolumeNumber(edition?.Volume, edition?.Series.FirstOrDefault()),
|
||||
@@ -134,7 +131,8 @@ internal static partial class OpenLibraryMapper
|
||||
NullIfWhiteSpace(appleBooksId),
|
||||
isbns,
|
||||
contributors,
|
||||
mappedRatings);
|
||||
mappedRatings,
|
||||
CoverImagePath: null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -142,8 +140,8 @@ internal static partial class OpenLibraryMapper
|
||||
/// </summary>
|
||||
/// <param name="lookup">The lookup describing the book to map.</param>
|
||||
/// <param name="document">The search document to map.</param>
|
||||
/// <returns>The mapped book request candidate.</returns>
|
||||
public static AddBookRequest MapSearchCandidate(BookMetadataLookupDto lookup, OpenLibrarySearchDocumentResponse document)
|
||||
/// <returns>The mapped book metadata candidate.</returns>
|
||||
public static BookMetadataDto MapSearchCandidate(BookMetadataLookupDto lookup, OpenLibrarySearchDocumentResponse document)
|
||||
{
|
||||
return MapDetailed(lookup, null, null, [], null, document);
|
||||
}
|
||||
@@ -274,24 +272,24 @@ internal static partial class OpenLibraryMapper
|
||||
List<MediaContributorDto> result = [];
|
||||
HashSet<string> seen = new(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
void Add(string? displayName, string? legalName, string role, MediaContributorRoleCategory category)
|
||||
void Add(string? displayName, string? legalName, MediaContributorRole role)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(displayName) || !seen.Add($"{displayName}|{role}"))
|
||||
return;
|
||||
result.Add(new MediaContributorDto(new MediaContributorNameDto(displayName.Trim(), NullIfWhiteSpace(legalName)), new MediaContributorRoleDto(role, category)));
|
||||
result.Add(new MediaContributorDto(new MediaContributorNameDto(displayName.Trim(), NullIfWhiteSpace(legalName)), role));
|
||||
}
|
||||
|
||||
foreach (OpenLibraryAuthorResponse author in authors)
|
||||
Add(author.Name, author.PersonalName, "Author", MediaContributorRoleCategory.Author);
|
||||
Add(author.Name, author.PersonalName, MediaContributorRole.Author);
|
||||
foreach (string authorName in fallbackAuthors ?? [])
|
||||
Add(authorName, null, "Author", MediaContributorRoleCategory.Author);
|
||||
Add(authorName, null, MediaContributorRole.Author);
|
||||
|
||||
foreach (string contribution in contributions ?? [])
|
||||
{
|
||||
Match match = ContributorPattern().Match(contribution);
|
||||
string name = match.Success ? match.Groups["name"].Value.Trim() : contribution.Trim();
|
||||
string role = match.Success ? match.Groups["role"].Value.Trim() : "Contributor";
|
||||
Add(name, null, role, ContributorCategory(role));
|
||||
string role = match.Success ? match.Groups["role"].Value.Trim() : string.Empty;
|
||||
Add(name, null, ContributorRole(role));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -505,24 +503,24 @@ internal static partial class OpenLibraryMapper
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maps a contribution role into the canonical category of the role.
|
||||
/// Maps a contribution role into the canonical role.
|
||||
/// </summary>
|
||||
/// <param name="role">The role to categorize.</param>
|
||||
/// <returns>The canonical category of the role.</returns>
|
||||
private static MediaContributorRoleCategory ContributorCategory(string role)
|
||||
/// <param name="role">The role to map.</param>
|
||||
/// <returns>The canonical role.</returns>
|
||||
private static MediaContributorRole ContributorRole(string role)
|
||||
{
|
||||
if (role.Contains("illustr", StringComparison.OrdinalIgnoreCase) ||
|
||||
role.Contains("artist", StringComparison.OrdinalIgnoreCase))
|
||||
return MediaContributorRoleCategory.Illustrator;
|
||||
return MediaContributorRole.Illustrator;
|
||||
if (role.Contains("translat", StringComparison.OrdinalIgnoreCase))
|
||||
return MediaContributorRoleCategory.Translator;
|
||||
return MediaContributorRole.Translator;
|
||||
if (role.Contains("narrat", StringComparison.OrdinalIgnoreCase))
|
||||
return MediaContributorRoleCategory.Narrator;
|
||||
return MediaContributorRole.Narrator;
|
||||
if (role.Contains("edit", StringComparison.OrdinalIgnoreCase) ||
|
||||
role.Contains("author", StringComparison.OrdinalIgnoreCase) ||
|
||||
role.Contains("writer", StringComparison.OrdinalIgnoreCase))
|
||||
return MediaContributorRoleCategory.Author;
|
||||
return MediaContributorRoleCategory.Other;
|
||||
return MediaContributorRole.Author;
|
||||
return MediaContributorRole.Other;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -65,75 +65,15 @@ internal sealed class OpenLibraryBookMetadataProvider : IMetadataProvider<BookMe
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(bookMetadataLookup.Isbn) || !string.IsNullOrWhiteSpace(bookMetadataLookup.OpenLibraryId))
|
||||
{
|
||||
AddBookRequest? exactBookRequestMatch = await GetBookAsync(bookMetadataLookup, cancellationToken).ConfigureAwait(false);
|
||||
return exactBookRequestMatch is null ? [] : [new BookMetadataDto(
|
||||
exactBookRequestMatch.Metadata?.Title,
|
||||
exactBookRequestMatch.Metadata?.OriginalTitle,
|
||||
exactBookRequestMatch.Metadata?.Description,
|
||||
exactBookRequestMatch.Metadata?.ReleaseInfo,
|
||||
exactBookRequestMatch.Metadata?.Genres,
|
||||
exactBookRequestMatch.Metadata?.Tags,
|
||||
exactBookRequestMatch.Metadata?.Language,
|
||||
exactBookRequestMatch.Metadata?.OriginalLanguage,
|
||||
exactBookRequestMatch.Metadata?.Publisher,
|
||||
exactBookRequestMatch.Metadata?.PageCount,
|
||||
exactBookRequestMatch.Format,
|
||||
exactBookRequestMatch.Edition,
|
||||
exactBookRequestMatch.VolumeNumber,
|
||||
exactBookRequestMatch.Series,
|
||||
exactBookRequestMatch.ASIN,
|
||||
exactBookRequestMatch.GoodreadsId,
|
||||
exactBookRequestMatch.LCCN,
|
||||
exactBookRequestMatch.OCLCNumber,
|
||||
exactBookRequestMatch.OpenLibraryId,
|
||||
exactBookRequestMatch.LibraryThingId,
|
||||
exactBookRequestMatch.GoogleBooksId,
|
||||
exactBookRequestMatch.BarnesAndNobleId,
|
||||
exactBookRequestMatch.AppleBooksId,
|
||||
exactBookRequestMatch.ISBNs,
|
||||
exactBookRequestMatch.Contributors,
|
||||
exactBookRequestMatch.Ratings,
|
||||
CoverImagePath: null
|
||||
)];
|
||||
BookMetadataDto? exactBookMatch = await GetBookAsync(bookMetadataLookup, cancellationToken).ConfigureAwait(false);
|
||||
return exactBookMatch is null ? [] : [exactBookMatch];
|
||||
}
|
||||
|
||||
IReadOnlyList<OpenLibrarySearchDocumentResponse> openLibrarySearchDocuments = await _openLibraryHttpClient.SearchAsync(bookMetadataLookup, settings.SearchResultLimit, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return [.. openLibrarySearchDocuments
|
||||
.Where(openLibrarySearchDocument => !string.IsNullOrWhiteSpace(openLibrarySearchDocument.Title))
|
||||
.Select(openLibrarySearchDocument =>
|
||||
{
|
||||
AddBookRequest addBookRequest = OpenLibraryMapper.MapSearchCandidate(bookMetadataLookup, openLibrarySearchDocument);
|
||||
return new BookMetadataDto(
|
||||
addBookRequest.Metadata?.Title,
|
||||
addBookRequest.Metadata?.OriginalTitle,
|
||||
addBookRequest.Metadata?.Description,
|
||||
addBookRequest.Metadata?.ReleaseInfo,
|
||||
addBookRequest.Metadata?.Genres,
|
||||
addBookRequest.Metadata?.Tags,
|
||||
addBookRequest.Metadata?.Language,
|
||||
addBookRequest.Metadata?.OriginalLanguage,
|
||||
addBookRequest.Metadata?.Publisher,
|
||||
addBookRequest.Metadata?.PageCount,
|
||||
addBookRequest.Format,
|
||||
addBookRequest.Edition,
|
||||
addBookRequest.VolumeNumber,
|
||||
addBookRequest.Series,
|
||||
addBookRequest.ASIN,
|
||||
addBookRequest.GoodreadsId,
|
||||
addBookRequest.LCCN,
|
||||
addBookRequest.OCLCNumber,
|
||||
addBookRequest.OpenLibraryId,
|
||||
addBookRequest.LibraryThingId,
|
||||
addBookRequest.GoogleBooksId,
|
||||
addBookRequest.BarnesAndNobleId,
|
||||
addBookRequest.AppleBooksId,
|
||||
addBookRequest.ISBNs,
|
||||
addBookRequest.Contributors,
|
||||
addBookRequest.Ratings,
|
||||
CoverImagePath: null
|
||||
);
|
||||
})];
|
||||
.Select(openLibrarySearchDocument => OpenLibraryMapper.MapSearchCandidate(bookMetadataLookup, openLibrarySearchDocument))];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -144,45 +84,16 @@ internal sealed class OpenLibraryBookMetadataProvider : IMetadataProvider<BookMe
|
||||
/// <returns>The metadata of the media item, or <see langword="null"/> when no metadata was found.</returns>
|
||||
public async Task<BookMetadataDto?> GetMetadataAsync(BookMetadataLookupDto bookMetadataLookup, CancellationToken cancellationToken)
|
||||
{
|
||||
AddBookRequest? exactBookRequestMatch = await GetBookAsync(bookMetadataLookup, cancellationToken).ConfigureAwait(false);
|
||||
return exactBookRequestMatch is null ? null : new BookMetadataDto(
|
||||
exactBookRequestMatch.Metadata?.Title,
|
||||
exactBookRequestMatch.Metadata?.OriginalTitle,
|
||||
exactBookRequestMatch.Metadata?.Description,
|
||||
exactBookRequestMatch.Metadata?.ReleaseInfo,
|
||||
exactBookRequestMatch.Metadata?.Genres,
|
||||
exactBookRequestMatch.Metadata?.Tags,
|
||||
exactBookRequestMatch.Metadata?.Language,
|
||||
exactBookRequestMatch.Metadata?.OriginalLanguage,
|
||||
exactBookRequestMatch.Metadata?.Publisher,
|
||||
exactBookRequestMatch.Metadata?.PageCount,
|
||||
exactBookRequestMatch.Format,
|
||||
exactBookRequestMatch.Edition,
|
||||
exactBookRequestMatch.VolumeNumber,
|
||||
exactBookRequestMatch.Series,
|
||||
exactBookRequestMatch.ASIN,
|
||||
exactBookRequestMatch.GoodreadsId,
|
||||
exactBookRequestMatch.LCCN,
|
||||
exactBookRequestMatch.OCLCNumber,
|
||||
exactBookRequestMatch.OpenLibraryId,
|
||||
exactBookRequestMatch.LibraryThingId,
|
||||
exactBookRequestMatch.GoogleBooksId,
|
||||
exactBookRequestMatch.BarnesAndNobleId,
|
||||
exactBookRequestMatch.AppleBooksId,
|
||||
exactBookRequestMatch.ISBNs,
|
||||
exactBookRequestMatch.Contributors,
|
||||
exactBookRequestMatch.Ratings,
|
||||
CoverImagePath: null
|
||||
);
|
||||
return await GetBookAsync(bookMetadataLookup, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the lookup into a full book request by combining edition, work, author, and rating data from Open Library.
|
||||
/// Resolves the lookup into full book metadata by combining edition, work, author, and rating data from Open Library.
|
||||
/// </summary>
|
||||
/// <param name="bookMetadataLookup">The lookup describing the book to resolve.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>The resolved book request, or <see langword="null"/> when no matching book was found.</returns>
|
||||
public async Task<AddBookRequest?> GetBookAsync(BookMetadataLookupDto bookMetadataLookup, CancellationToken cancellationToken = default)
|
||||
/// <returns>The resolved book metadata, or <see langword="null"/> when no matching book was found.</returns>
|
||||
public async Task<BookMetadataDto?> GetBookAsync(BookMetadataLookupDto bookMetadataLookup, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ValidateLookup(bookMetadataLookup);
|
||||
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
|
||||
/// <summary>
|
||||
/// Lightweight read model of an album, containing only the fields needed to display the album in a card-based grid or a list.
|
||||
/// </summary>
|
||||
public sealed record AlbumLiteRow
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the album.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the title of the album.
|
||||
/// </summary>
|
||||
public required string Title { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of tracks of the release.
|
||||
/// </summary>
|
||||
public int TotalTracks { get; init; }
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
|
||||
/// <summary>
|
||||
/// Lightweight read model of an artist, containing only the fields needed to display the artist in a card-based grid or a list.
|
||||
/// </summary>
|
||||
public sealed record ArtistLiteRow
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the artist.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the artist.
|
||||
/// </summary>
|
||||
public required string Name { get; init; }
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Lightweight read model of a track, containing only the fields needed to display the track in a list.
|
||||
/// </summary>
|
||||
public sealed record TrackLiteRow
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the track.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the title of the track.
|
||||
/// </summary>
|
||||
public required string Title { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of the track on its disc.
|
||||
/// </summary>
|
||||
public int TrackNumber { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of the disc the track belongs to, if applicable.
|
||||
/// </summary>
|
||||
public int? DiscNumber { get; init; }
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for the participation of a media contributor in an album, carrying the role the contributor played in that album.
|
||||
/// The role is tracked per participation, so that a single contributor can play multiple roles in the same album, or different roles in different albums.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("AlbumId: {AlbumId} MediaContributorId: {MediaContributorId}")]
|
||||
public class AlbumContributorEntity : IStorageEntity, IAuditableEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the participation.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Id of the album the contributor participated in.
|
||||
/// </summary>
|
||||
public required Guid AlbumId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Id of the media contributor.
|
||||
/// </summary>
|
||||
public required Guid MediaContributorId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the role the contributor played in the album.
|
||||
/// </summary>
|
||||
public required MediaContributorRole Role { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
public DateTime? UpdatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+207
@@ -0,0 +1,207 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for an album, a release of an artist.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public class AlbumEntity : IStorageEntity, IAuditableEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the album.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the artist the album belongs to.
|
||||
/// </summary>
|
||||
public required Guid ArtistId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the media library the artist of the album belongs to.
|
||||
/// </summary>
|
||||
public required Guid LibraryId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the title of the album.
|
||||
/// </summary>
|
||||
public required string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the original title of the album, if applicable.
|
||||
/// </summary>
|
||||
public string? OriginalTitle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the description of the album, if applicable.
|
||||
/// </summary>
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the original release date of the album, if applicable.
|
||||
/// </summary>
|
||||
public DateOnly? OriginalReleaseDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the original release year of the album, if applicable.
|
||||
/// </summary>
|
||||
public int? OriginalReleaseYear { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the re-release or reissue date of the album, if applicable.
|
||||
/// </summary>
|
||||
public DateOnly? ReReleaseDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the re-release or reissue year of the album, if applicable.
|
||||
/// </summary>
|
||||
public int? ReReleaseYear { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the country or region of release, if applicable.
|
||||
/// </summary>
|
||||
public ReleaseCountry? ReleaseCountry { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the release version or edition of the album, if applicable.
|
||||
/// </summary>
|
||||
public string? ReleaseVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ISO 639-1 two-letter language code of the album, if applicable.
|
||||
/// </summary>
|
||||
public string? LanguageCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the full name of the language of the album in English, if applicable.
|
||||
/// </summary>
|
||||
public string? LanguageName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the native name of the language of the album, if applicable.
|
||||
/// </summary>
|
||||
public string? LanguageNativeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ISO 639-1 two-letter original language code of the album, if applicable.
|
||||
/// </summary>
|
||||
public string? OriginalLanguageCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the full name of the original language of the album in English, if applicable.
|
||||
/// </summary>
|
||||
public string? OriginalLanguageName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the native name of the original language of the album, if applicable.
|
||||
/// </summary>
|
||||
public string? OriginalLanguageNativeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the release, if applicable.
|
||||
/// </summary>
|
||||
public MusicReleaseType? ReleaseType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the status of the release, if applicable.
|
||||
/// </summary>
|
||||
public MusicReleaseStatus? ReleaseStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of discs of the release, if applicable.
|
||||
/// </summary>
|
||||
public int? TotalDiscs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of tracks of the release.
|
||||
/// </summary>
|
||||
public int TotalTracks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the physical or digital medium of the album, if applicable.
|
||||
/// </summary>
|
||||
public MusicMediaFormat? MediaFormat { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the barcode of the album, if applicable.
|
||||
/// </summary>
|
||||
public string? Barcode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the catalog number of the album, if applicable.
|
||||
/// </summary>
|
||||
public string? CatalogNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the MusicBrainz identifier of the release, if applicable.
|
||||
/// </summary>
|
||||
public Guid? MusicBrainzReleaseId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the MusicBrainz identifier of the release group, if applicable.
|
||||
/// </summary>
|
||||
public Guid? MusicBrainzReleaseGroupId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the MusicBrainz identifier of the release artist, if applicable.
|
||||
/// </summary>
|
||||
public Guid? MusicBrainzReleaseArtistId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the artist the album belongs to.
|
||||
/// </summary>
|
||||
public ArtistEntity? Artist { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the tracks of the album.
|
||||
/// </summary>
|
||||
public List<TrackEntity> Tracks { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of ratings for this album.
|
||||
/// </summary>
|
||||
public List<AudioRatingEntity> Ratings { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of the media contributors of the album.
|
||||
/// </summary>
|
||||
public List<AlbumContributorEntity> Contributors { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the genres of the album.
|
||||
/// </summary>
|
||||
public HashSet<GenreEntity> Genres { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the tags of the album.
|
||||
/// </summary>
|
||||
public HashSet<TagEntity> Tags { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
public DateTime? UpdatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for the participation of a media contributor in an artist, carrying the role the contributor played in that artist.
|
||||
/// The role is tracked per participation, so that a single contributor can play multiple roles in the same artist, or different roles in different artists.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("ArtistId: {ArtistId} MediaContributorId: {MediaContributorId}")]
|
||||
public class ArtistContributorEntity : IStorageEntity, IAuditableEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the participation.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Id of the artist the contributor participated in.
|
||||
/// </summary>
|
||||
public required Guid ArtistId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Id of the media contributor.
|
||||
/// </summary>
|
||||
public required Guid MediaContributorId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the role the contributor played in the artist.
|
||||
/// </summary>
|
||||
public required MediaContributorRole Role { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
public DateTime? UpdatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for an artist.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("Name: {Name}")]
|
||||
public class ArtistEntity : IStorageEntity, IAuditableEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the artist.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the media library this artist belongs to.
|
||||
/// </summary>
|
||||
public required Guid LibraryId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the artist.
|
||||
/// </summary>
|
||||
public required string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the website of the artist, if applicable.
|
||||
/// </summary>
|
||||
public string? Website { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the MusicBrainz identifier of the artist, if applicable.
|
||||
/// </summary>
|
||||
public Guid? MusicBrainzArtistId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the albums of the artist.
|
||||
/// </summary>
|
||||
public List<AlbumEntity> Albums { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of the media contributors that make up the artist.
|
||||
/// </summary>
|
||||
public List<ArtistContributorEntity> Contributors { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
public DateTime? UpdatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for the rating of an audio media element.
|
||||
/// </summary>
|
||||
/// <param name="Value">The rating value of the audio media element.</param>
|
||||
/// <param name="MaxValue">The maximum possible rating value of the audio media element.</param>
|
||||
/// <param name="Source">The source of the audio rating (e.g., a specific website or platform).</param>
|
||||
/// <param name="VoteCount">The number of votes that contributed to the audio rating.</param>
|
||||
[DebuggerDisplay("{Value}/{MaxValue}")]
|
||||
public record AudioRatingEntity(
|
||||
decimal? Value,
|
||||
decimal? MaxValue,
|
||||
AudioRatingSource? Source,
|
||||
int? VoteCount
|
||||
) : RatingEntity(Value, MaxValue, VoteCount);
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for the participation of a media contributor in a track, carrying the role the contributor played in that track.
|
||||
/// The role is tracked per participation, so that a single contributor can play multiple roles in the same track, or different roles in different tracks.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("TrackId: {TrackId} MediaContributorId: {MediaContributorId}")]
|
||||
public class TrackContributorEntity : IStorageEntity, IAuditableEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the participation.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Id of the track the contributor participated in.
|
||||
/// </summary>
|
||||
public required Guid TrackId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Id of the media contributor.
|
||||
/// </summary>
|
||||
public required Guid MediaContributorId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the role the contributor played in the track.
|
||||
/// </summary>
|
||||
public required MediaContributorRole Role { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
public DateTime? UpdatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+242
@@ -0,0 +1,242 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for a track, the individual song of an album.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
public class TrackEntity : IStorageEntity, IAuditableEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the track.
|
||||
/// </summary>
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the album the track belongs to.
|
||||
/// </summary>
|
||||
public required Guid AlbumId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the media library this track belongs to.
|
||||
/// </summary>
|
||||
public required Guid LibraryId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the file system path of the track.
|
||||
/// </summary>
|
||||
public required string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the title of the track.
|
||||
/// </summary>
|
||||
public required string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the original title of the track, if applicable.
|
||||
/// </summary>
|
||||
public string? OriginalTitle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the description of the track, if applicable.
|
||||
/// </summary>
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the original release date of the track, if applicable.
|
||||
/// </summary>
|
||||
public DateOnly? OriginalReleaseDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the original release year of the track, if applicable.
|
||||
/// </summary>
|
||||
public int? OriginalReleaseYear { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the re-release or reissue date of the track, if applicable.
|
||||
/// </summary>
|
||||
public DateOnly? ReReleaseDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the re-release or reissue year of the track, if applicable.
|
||||
/// </summary>
|
||||
public int? ReReleaseYear { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the country or region of release, if applicable.
|
||||
/// </summary>
|
||||
public ReleaseCountry? ReleaseCountry { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the release version or edition of the track, if applicable.
|
||||
/// </summary>
|
||||
public string? ReleaseVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ISO 639-1 two-letter language code of the track, if applicable.
|
||||
/// </summary>
|
||||
public string? LanguageCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the full name of the language of the track in English, if applicable.
|
||||
/// </summary>
|
||||
public string? LanguageName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the native name of the language of the track, if applicable.
|
||||
/// </summary>
|
||||
public string? LanguageNativeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ISO 639-1 two-letter original language code of the track, if applicable.
|
||||
/// </summary>
|
||||
public string? OriginalLanguageCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the full name of the original language of the track in English, if applicable.
|
||||
/// </summary>
|
||||
public string? OriginalLanguageName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the native name of the original language of the track, if applicable.
|
||||
/// </summary>
|
||||
public string? OriginalLanguageNativeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the duration of the audio in seconds.
|
||||
/// </summary>
|
||||
public int DurationInSeconds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the sample rate of the audio in Hz.
|
||||
/// </summary>
|
||||
public int SampleRate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of audio channels.
|
||||
/// </summary>
|
||||
public int Channels { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the bit depth of the audio, if applicable.
|
||||
/// </summary>
|
||||
public int? BitDepth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the audio codec used, if applicable.
|
||||
/// </summary>
|
||||
public string? AudioCodec { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the bitrate of the audio in kbps, if applicable.
|
||||
/// </summary>
|
||||
public int? Bitrate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of the track on its disc.
|
||||
/// </summary>
|
||||
public int TrackNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of the disc the track belongs to, if applicable.
|
||||
/// </summary>
|
||||
public int? DiscNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the script used by the language of the track, if applicable.
|
||||
/// </summary>
|
||||
public string? Script { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the musical key of the track, if applicable.
|
||||
/// </summary>
|
||||
public MusicKey? Key { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the tempo of the track in beats per minute, if applicable.
|
||||
/// </summary>
|
||||
public int? Bpm { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the title of the work the track is a recording of, if applicable.
|
||||
/// </summary>
|
||||
public string? Work { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the MusicBrainz identifier of the recording, if applicable.
|
||||
/// </summary>
|
||||
public Guid? MusicBrainzRecordingId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the MusicBrainz identifier of the track, if applicable.
|
||||
/// </summary>
|
||||
public Guid? MusicBrainzTrackId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the MusicBrainz identifier of the work, if applicable.
|
||||
/// </summary>
|
||||
public Guid? MusicBrainzWorkId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the album the track belongs to.
|
||||
/// </summary>
|
||||
public AlbumEntity? Album { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of ratings for this track.
|
||||
/// </summary>
|
||||
public List<AudioRatingEntity> Ratings { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of the media contributors of the track.
|
||||
/// </summary>
|
||||
public List<TrackContributorEntity> Contributors { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of moods of the track.
|
||||
/// </summary>
|
||||
public List<TrackMoodEntity> Moods { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of ISRC (International Standard Recording Code) of the track.
|
||||
/// </summary>
|
||||
public List<TrackIsrcEntity> Isrcs { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the genres of the track.
|
||||
/// </summary>
|
||||
public HashSet<GenreEntity> Genres { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the tags of the track.
|
||||
/// </summary>
|
||||
public HashSet<TagEntity> Tags { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
public DateTime? UpdatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public required Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for an ISRC (International Standard Recording Code) of a track.
|
||||
/// </summary>
|
||||
/// <param name="Value">The value of the ISRC.</param>
|
||||
[DebuggerDisplay("Value: {Value}")]
|
||||
public record TrackIsrcEntity(
|
||||
string Value
|
||||
);
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for a mood of a track.
|
||||
/// </summary>
|
||||
/// <param name="Name">The name of the mood.</param>
|
||||
[DebuggerDisplay("Name: {Name}")]
|
||||
public record TrackMoodEntity(
|
||||
string Name
|
||||
);
|
||||
+2
-2
@@ -199,12 +199,12 @@ public class BookEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets the participations of the media contributors in the book, each carrying the role the contributor played.
|
||||
/// </summary>
|
||||
public List<BookContributorEntity> BookContributors { get; set; } = [];
|
||||
public List<BookContributorEntity> Contributors { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the pieces of artwork of the book, each tracked independently with its own enrichment state.
|
||||
/// </summary>
|
||||
public List<BookArtworkEntity> BookArtwork { get; set; } = [];
|
||||
public List<BookArtworkEntity> Artwork { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of ratings for this book.
|
||||
|
||||
+3
-10
@@ -10,7 +10,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Repositories.Books;
|
||||
namespace Lumina.Application.Common.DataAccess.Repositories.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the repository for books.
|
||||
@@ -20,7 +20,8 @@ public interface IBookRepository : IRepository<BookEntity>,
|
||||
IUpdateRepositoryAction<BookEntity>,
|
||||
IGetByIdRepositoryAction<BookEntity, Guid>,
|
||||
IGetAllRepositoryAction<BookEntity>,
|
||||
IGetAllLiteRepositoryAction<BookEntity, BookLiteRow>
|
||||
IGetAllLiteRepositoryAction<BookEntity, BookLiteRow>,
|
||||
IDeleteByIdRepositoryAction<Guid>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all the books of the media library identified by <paramref name="libraryId"/>.
|
||||
@@ -113,12 +114,4 @@ public interface IBookRepository : IRepository<BookEntity>,
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either the display names of the authors of the books, keyed by book Id, or an error.</returns>
|
||||
Task<Result<IReadOnlyDictionary<Guid, string?>>> GetAuthorsDisplayNamesByBookIdsAsync(IReadOnlyCollection<Guid> bookIds, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the book identified by <paramref name="bookId"/>.
|
||||
/// </summary>
|
||||
/// <param name="bookId">The Id of the book to delete.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
Task<Result<Deleted>> DeleteAsync(Guid bookId, CancellationToken cancellationToken);
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Repositories.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the repository for albums.
|
||||
/// </summary>
|
||||
public interface IAlbumRepository : IRepository<AlbumEntity>,
|
||||
IInsertRepositoryAction<AlbumEntity>,
|
||||
IUpdateRepositoryAction<AlbumEntity>,
|
||||
IGetByIdRepositoryAction<AlbumEntity, Guid>,
|
||||
IDeleteByIdRepositoryAction<Guid>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all the albums of the artist identified by <paramref name="artistId"/>.
|
||||
/// </summary>
|
||||
/// <param name="artistId">The Id of the artist whose albums are retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either a collection of <see cref="AlbumEntity"/>, or an error.</returns>
|
||||
Task<Result<IReadOnlyList<AlbumEntity>>> GetByArtistIdAsync(Guid artistId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the lightweight read models of the albums of the artist identified by <paramref name="artistId"/>, projecting only the fields needed to display the albums in a card-based grid or a list.
|
||||
/// </summary>
|
||||
/// <param name="artistId">The Id of the artist whose albums are retrieved.</param>
|
||||
/// <param name="paginationData">The pagination data that includes the current page and the number of items per page to retrieve. If <see langword="null"/>, all matching albums are returned.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either a paginated result of <see cref="AlbumLiteRow"/>, or an error.</returns>
|
||||
Task<Result<PaginatedResultDto<AlbumLiteRow>>> GetAlbumsLiteByArtistIdAsync(Guid artistId, PaginationDataDto? paginationData, CancellationToken cancellationToken);
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Repositories.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the repository for artists.
|
||||
/// </summary>
|
||||
public interface IArtistRepository : IRepository<ArtistEntity>,
|
||||
IInsertRepositoryAction<ArtistEntity>,
|
||||
IUpdateRepositoryAction<ArtistEntity>,
|
||||
IGetByIdRepositoryAction<ArtistEntity, Guid>,
|
||||
IGetAllRepositoryAction<ArtistEntity>,
|
||||
IGetAllLiteRepositoryAction<ArtistEntity, ArtistLiteRow>,
|
||||
IDeleteByIdRepositoryAction<Guid>
|
||||
{
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Repositories.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the repository for tracks.
|
||||
/// </summary>
|
||||
public interface ITrackRepository : IRepository<TrackEntity>,
|
||||
IInsertRepositoryAction<TrackEntity>,
|
||||
IUpdateRepositoryAction<TrackEntity>,
|
||||
IGetByIdRepositoryAction<TrackEntity, Guid>,
|
||||
IDeleteByIdRepositoryAction<Guid>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all the tracks of the album identified by <paramref name="albumId"/>.
|
||||
/// </summary>
|
||||
/// <param name="albumId">The Id of the album whose tracks are retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either a collection of <see cref="TrackEntity"/>, or an error.</returns>
|
||||
Task<Result<IReadOnlyList<TrackEntity>>> GetByAlbumIdAsync(Guid albumId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the lightweight read models of the tracks of the album identified by <paramref name="albumId"/>, projecting only the fields needed to display the tracks of an album.
|
||||
/// </summary>
|
||||
/// <param name="albumId">The Id of the album whose tracks are retrieved.</param>
|
||||
/// <param name="paginationData">The pagination data that includes the current page and the number of items per page to retrieve. If <see langword="null"/>, all matching tracks are returned.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either a paginated result of <see cref="TrackLiteRow"/>, or an error.</returns>
|
||||
Task<Result<PaginatedResultDto<TrackLiteRow>>> GetTracksLiteByAlbumIdAsync(Guid albumId, PaginationDataDto? paginationData, CancellationToken cancellationToken);
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.MediaContributors;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Common;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.AddAlbum;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="AddAlbumCommand"/>.
|
||||
/// </summary>
|
||||
public static class AddAlbumCommandMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="command"/> to a domain <see cref="Album"/>.
|
||||
/// </summary>
|
||||
/// <param name="command">The command whose data is used to create the album.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="Album"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<Album> ToDomainEntity(this AddAlbumCommand command)
|
||||
{
|
||||
Result<AlbumMetadata> metadataResult = command.Metadata!.ToDomainEntity();
|
||||
if (metadataResult.IsFailure)
|
||||
return metadataResult.Errors;
|
||||
|
||||
IEnumerable<Result<MusicMediaContributor>> domainContributorsResult = command.Contributors!.ToMusicDomainEntities();
|
||||
List<Error> errors = [.. domainContributorsResult.Where(contributorResult => contributorResult.IsFailure).SelectMany(contributorResult => contributorResult.Errors)];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
IEnumerable<Result<AudioRating>> domainRatingsResult = command.Ratings!.ToDomainEntities();
|
||||
errors = [.. domainRatingsResult.Where(ratingResult => ratingResult.IsFailure).SelectMany(ratingResult => ratingResult.Errors)];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
IEnumerable<Result<Track>> domainTracksResult = command.Tracks!.ToDomainEntities();
|
||||
errors = [.. domainTracksResult.Where(trackResult => trackResult.IsFailure).SelectMany(trackResult => trackResult.Errors)];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
Optional<Barcode> barcode = Optional<Barcode>.None();
|
||||
if (command.Barcode is not null)
|
||||
{
|
||||
Result<Barcode> barcodeResult = Barcode.Create(command.Barcode);
|
||||
if (barcodeResult.IsFailure)
|
||||
return barcodeResult.Errors;
|
||||
barcode = barcodeResult.Value;
|
||||
}
|
||||
|
||||
Optional<MusicBrainzId> musicBrainzReleaseId = Optional<MusicBrainzId>.None();
|
||||
if (command.MusicBrainzReleaseId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzReleaseIdResult = MusicBrainzId.Create(command.MusicBrainzReleaseId.Value);
|
||||
if (musicBrainzReleaseIdResult.IsFailure)
|
||||
return musicBrainzReleaseIdResult.Errors;
|
||||
musicBrainzReleaseId = musicBrainzReleaseIdResult.Value;
|
||||
}
|
||||
Optional<MusicBrainzId> musicBrainzReleaseGroupId = Optional<MusicBrainzId>.None();
|
||||
if (command.MusicBrainzReleaseGroupId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzReleaseGroupIdResult = MusicBrainzId.Create(command.MusicBrainzReleaseGroupId.Value);
|
||||
if (musicBrainzReleaseGroupIdResult.IsFailure)
|
||||
return musicBrainzReleaseGroupIdResult.Errors;
|
||||
musicBrainzReleaseGroupId = musicBrainzReleaseGroupIdResult.Value;
|
||||
}
|
||||
Optional<MusicBrainzId> musicBrainzReleaseArtistId = Optional<MusicBrainzId>.None();
|
||||
if (command.MusicBrainzReleaseArtistId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzReleaseArtistIdResult = MusicBrainzId.Create(command.MusicBrainzReleaseArtistId.Value);
|
||||
if (musicBrainzReleaseArtistIdResult.IsFailure)
|
||||
return musicBrainzReleaseArtistIdResult.Errors;
|
||||
musicBrainzReleaseArtistId = musicBrainzReleaseArtistIdResult.Value;
|
||||
}
|
||||
|
||||
return Album.Create(
|
||||
metadataResult.Value,
|
||||
Optional<MusicMediaFormat>.FromNullable(command.MediaFormat),
|
||||
barcode,
|
||||
Optional<string>.FromNullable(command.CatalogNumber),
|
||||
musicBrainzReleaseId,
|
||||
musicBrainzReleaseGroupId,
|
||||
musicBrainzReleaseArtistId,
|
||||
[.. domainContributorsResult.Select(contributorResult => contributorResult.Value)],
|
||||
[.. domainRatingsResult.Select(ratingResult => ratingResult.Value)],
|
||||
[.. domainTracksResult.Select(trackResult => trackResult.Value)]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="commands"/> to a collection of domain <see cref="Album"/>.
|
||||
/// </summary>
|
||||
/// <param name="commands">The commands whose data is used to create the albums.</param>
|
||||
/// <returns>A collection of <see cref="Result{TValue}"/> containing either the converted albums, or error messages.</returns>
|
||||
public static IEnumerable<Result<Album>> ToDomainEntities(this IEnumerable<AddAlbumCommand> commands)
|
||||
{
|
||||
return commands.Select(command => command.ToDomainEntity());
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.AddAlbum;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="AddAlbumRequest"/>.
|
||||
/// </summary>
|
||||
public static class AddAlbumRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="AddAlbumCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <param name="libraryId">The Id of the library the album belongs to, taken from the route.</param>
|
||||
/// <param name="artistId">The Id of the artist the album belongs to, taken from the route.</param>
|
||||
/// <returns>The converted command.</returns>
|
||||
public static AddAlbumCommand ToCommand(this AddAlbumRequest request, string? libraryId, string? artistId)
|
||||
{
|
||||
return new AddAlbumCommand(
|
||||
libraryId,
|
||||
artistId,
|
||||
request.Metadata,
|
||||
request.MediaFormat,
|
||||
request.Barcode,
|
||||
request.CatalogNumber,
|
||||
request.MusicBrainzReleaseId,
|
||||
request.MusicBrainzReleaseGroupId,
|
||||
request.MusicBrainzReleaseArtistId,
|
||||
request.Contributors,
|
||||
request.Ratings,
|
||||
request.Tracks?.ToCommands(libraryId, artistId, null).ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="requests"/> to a collection of <see cref="AddAlbumCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="requests">The requests to be converted.</param>
|
||||
/// <param name="libraryId">The Id of the library the albums belong to, taken from the route.</param>
|
||||
/// <param name="artistId">The Id of the artist the albums belong to, taken from the route.</param>
|
||||
/// <returns>The converted commands.</returns>
|
||||
public static IEnumerable<AddAlbumCommand> ToCommands(this IEnumerable<AddAlbumRequest> requests, string? libraryId, string? artistId)
|
||||
{
|
||||
return requests.Select(request => request.ToCommand(libraryId, artistId));
|
||||
}
|
||||
}
|
||||
+240
@@ -0,0 +1,240 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIdentifiers.MediaContributorBoundedContext.MediaContributorAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Common;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="AlbumEntity"/>.
|
||||
/// </summary>
|
||||
public static class AlbumEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="Album"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully converted <see cref="Album"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<Album> ToDomainEntity(this AlbumEntity repositoryEntity)
|
||||
{
|
||||
Result<ReleaseInfo> releaseInfoResult = ReleaseInfo.Create(
|
||||
Optional<DateOnly>.FromNullable(repositoryEntity.OriginalReleaseDate),
|
||||
Optional<int>.FromNullable(repositoryEntity.OriginalReleaseYear),
|
||||
Optional<DateOnly>.FromNullable(repositoryEntity.ReReleaseDate),
|
||||
Optional<int>.FromNullable(repositoryEntity.ReReleaseYear),
|
||||
Optional<ReleaseCountry>.FromNullable(repositoryEntity.ReleaseCountry),
|
||||
Optional<string>.FromNullable(repositoryEntity.ReleaseVersion));
|
||||
if (releaseInfoResult.IsFailure)
|
||||
return releaseInfoResult.Errors;
|
||||
|
||||
List<Genre> domainGenres = [];
|
||||
foreach (Result<Genre> genreResult in repositoryEntity.Genres.ToDomainEntities())
|
||||
{
|
||||
if (genreResult.IsFailure)
|
||||
return genreResult.Errors;
|
||||
domainGenres.Add(genreResult.Value);
|
||||
}
|
||||
|
||||
List<Tag> domainTags = [];
|
||||
foreach (Result<Tag> tagResult in repositoryEntity.Tags.ToDomainEntities())
|
||||
{
|
||||
if (tagResult.IsFailure)
|
||||
return tagResult.Errors;
|
||||
domainTags.Add(tagResult.Value);
|
||||
}
|
||||
|
||||
Optional<LanguageInfo> language = Optional<LanguageInfo>.None();
|
||||
if (repositoryEntity.LanguageCode is not null && repositoryEntity.LanguageName is not null)
|
||||
language = LanguageInfo.Create(repositoryEntity.LanguageCode, repositoryEntity.LanguageName, Optional<string>.FromNullable(repositoryEntity.LanguageNativeName));
|
||||
|
||||
Optional<LanguageInfo> originalLanguage = Optional<LanguageInfo>.None();
|
||||
if (repositoryEntity.OriginalLanguageCode is not null && repositoryEntity.OriginalLanguageName is not null)
|
||||
originalLanguage = LanguageInfo.Create(repositoryEntity.OriginalLanguageCode, repositoryEntity.OriginalLanguageName, Optional<string>.FromNullable(repositoryEntity.OriginalLanguageNativeName));
|
||||
|
||||
Result<AlbumMetadata> metadataResult = AlbumMetadata.Create(
|
||||
repositoryEntity.Title,
|
||||
Optional<string>.FromNullable(repositoryEntity.OriginalTitle),
|
||||
Optional<string>.FromNullable(repositoryEntity.Description),
|
||||
releaseInfoResult.Value,
|
||||
domainGenres,
|
||||
domainTags,
|
||||
language,
|
||||
originalLanguage,
|
||||
Optional<MusicReleaseType>.FromNullable(repositoryEntity.ReleaseType),
|
||||
Optional<MusicReleaseStatus>.FromNullable(repositoryEntity.ReleaseStatus),
|
||||
Optional<int>.FromNullable(repositoryEntity.TotalDiscs),
|
||||
repositoryEntity.TotalTracks);
|
||||
if (metadataResult.IsFailure)
|
||||
return metadataResult.Errors;
|
||||
|
||||
Optional<Barcode> barcode = Optional<Barcode>.None();
|
||||
if (repositoryEntity.Barcode is not null)
|
||||
{
|
||||
Result<Barcode> barcodeResult = Barcode.Create(repositoryEntity.Barcode);
|
||||
if (barcodeResult.IsFailure)
|
||||
return barcodeResult.Errors;
|
||||
barcode = barcodeResult.Value;
|
||||
}
|
||||
|
||||
Optional<MusicBrainzId> musicBrainzReleaseId = Optional<MusicBrainzId>.None();
|
||||
if (repositoryEntity.MusicBrainzReleaseId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzReleaseIdResult = MusicBrainzId.Create(repositoryEntity.MusicBrainzReleaseId.Value);
|
||||
if (musicBrainzReleaseIdResult.IsFailure)
|
||||
return musicBrainzReleaseIdResult.Errors;
|
||||
musicBrainzReleaseId = musicBrainzReleaseIdResult.Value;
|
||||
}
|
||||
Optional<MusicBrainzId> musicBrainzReleaseGroupId = Optional<MusicBrainzId>.None();
|
||||
if (repositoryEntity.MusicBrainzReleaseGroupId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzReleaseGroupIdResult = MusicBrainzId.Create(repositoryEntity.MusicBrainzReleaseGroupId.Value);
|
||||
if (musicBrainzReleaseGroupIdResult.IsFailure)
|
||||
return musicBrainzReleaseGroupIdResult.Errors;
|
||||
musicBrainzReleaseGroupId = musicBrainzReleaseGroupIdResult.Value;
|
||||
}
|
||||
Optional<MusicBrainzId> musicBrainzReleaseArtistId = Optional<MusicBrainzId>.None();
|
||||
if (repositoryEntity.MusicBrainzReleaseArtistId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzReleaseArtistIdResult = MusicBrainzId.Create(repositoryEntity.MusicBrainzReleaseArtistId.Value);
|
||||
if (musicBrainzReleaseArtistIdResult.IsFailure)
|
||||
return musicBrainzReleaseArtistIdResult.Errors;
|
||||
musicBrainzReleaseArtistId = musicBrainzReleaseArtistIdResult.Value;
|
||||
}
|
||||
|
||||
List<AudioRating> domainRatings = [];
|
||||
foreach (Result<AudioRating> ratingResult in repositoryEntity.Ratings.ToDomainEntities())
|
||||
{
|
||||
if (ratingResult.IsFailure)
|
||||
return ratingResult.Errors;
|
||||
domainRatings.Add(ratingResult.Value);
|
||||
}
|
||||
|
||||
List<MusicMediaContributor> domainContributors = [];
|
||||
foreach (AlbumContributorEntity contributorEntity in repositoryEntity.Contributors)
|
||||
{
|
||||
Result<MusicMediaContributor> contributorResult = MusicMediaContributor.Create(MediaContributorId.Create(contributorEntity.MediaContributorId), contributorEntity.Role);
|
||||
if (contributorResult.IsFailure)
|
||||
return contributorResult.Errors;
|
||||
domainContributors.Add(contributorResult.Value);
|
||||
}
|
||||
|
||||
List<Track> domainTracks = [];
|
||||
foreach (TrackEntity trackEntity in repositoryEntity.Tracks)
|
||||
{
|
||||
Result<Track> trackResult = trackEntity.ToDomainEntity();
|
||||
if (trackResult.IsFailure)
|
||||
return trackResult.Errors;
|
||||
domainTracks.Add(trackResult.Value);
|
||||
}
|
||||
|
||||
return Album.Create(
|
||||
AlbumId.Create(repositoryEntity.Id),
|
||||
metadataResult.Value,
|
||||
Optional<MusicMediaFormat>.FromNullable(repositoryEntity.MediaFormat),
|
||||
barcode,
|
||||
Optional<string>.FromNullable(repositoryEntity.CatalogNumber),
|
||||
musicBrainzReleaseId,
|
||||
musicBrainzReleaseGroupId,
|
||||
musicBrainzReleaseArtistId,
|
||||
domainContributors,
|
||||
domainRatings,
|
||||
domainTracks,
|
||||
repositoryEntity.CreatedOnUtc,
|
||||
Optional<DateTime>.FromNullable(repositoryEntity.UpdatedOnUtc));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="AlbumResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted response entity.</returns>
|
||||
public static AlbumResponse ToResponse(this AlbumEntity repositoryEntity)
|
||||
{
|
||||
ReleaseInfoDto releaseInfo = new(
|
||||
repositoryEntity.OriginalReleaseDate,
|
||||
repositoryEntity.OriginalReleaseYear,
|
||||
repositoryEntity.ReReleaseDate,
|
||||
repositoryEntity.ReReleaseYear,
|
||||
repositoryEntity.ReleaseCountry,
|
||||
repositoryEntity.ReleaseVersion
|
||||
);
|
||||
// language and original language make sense only if their subproperties have values
|
||||
LanguageInfoDto? languageInfo = !string.IsNullOrWhiteSpace(repositoryEntity.LanguageCode) ||
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.LanguageName) ||
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.LanguageNativeName)
|
||||
? new LanguageInfoDto(
|
||||
repositoryEntity.LanguageCode,
|
||||
repositoryEntity.LanguageName,
|
||||
repositoryEntity.LanguageNativeName
|
||||
) : null;
|
||||
LanguageInfoDto? originalLanguageInfo = !string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageCode) ||
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageName) ||
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageNativeName)
|
||||
? new LanguageInfoDto(
|
||||
repositoryEntity.OriginalLanguageCode,
|
||||
repositoryEntity.OriginalLanguageName,
|
||||
repositoryEntity.OriginalLanguageNativeName
|
||||
) : null;
|
||||
AlbumMetadataDto metadata = new(
|
||||
repositoryEntity.Title,
|
||||
repositoryEntity.OriginalTitle,
|
||||
repositoryEntity.Description,
|
||||
releaseInfo,
|
||||
languageInfo,
|
||||
originalLanguageInfo,
|
||||
[.. repositoryEntity.Tags.ToResponses()],
|
||||
[.. repositoryEntity.Genres.ToResponses()],
|
||||
repositoryEntity.ReleaseType,
|
||||
repositoryEntity.ReleaseStatus,
|
||||
repositoryEntity.TotalDiscs,
|
||||
repositoryEntity.TotalTracks
|
||||
);
|
||||
return new AlbumResponse(
|
||||
repositoryEntity.Id,
|
||||
repositoryEntity.ArtistId,
|
||||
repositoryEntity.LibraryId,
|
||||
metadata,
|
||||
repositoryEntity.MediaFormat,
|
||||
repositoryEntity.Barcode,
|
||||
repositoryEntity.CatalogNumber,
|
||||
repositoryEntity.MusicBrainzReleaseId,
|
||||
repositoryEntity.MusicBrainzReleaseGroupId,
|
||||
repositoryEntity.MusicBrainzReleaseArtistId,
|
||||
repositoryEntity.CreatedOnUtc,
|
||||
repositoryEntity.UpdatedOnUtc,
|
||||
[.. repositoryEntity.Contributors.Select(contributor => new MediaContributorReferenceDto(contributor.MediaContributorId, contributor.Role))],
|
||||
[.. repositoryEntity.Ratings.ToResponses()],
|
||||
[.. repositoryEntity.Tracks.Select(track => track.ToResponse())]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="AlbumResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>The converted responses.</returns>
|
||||
public static IReadOnlyList<AlbumResponse> ToResponses(this IEnumerable<AlbumEntity> repositoryEntities)
|
||||
{
|
||||
return [.. repositoryEntities.Select(repositoryEntity => repositoryEntity.ToResponse())];
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Contracts.Responses.Common;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="AlbumLiteRow"/>.
|
||||
/// </summary>
|
||||
public static class AlbumLiteRowMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="readModel"/> to <see cref="AlbumLiteResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="readModel">The read model to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static AlbumLiteResponse ToResponse(this AlbumLiteRow readModel)
|
||||
{
|
||||
return new AlbumLiteResponse(
|
||||
readModel.Id,
|
||||
readModel.Title,
|
||||
readModel.TotalTracks);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="readModels"/> to a collection of <see cref="AlbumLiteResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="readModels">The read models to be converted.</param>
|
||||
/// <returns>The converted responses.</returns>
|
||||
public static IReadOnlyList<AlbumLiteResponse> ToResponses(this IEnumerable<AlbumLiteRow> readModels)
|
||||
{
|
||||
return [.. readModels.Select(readModel => readModel.ToResponse())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="readModels"/> to a paginated collection of <see cref="AlbumLiteResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="readModels">The paginated read models to be converted.</param>
|
||||
/// <returns>The converted paginated responses.</returns>
|
||||
public static PaginatedResponse<AlbumLiteResponse> ToResponses(this PaginatedResultDto<AlbumLiteRow> readModels)
|
||||
{
|
||||
return new PaginatedResponse<AlbumLiteResponse>
|
||||
{
|
||||
Data = readModels.Data.ToResponses(),
|
||||
CurrentPage = readModels.CurrentPage,
|
||||
PerPage = readModels.PerPage,
|
||||
Count = readModels.Count,
|
||||
NumberOfPages = readModels.NumberOfPages
|
||||
};
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Common;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="Album"/>.
|
||||
/// </summary>
|
||||
public static class AlbumMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="AlbumEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <param name="artistId">The Id of the artist the album belongs to.</param>
|
||||
/// <param name="libraryId">The Id of the media library the album belongs to.</param>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static AlbumEntity ToRepositoryEntity(this Album domainEntity, Guid artistId, Guid libraryId)
|
||||
{
|
||||
return new AlbumEntity
|
||||
{
|
||||
Id = domainEntity.Id.Value,
|
||||
ArtistId = artistId,
|
||||
LibraryId = libraryId,
|
||||
Title = domainEntity.Metadata.Title,
|
||||
OriginalTitle = domainEntity.Metadata.OriginalTitle.HasValue ? domainEntity.Metadata.OriginalTitle.Value : null,
|
||||
Description = domainEntity.Metadata.Description.HasValue ? domainEntity.Metadata.Description.Value : null,
|
||||
OriginalReleaseDate = domainEntity.Metadata.ReleaseInfo.OriginalReleaseDate.HasValue ? domainEntity.Metadata.ReleaseInfo.OriginalReleaseDate.Value : null,
|
||||
OriginalReleaseYear = domainEntity.Metadata.ReleaseInfo.OriginalReleaseYear.HasValue ? domainEntity.Metadata.ReleaseInfo.OriginalReleaseYear.Value : null,
|
||||
ReReleaseDate = domainEntity.Metadata.ReleaseInfo.ReReleaseDate.HasValue ? domainEntity.Metadata.ReleaseInfo.ReReleaseDate.Value : null,
|
||||
ReReleaseYear = domainEntity.Metadata.ReleaseInfo.ReReleaseYear.HasValue ? domainEntity.Metadata.ReleaseInfo.ReReleaseYear.Value : null,
|
||||
ReleaseCountry = domainEntity.Metadata.ReleaseInfo.ReleaseCountry.HasValue ? domainEntity.Metadata.ReleaseInfo.ReleaseCountry.Value : null,
|
||||
ReleaseVersion = domainEntity.Metadata.ReleaseInfo.ReleaseVersion.HasValue ? domainEntity.Metadata.ReleaseInfo.ReleaseVersion.Value : null,
|
||||
LanguageCode = domainEntity.Metadata.Language.HasValue ? domainEntity.Metadata.Language.Value.LanguageCode : null,
|
||||
LanguageName = domainEntity.Metadata.Language.HasValue ? domainEntity.Metadata.Language.Value.LanguageName : null,
|
||||
LanguageNativeName = domainEntity.Metadata.Language.HasValue && domainEntity.Metadata.Language.Value.NativeName.HasValue ? domainEntity.Metadata.Language.Value.NativeName.Value : null,
|
||||
OriginalLanguageCode = domainEntity.Metadata.OriginalLanguage.HasValue ? domainEntity.Metadata.OriginalLanguage.Value.LanguageCode : null,
|
||||
OriginalLanguageName = domainEntity.Metadata.OriginalLanguage.HasValue ? domainEntity.Metadata.OriginalLanguage.Value.LanguageName : null,
|
||||
OriginalLanguageNativeName = domainEntity.Metadata.OriginalLanguage.HasValue && domainEntity.Metadata.OriginalLanguage.Value.NativeName.HasValue ? domainEntity.Metadata.OriginalLanguage.Value.NativeName.Value : null,
|
||||
Genres = [.. domainEntity.Metadata.Genres.ToRepositoryEntities()],
|
||||
Tags = [.. domainEntity.Metadata.Tags.ToRepositoryEntities()],
|
||||
ReleaseType = domainEntity.Metadata.ReleaseType.HasValue ? domainEntity.Metadata.ReleaseType.Value : null,
|
||||
ReleaseStatus = domainEntity.Metadata.ReleaseStatus.HasValue ? domainEntity.Metadata.ReleaseStatus.Value : null,
|
||||
TotalDiscs = domainEntity.Metadata.TotalDiscs.HasValue ? domainEntity.Metadata.TotalDiscs.Value : null,
|
||||
TotalTracks = domainEntity.Metadata.TotalTracks,
|
||||
MediaFormat = domainEntity.MediaFormat.HasValue ? domainEntity.MediaFormat.Value : null,
|
||||
Barcode = domainEntity.Barcode.HasValue ? domainEntity.Barcode.Value.Value : null,
|
||||
CatalogNumber = domainEntity.CatalogNumber.HasValue ? domainEntity.CatalogNumber.Value : null,
|
||||
MusicBrainzReleaseId = domainEntity.MusicBrainzReleaseId.HasValue ? domainEntity.MusicBrainzReleaseId.Value.Value : null,
|
||||
MusicBrainzReleaseGroupId = domainEntity.MusicBrainzReleaseGroupId.HasValue ? domainEntity.MusicBrainzReleaseGroupId.Value.Value : null,
|
||||
MusicBrainzReleaseArtistId = domainEntity.MusicBrainzReleaseArtistId.HasValue ? domainEntity.MusicBrainzReleaseArtistId.Value.Value : null,
|
||||
Contributors = [.. domainEntity.Contributors.Select(contributor => new AlbumContributorEntity
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
AlbumId = domainEntity.Id.Value,
|
||||
MediaContributorId = contributor.ContributorId.Value,
|
||||
Role = contributor.Role,
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
UpdatedBy = null
|
||||
})],
|
||||
Ratings = [.. domainEntity.Ratings.ToRepositoryEntities()],
|
||||
Tracks = [.. domainEntity.Tracks.Select(track => track.ToRepositoryEntity(domainEntity.Id.Value, libraryId))],
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
UpdatedOnUtc = domainEntity.UpdatedOnUtc.HasValue ? domainEntity.UpdatedOnUtc : null,
|
||||
UpdatedBy = domainEntity.UpdatedOnUtc.HasValue ? Guid.NewGuid() : null
|
||||
};
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="AlbumMetadataDto"/>.
|
||||
/// </summary>
|
||||
public static class AlbumMetadataDtoMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="dto"/> to a domain <see cref="AlbumMetadata"/>.
|
||||
/// </summary>
|
||||
/// <param name="dto">The data transfer object to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully converted <see cref="AlbumMetadata"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<AlbumMetadata> ToDomainEntity(this AlbumMetadataDto dto)
|
||||
{
|
||||
ReleaseInfoDto? releaseInfoDto = dto.ReleaseInfo;
|
||||
Result<ReleaseInfo> releaseInfoResult = ReleaseInfo.Create(
|
||||
Optional<DateOnly>.FromNullable(releaseInfoDto?.OriginalReleaseDate),
|
||||
Optional<int>.FromNullable(releaseInfoDto?.OriginalReleaseYear),
|
||||
Optional<DateOnly>.FromNullable(releaseInfoDto?.ReReleaseDate),
|
||||
Optional<int>.FromNullable(releaseInfoDto?.ReReleaseYear),
|
||||
Optional<ReleaseCountry>.FromNullable(releaseInfoDto?.ReleaseCountry),
|
||||
Optional<string>.FromNullable(releaseInfoDto?.ReleaseVersion));
|
||||
if (releaseInfoResult.IsFailure)
|
||||
return releaseInfoResult.Errors;
|
||||
|
||||
List<Genre> domainGenres = [];
|
||||
foreach (GenreDto genre in dto.Genres ?? [])
|
||||
{
|
||||
Result<Genre> genreResult = genre.ToDomainEntity();
|
||||
if (genreResult.IsFailure)
|
||||
return genreResult.Errors;
|
||||
domainGenres.Add(genreResult.Value);
|
||||
}
|
||||
|
||||
List<Tag> domainTags = [];
|
||||
foreach (TagDto tag in dto.Tags ?? [])
|
||||
{
|
||||
Result<Tag> tagResult = tag.ToDomainEntity();
|
||||
if (tagResult.IsFailure)
|
||||
return tagResult.Errors;
|
||||
domainTags.Add(tagResult.Value);
|
||||
}
|
||||
|
||||
Optional<LanguageInfo> language = Optional<LanguageInfo>.None();
|
||||
if (dto.Language is not null && dto.Language.LanguageCode is not null && dto.Language.LanguageName is not null)
|
||||
language = LanguageInfo.Create(dto.Language.LanguageCode, dto.Language.LanguageName, Optional<string>.FromNullable(dto.Language.NativeName));
|
||||
|
||||
Optional<LanguageInfo> originalLanguage = Optional<LanguageInfo>.None();
|
||||
if (dto.OriginalLanguage is not null && dto.OriginalLanguage.LanguageCode is not null && dto.OriginalLanguage.LanguageName is not null)
|
||||
originalLanguage = LanguageInfo.Create(dto.OriginalLanguage.LanguageCode, dto.OriginalLanguage.LanguageName, Optional<string>.FromNullable(dto.OriginalLanguage.NativeName));
|
||||
|
||||
return AlbumMetadata.Create(
|
||||
dto.Title!,
|
||||
Optional<string>.FromNullable(dto.OriginalTitle),
|
||||
Optional<string>.FromNullable(dto.Description),
|
||||
releaseInfoResult.Value,
|
||||
domainGenres,
|
||||
domainTags,
|
||||
language,
|
||||
originalLanguage,
|
||||
Optional<MusicReleaseType>.FromNullable(dto.ReleaseType),
|
||||
Optional<MusicReleaseStatus>.FromNullable(dto.ReleaseStatus),
|
||||
Optional<int>.FromNullable(dto.TotalDiscs),
|
||||
dto.TotalTracks ?? 0);
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.DeleteAlbum;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="DeleteAlbumRequest"/>.
|
||||
/// </summary>
|
||||
public static class DeleteAlbumRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="DeleteAlbumCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted command.</returns>
|
||||
public static DeleteAlbumCommand ToCommand(this DeleteAlbumRequest request)
|
||||
{
|
||||
return new DeleteAlbumCommand(
|
||||
request.AlbumId);
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Queries.GetAlbum;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetAlbumRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetAlbumRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetAlbumQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetAlbumQuery ToQuery(this GetAlbumRequest request)
|
||||
{
|
||||
return new GetAlbumQuery(
|
||||
request.AlbumId);
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Queries.GetAlbumTracksLite;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetAlbumTracksLiteRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetAlbumTracksLiteRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetAlbumTracksLiteQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetAlbumTracksLiteQuery ToQuery(this GetAlbumTracksLiteRequest request)
|
||||
{
|
||||
return new GetAlbumTracksLiteQuery(
|
||||
request.AlbumId,
|
||||
request.CurrentPage,
|
||||
request.PerPage);
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Queries.GetAlbumTracks;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetAlbumTracksRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetAlbumTracksRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetAlbumTracksQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetAlbumTracksQuery ToQuery(this GetAlbumTracksRequest request)
|
||||
{
|
||||
return new GetAlbumTracksQuery(
|
||||
request.AlbumId);
|
||||
}
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Application.Common.Mapping.MediaContributors;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Common;
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.UpdateAlbum;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="UpdateAlbumCommand"/>.
|
||||
/// </summary>
|
||||
public static class UpdateAlbumCommandMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="command"/> to a domain <see cref="Album"/>, preserving the identity and creation metadata of the stored album identified by <paramref name="existingAlbum"/>.
|
||||
/// </summary>
|
||||
/// <param name="command">The command whose data is used to create the album.</param>
|
||||
/// <param name="existingAlbum">The stored album whose identity and creation metadata are preserved.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="Album"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<Album> ToDomainEntity(this UpdateAlbumCommand command, AlbumEntity existingAlbum)
|
||||
{
|
||||
Result<AlbumMetadata> metadataResult = command.Metadata!.ToDomainEntity();
|
||||
if (metadataResult.IsFailure)
|
||||
return metadataResult.Errors;
|
||||
|
||||
IEnumerable<Result<MusicMediaContributor>> domainContributorsResult = (command.Contributors ?? []).ToMusicDomainEntities();
|
||||
List<Error> errors = [.. domainContributorsResult.Where(contributorResult => contributorResult.IsFailure).SelectMany(contributorResult => contributorResult.Errors)];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
IEnumerable<Result<AudioRating>> domainRatingsResult = (command.Ratings ?? []).ToDomainEntities();
|
||||
errors = [.. domainRatingsResult.Where(ratingResult => ratingResult.IsFailure).SelectMany(ratingResult => ratingResult.Errors)];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
Optional<Barcode> barcode = Optional<Barcode>.None();
|
||||
if (command.Barcode is not null)
|
||||
{
|
||||
Result<Barcode> barcodeResult = Barcode.Create(command.Barcode);
|
||||
if (barcodeResult.IsFailure)
|
||||
return barcodeResult.Errors;
|
||||
barcode = barcodeResult.Value;
|
||||
}
|
||||
|
||||
Optional<MusicBrainzId> musicBrainzReleaseId = Optional<MusicBrainzId>.None();
|
||||
if (command.MusicBrainzReleaseId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzReleaseIdResult = MusicBrainzId.Create(command.MusicBrainzReleaseId.Value);
|
||||
if (musicBrainzReleaseIdResult.IsFailure)
|
||||
return musicBrainzReleaseIdResult.Errors;
|
||||
musicBrainzReleaseId = musicBrainzReleaseIdResult.Value;
|
||||
}
|
||||
Optional<MusicBrainzId> musicBrainzReleaseGroupId = Optional<MusicBrainzId>.None();
|
||||
if (command.MusicBrainzReleaseGroupId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzReleaseGroupIdResult = MusicBrainzId.Create(command.MusicBrainzReleaseGroupId.Value);
|
||||
if (musicBrainzReleaseGroupIdResult.IsFailure)
|
||||
return musicBrainzReleaseGroupIdResult.Errors;
|
||||
musicBrainzReleaseGroupId = musicBrainzReleaseGroupIdResult.Value;
|
||||
}
|
||||
Optional<MusicBrainzId> musicBrainzReleaseArtistId = Optional<MusicBrainzId>.None();
|
||||
if (command.MusicBrainzReleaseArtistId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzReleaseArtistIdResult = MusicBrainzId.Create(command.MusicBrainzReleaseArtistId.Value);
|
||||
if (musicBrainzReleaseArtistIdResult.IsFailure)
|
||||
return musicBrainzReleaseArtistIdResult.Errors;
|
||||
musicBrainzReleaseArtistId = musicBrainzReleaseArtistIdResult.Value;
|
||||
}
|
||||
|
||||
return Album.Create(
|
||||
AlbumId.Create(existingAlbum.Id),
|
||||
metadataResult.Value,
|
||||
Optional<MusicMediaFormat>.FromNullable(command.MediaFormat),
|
||||
barcode,
|
||||
Optional<string>.FromNullable(command.CatalogNumber),
|
||||
musicBrainzReleaseId,
|
||||
musicBrainzReleaseGroupId,
|
||||
musicBrainzReleaseArtistId,
|
||||
[.. domainContributorsResult.Select(contributorResult => contributorResult.Value)],
|
||||
[.. domainRatingsResult.Select(ratingResult => ratingResult.Value)],
|
||||
[],
|
||||
existingAlbum.CreatedOnUtc,
|
||||
Optional<DateTime>.FromNullable(existingAlbum.UpdatedOnUtc));
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.UpdateAlbum;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="UpdateAlbumRequest"/>.
|
||||
/// </summary>
|
||||
public static class UpdateAlbumRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="UpdateAlbumCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <param name="libraryId">The Id of the library the album belongs to, taken from the route.</param>
|
||||
/// <param name="artistId">The Id of the artist the album belongs to, taken from the route.</param>
|
||||
/// <param name="albumId">The Id of the album to update, taken from the route.</param>
|
||||
/// <returns>The converted command.</returns>
|
||||
public static UpdateAlbumCommand ToCommand(this UpdateAlbumRequest request, string? libraryId, string? artistId, string? albumId)
|
||||
{
|
||||
return new UpdateAlbumCommand(
|
||||
libraryId,
|
||||
artistId,
|
||||
albumId,
|
||||
request.Metadata,
|
||||
request.MediaFormat,
|
||||
request.Barcode,
|
||||
request.CatalogNumber,
|
||||
request.MusicBrainzReleaseId,
|
||||
request.MusicBrainzReleaseGroupId,
|
||||
request.MusicBrainzReleaseArtistId,
|
||||
request.Contributors,
|
||||
request.Ratings);
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.MediaContributors;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Commands.AddArtist;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="AddArtistCommand"/>.
|
||||
/// </summary>
|
||||
public static class AddArtistCommandMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="command"/> to <see cref="Artist"/>.
|
||||
/// </summary>
|
||||
/// <param name="command">The command to be converted.</param>
|
||||
/// <param name="libraryId">The Id of the media library the artist is added to.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully converted <see cref="Artist"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<Artist> ToDomainEntity(this AddArtistCommand command, Guid libraryId)
|
||||
{
|
||||
// Map the media contributors referenced by the user to their domain counterparts; a contributor is identified by its id and carries the role it played.
|
||||
IEnumerable<Result<MusicMediaContributor>> domainContributorsResult = command.Contributors!.ToMusicDomainEntities();
|
||||
List<Error> errors = [.. domainContributorsResult.Where(contributorResult => contributorResult.IsFailure).SelectMany(contributorResult => contributorResult.Errors)];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
// Build each album of the artist, together with its metadata, contributors, ratings and tracks.
|
||||
IEnumerable<Result<Album>> domainAlbumsResult = command.Albums!.ToDomainEntities();
|
||||
errors = [.. domainAlbumsResult.Where(albumResult => albumResult.IsFailure).SelectMany(albumResult => albumResult.Errors)];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
Optional<string> website = Optional<string>.FromNullable(command.Website);
|
||||
Optional<MusicBrainzId> musicBrainzArtistId = Optional<MusicBrainzId>.None();
|
||||
if (command.MusicBrainzArtistId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzArtistIdResult = MusicBrainzId.Create(command.MusicBrainzArtistId.Value);
|
||||
if (musicBrainzArtistIdResult.IsFailure)
|
||||
return musicBrainzArtistIdResult.Errors;
|
||||
musicBrainzArtistId = musicBrainzArtistIdResult.Value;
|
||||
}
|
||||
|
||||
return Artist.Create(
|
||||
LibraryId.Create(libraryId),
|
||||
command.Name!,
|
||||
website,
|
||||
musicBrainzArtistId,
|
||||
[.. domainContributorsResult.Select(contributorResult => contributorResult.Value)],
|
||||
[.. domainAlbumsResult.Select(albumResult => albumResult.Value)]);
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Commands.AddArtist;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="AddArtistRequest"/>.
|
||||
/// </summary>
|
||||
public static class AddArtistRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="AddArtistCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <param name="libraryId">The Id of the library the artist is added to, taken from the route.</param>
|
||||
/// <returns>The converted command.</returns>
|
||||
public static AddArtistCommand ToCommand(this AddArtistRequest request, string? libraryId)
|
||||
{
|
||||
return new AddArtistCommand(
|
||||
libraryId,
|
||||
request.Name,
|
||||
request.Website,
|
||||
request.MusicBrainzArtistId,
|
||||
request.Contributors,
|
||||
request.Albums?.ToCommands(libraryId, null).ToList());
|
||||
}
|
||||
}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
using Lumina.Contracts.Responses.Common;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIdentifiers.MediaContributorBoundedContext.MediaContributorAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="ArtistEntity"/>.
|
||||
/// </summary>
|
||||
public static class ArtistEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="Artist"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully converted <see cref="Artist"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<Artist> ToDomainEntity(this ArtistEntity repositoryEntity)
|
||||
{
|
||||
Optional<MusicBrainzId> musicBrainzArtistId = Optional<MusicBrainzId>.None();
|
||||
if (repositoryEntity.MusicBrainzArtistId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzArtistIdResult = MusicBrainzId.Create(repositoryEntity.MusicBrainzArtistId.Value);
|
||||
if (musicBrainzArtistIdResult.IsFailure)
|
||||
return musicBrainzArtistIdResult.Errors;
|
||||
musicBrainzArtistId = musicBrainzArtistIdResult.Value;
|
||||
}
|
||||
|
||||
List<MusicMediaContributor> domainContributors = [];
|
||||
foreach (ArtistContributorEntity contributorEntity in repositoryEntity.Contributors)
|
||||
{
|
||||
Result<MusicMediaContributor> contributorResult = MusicMediaContributor.Create(MediaContributorId.Create(contributorEntity.MediaContributorId), contributorEntity.Role);
|
||||
if (contributorResult.IsFailure)
|
||||
return contributorResult.Errors;
|
||||
domainContributors.Add(contributorResult.Value);
|
||||
}
|
||||
|
||||
List<Album> domainAlbums = [];
|
||||
foreach (AlbumEntity albumEntity in repositoryEntity.Albums)
|
||||
{
|
||||
Result<Album> albumResult = albumEntity.ToDomainEntity();
|
||||
if (albumResult.IsFailure)
|
||||
return albumResult.Errors;
|
||||
domainAlbums.Add(albumResult.Value);
|
||||
}
|
||||
|
||||
return Artist.Create(
|
||||
ArtistId.Create(repositoryEntity.Id),
|
||||
LibraryId.Create(repositoryEntity.LibraryId),
|
||||
repositoryEntity.Name,
|
||||
Optional<string>.FromNullable(repositoryEntity.Website),
|
||||
musicBrainzArtistId,
|
||||
domainContributors,
|
||||
domainAlbums,
|
||||
repositoryEntity.CreatedOnUtc,
|
||||
Optional<DateTime>.FromNullable(repositoryEntity.UpdatedOnUtc));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="ArtistResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted response entity.</returns>
|
||||
public static ArtistResponse ToResponse(this ArtistEntity repositoryEntity)
|
||||
{
|
||||
return new ArtistResponse(
|
||||
repositoryEntity.Id,
|
||||
repositoryEntity.LibraryId,
|
||||
repositoryEntity.Name,
|
||||
repositoryEntity.Website,
|
||||
repositoryEntity.MusicBrainzArtistId,
|
||||
[.. repositoryEntity.Contributors.Select(contributor => new MediaContributorReferenceDto(contributor.MediaContributorId, contributor.Role))],
|
||||
[.. repositoryEntity.Albums.Select(album => album.ToResponse())],
|
||||
repositoryEntity.CreatedOnUtc,
|
||||
repositoryEntity.UpdatedOnUtc);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="ArtistResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>The converted responses.</returns>
|
||||
public static IReadOnlyList<ArtistResponse> ToResponses(this IEnumerable<ArtistEntity> repositoryEntities)
|
||||
{
|
||||
return [.. repositoryEntities.Select(repositoryEntity => repositoryEntity.ToResponse())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a paginated collection of <see cref="ArtistResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The paginated repository entities to be converted.</param>
|
||||
/// <returns>The converted paginated responses.</returns>
|
||||
public static PaginatedResponse<ArtistResponse> ToResponses(this PaginatedResultDto<ArtistEntity> repositoryEntities)
|
||||
{
|
||||
return new PaginatedResponse<ArtistResponse>
|
||||
{
|
||||
Data = repositoryEntities.Data.ToResponses(),
|
||||
CurrentPage = repositoryEntities.CurrentPage,
|
||||
PerPage = repositoryEntities.PerPage,
|
||||
Count = repositoryEntities.Count,
|
||||
NumberOfPages = repositoryEntities.NumberOfPages
|
||||
};
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Contracts.Responses.Common;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="ArtistLiteRow"/>.
|
||||
/// </summary>
|
||||
public static class ArtistLiteRowMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="readModel"/> to <see cref="ArtistLiteResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="readModel">The read model to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static ArtistLiteResponse ToResponse(this ArtistLiteRow readModel)
|
||||
{
|
||||
return new ArtistLiteResponse(
|
||||
readModel.Id,
|
||||
readModel.Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="readModels"/> to a collection of <see cref="ArtistLiteResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="readModels">The read models to be converted.</param>
|
||||
/// <returns>The converted responses.</returns>
|
||||
public static IReadOnlyList<ArtistLiteResponse> ToResponses(this IEnumerable<ArtistLiteRow> readModels)
|
||||
{
|
||||
return [.. readModels.Select(readModel => readModel.ToResponse())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="readModels"/> to a paginated collection of <see cref="ArtistLiteResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="readModels">The paginated read models to be converted.</param>
|
||||
/// <returns>The converted paginated responses.</returns>
|
||||
public static PaginatedResponse<ArtistLiteResponse> ToResponses(this PaginatedResultDto<ArtistLiteRow> readModels)
|
||||
{
|
||||
return new PaginatedResponse<ArtistLiteResponse>
|
||||
{
|
||||
Data = readModels.Data.ToResponses(),
|
||||
CurrentPage = readModels.CurrentPage,
|
||||
PerPage = readModels.PerPage,
|
||||
Count = readModels.Count,
|
||||
NumberOfPages = readModels.NumberOfPages
|
||||
};
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate;
|
||||
using System;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="Artist"/>.
|
||||
/// </summary>
|
||||
public static class ArtistMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="ArtistEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static ArtistEntity ToRepositoryEntity(this Artist domainEntity)
|
||||
{
|
||||
return new ArtistEntity
|
||||
{
|
||||
Id = domainEntity.Id.Value,
|
||||
LibraryId = domainEntity.LibraryId.Value,
|
||||
Name = domainEntity.Name,
|
||||
Website = domainEntity.Website.HasValue ? domainEntity.Website.Value : null,
|
||||
MusicBrainzArtistId = domainEntity.MusicBrainzArtistId.HasValue ? domainEntity.MusicBrainzArtistId.Value.Value : null,
|
||||
Contributors = [.. domainEntity.Contributors.Select(contributor => new ArtistContributorEntity
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
ArtistId = domainEntity.Id.Value,
|
||||
MediaContributorId = contributor.ContributorId.Value,
|
||||
Role = contributor.Role,
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
UpdatedBy = null
|
||||
})],
|
||||
Albums = [.. domainEntity.Albums.Select(album => album.ToRepositoryEntity(domainEntity.Id.Value, domainEntity.LibraryId.Value))],
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
UpdatedOnUtc = domainEntity.UpdatedOnUtc.HasValue ? domainEntity.UpdatedOnUtc : null,
|
||||
UpdatedBy = domainEntity.UpdatedOnUtc.HasValue ? Guid.NewGuid() : null
|
||||
};
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Queries.GetArtistAlbumsLite;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetArtistAlbumsLiteRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetArtistAlbumsLiteRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetArtistAlbumsLiteQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetArtistAlbumsLiteQuery ToQuery(this GetArtistAlbumsLiteRequest request)
|
||||
{
|
||||
return new GetArtistAlbumsLiteQuery(
|
||||
request.ArtistId,
|
||||
request.CurrentPage,
|
||||
request.PerPage);
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Queries.GetArtistAlbums;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetArtistAlbumsRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetArtistAlbumsRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetArtistAlbumsQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetArtistAlbumsQuery ToQuery(this GetArtistAlbumsRequest request)
|
||||
{
|
||||
return new GetArtistAlbumsQuery(
|
||||
request.ArtistId);
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Queries.GetArtist;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetArtistRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetArtistRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetArtistQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetArtistQuery ToQuery(this GetArtistRequest request)
|
||||
{
|
||||
return new GetArtistQuery(
|
||||
request.ArtistId);
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Queries.GetArtistsLite;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetArtistsLiteRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetArtistsLiteRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetArtistsLiteQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetArtistsLiteQuery ToQuery(this GetArtistsLiteRequest request)
|
||||
{
|
||||
return new GetArtistsLiteQuery(
|
||||
request.LibraryId,
|
||||
request.CurrentPage,
|
||||
request.PerPage,
|
||||
request.SearchTerm);
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Queries.GetArtists;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetArtistsRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetArtistsRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetArtistsQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetArtistsQuery ToQuery(this GetArtistsRequest request)
|
||||
{
|
||||
return new GetArtistsQuery(
|
||||
request.LibraryId,
|
||||
request.CurrentPage,
|
||||
request.PerPage,
|
||||
request.SearchTerm);
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Application.Common.Mapping.MediaContributors;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Commands.UpdateArtist;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="UpdateArtistCommand"/>.
|
||||
/// </summary>
|
||||
public static class UpdateArtistCommandMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="command"/> to <see cref="Artist"/>, preserving the identity and creation metadata of the stored artist identified by <paramref name="existingArtist"/>.
|
||||
/// </summary>
|
||||
/// <param name="command">The command to be converted.</param>
|
||||
/// <param name="existingArtist">The stored artist whose identity and creation metadata are preserved.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully converted <see cref="Artist"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<Artist> ToDomainEntity(this UpdateArtistCommand command, ArtistEntity existingArtist)
|
||||
{
|
||||
// Map the media contributors that make up the artist to their domain counterparts.
|
||||
IEnumerable<Result<MusicMediaContributor>> domainContributorsResult = command.Contributors!.ToMusicDomainEntities();
|
||||
List<Error> errors = [.. domainContributorsResult.Where(contributorResult => contributorResult.IsFailure).SelectMany(contributorResult => contributorResult.Errors) ?? []];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
// Build each album of the artist, together with its metadata, contributors, ratings and tracks.
|
||||
IEnumerable<Result<Album>> domainAlbumsResult = command.Albums!.ToDomainEntities();
|
||||
errors = [.. domainAlbumsResult.Where(albumResult => albumResult.IsFailure).SelectMany(albumResult => albumResult.Errors) ?? []];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
Optional<string> website = Optional<string>.FromNullable(command.Website);
|
||||
Optional<MusicBrainzId> musicBrainzArtistId = Optional<MusicBrainzId>.None();
|
||||
if (command.MusicBrainzArtistId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzArtistIdResult = MusicBrainzId.Create(command.MusicBrainzArtistId.Value);
|
||||
if (musicBrainzArtistIdResult.IsFailure)
|
||||
return musicBrainzArtistIdResult.Errors;
|
||||
musicBrainzArtistId = musicBrainzArtistIdResult.Value;
|
||||
}
|
||||
|
||||
return Artist.Create(
|
||||
ArtistId.Create(existingArtist.Id),
|
||||
LibraryId.Create(existingArtist.LibraryId),
|
||||
command.Name!,
|
||||
website,
|
||||
musicBrainzArtistId,
|
||||
[.. domainContributorsResult.Select(contributorResult => contributorResult.Value)],
|
||||
[.. domainAlbumsResult.Select(albumResult => albumResult.Value)],
|
||||
existingArtist.CreatedOnUtc,
|
||||
Optional<DateTime>.FromNullable(existingArtist.UpdatedOnUtc));
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Commands.UpdateArtist;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="UpdateArtistRequest"/>.
|
||||
/// </summary>
|
||||
public static class UpdateArtistRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="UpdateArtistCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <param name="libraryId">The Id of the library the artist belongs to, taken from the route.</param>
|
||||
/// <param name="artistId">The Id of the artist to update, taken from the route.</param>
|
||||
/// <returns>The converted command.</returns>
|
||||
public static UpdateArtistCommand ToCommand(this UpdateArtistRequest request, string? libraryId, string? artistId)
|
||||
{
|
||||
return new UpdateArtistCommand(
|
||||
libraryId,
|
||||
artistId,
|
||||
request.Name,
|
||||
request.Website,
|
||||
request.MusicBrainzArtistId,
|
||||
request.Contributors,
|
||||
request.Albums?.ToCommands(libraryId, artistId).ToList());
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="AudioRatingDto"/>.
|
||||
/// </summary>
|
||||
public static class AudioRatingDtoMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="dto"/> to <see cref="AudioRating"/>.
|
||||
/// </summary>
|
||||
/// <param name="dto">The DTO to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully converted <see cref="AudioRating"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<AudioRating> ToDomainEntity(this AudioRatingDto dto)
|
||||
{
|
||||
return AudioRating.Create(
|
||||
dto.Value ?? default,
|
||||
dto.MaxValue ?? default,
|
||||
Optional<AudioRatingSource>.FromNullable(dto.Source),
|
||||
Optional<int>.FromNullable(dto.VoteCount)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="dtos"/> to a collection of <see cref="AudioRating"/>.
|
||||
/// </summary>
|
||||
/// <param name="dtos">The DTOs to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a collection of converted <see cref="AudioRating"/>, or an error message.
|
||||
/// </returns>
|
||||
public static IEnumerable<Result<AudioRating>> ToDomainEntities(this IEnumerable<AudioRatingDto> dtos)
|
||||
{
|
||||
return dtos.Select(dto => dto.ToDomainEntity());
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="AudioRatingEntity"/>.
|
||||
/// </summary>
|
||||
public static class AudioRatingEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="AudioRatingDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted DTO.</returns>
|
||||
public static AudioRatingDto ToResponse(this AudioRatingEntity repositoryEntity)
|
||||
{
|
||||
return new AudioRatingDto(
|
||||
repositoryEntity.Value ?? default,
|
||||
repositoryEntity.MaxValue ?? default,
|
||||
repositoryEntity.Source,
|
||||
repositoryEntity.VoteCount
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="AudioRatingDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>The converted DTOs.</returns>
|
||||
public static IEnumerable<AudioRatingDto> ToResponses(this IEnumerable<AudioRatingEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(repositoryEntity => repositoryEntity.ToResponse());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="AudioRating"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully converted <see cref="AudioRating"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<AudioRating> ToDomainEntity(this AudioRatingEntity repositoryEntity)
|
||||
{
|
||||
return AudioRating.Create(
|
||||
repositoryEntity.Value ?? default,
|
||||
repositoryEntity.MaxValue ?? default,
|
||||
Optional<AudioRatingSource>.FromNullable(repositoryEntity.Source),
|
||||
Optional<int>.FromNullable(repositoryEntity.VoteCount)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="AudioRating"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a collection of converted <see cref="AudioRating"/>, or an error message.
|
||||
/// </returns>
|
||||
public static IEnumerable<Result<AudioRating>> ToDomainEntities(this IEnumerable<AudioRatingEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(repositoryEntity => repositoryEntity.ToDomainEntity());
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.Common.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="AudioRating"/>.
|
||||
/// </summary>
|
||||
public static class AudioRatingMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="AudioRatingEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static AudioRatingEntity ToRepositoryEntity(this AudioRating domainEntity)
|
||||
{
|
||||
return new AudioRatingEntity(
|
||||
domainEntity.Value,
|
||||
domainEntity.MaxValue,
|
||||
domainEntity.Source.HasValue ? domainEntity.Source.Value : null,
|
||||
domainEntity.VoteCount.HasValue ? domainEntity.VoteCount.Value : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainEntities"/> to a collection of <see cref="AudioRatingEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainEntities">The domain entities to be converted.</param>
|
||||
/// <returns>The converted repository entities.</returns>
|
||||
public static IEnumerable<AudioRatingEntity> ToRepositoryEntities(this IEnumerable<AudioRating> domainEntities)
|
||||
{
|
||||
return domainEntities.Select(domainEntity => domainEntity.ToRepositoryEntity());
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="IsrcDto"/>.
|
||||
/// </summary>
|
||||
public static class IsrcDtoMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="dto"/> to <see cref="Isrc"/>.
|
||||
/// </summary>
|
||||
/// <param name="dto">The DTO to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully converted <see cref="Isrc"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<Isrc> ToDomainEntity(this IsrcDto dto)
|
||||
{
|
||||
return Isrc.Create(dto.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="dtos"/> to a collection of <see cref="Isrc"/>.
|
||||
/// </summary>
|
||||
/// <param name="dtos">The DTOs to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a collection of converted <see cref="Isrc"/>, or an error message.
|
||||
/// </returns>
|
||||
public static IEnumerable<Result<Isrc>> ToDomainEntities(this IEnumerable<IsrcDto> dtos)
|
||||
{
|
||||
return dtos.Select(dto => dto.ToDomainEntity());
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="TrackIsrcEntity"/>.
|
||||
/// </summary>
|
||||
public static class IsrcEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="IsrcDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted DTO.</returns>
|
||||
public static IsrcDto ToResponse(this TrackIsrcEntity repositoryEntity)
|
||||
{
|
||||
return new IsrcDto(
|
||||
repositoryEntity.Value
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="IsrcDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>The converted DTOs.</returns>
|
||||
public static IEnumerable<IsrcDto> ToResponses(this IEnumerable<TrackIsrcEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(repositoryEntity => repositoryEntity.ToResponse());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="Isrc"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully converted <see cref="Isrc"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<Isrc> ToDomainEntity(this TrackIsrcEntity repositoryEntity)
|
||||
{
|
||||
return Isrc.Create(repositoryEntity.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="Isrc"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a collection of converted <see cref="Isrc"/>, or an error message.
|
||||
/// </returns>
|
||||
public static IEnumerable<Result<Isrc>> ToDomainEntities(this IEnumerable<TrackIsrcEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(repositoryEntity => repositoryEntity.ToDomainEntity());
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="Isrc"/>.
|
||||
/// </summary>
|
||||
public static class IsrcMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="TrackIsrcEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static TrackIsrcEntity ToRepositoryEntity(this Isrc domainEntity)
|
||||
{
|
||||
return new TrackIsrcEntity(
|
||||
domainEntity.Value
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainEntities"/> to a collection of <see cref="TrackIsrcEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainEntities">The domain entities to be converted.</param>
|
||||
/// <returns>The converted repository entities.</returns>
|
||||
public static IEnumerable<TrackIsrcEntity> ToRepositoryEntities(this IEnumerable<Isrc> domainEntities)
|
||||
{
|
||||
return domainEntities.Select(domainEntity => domainEntity.ToRepositoryEntity());
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="MoodDto"/>.
|
||||
/// </summary>
|
||||
public static class MoodDtoMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="dto"/> to <see cref="Mood"/>.
|
||||
/// </summary>
|
||||
/// <param name="dto">The DTO to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully converted <see cref="Mood"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<Mood> ToDomainEntity(this MoodDto dto)
|
||||
{
|
||||
return Mood.Create(dto.Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="dtos"/> to a collection of <see cref="Mood"/>.
|
||||
/// </summary>
|
||||
/// <param name="dtos">The DTOs to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a collection of converted <see cref="Mood"/>, or an error message.
|
||||
/// </returns>
|
||||
public static IEnumerable<Result<Mood>> ToDomainEntities(this IEnumerable<MoodDto> dtos)
|
||||
{
|
||||
return dtos.Select(dto => dto.ToDomainEntity());
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="TrackMoodEntity"/>.
|
||||
/// </summary>
|
||||
public static class MoodEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="MoodDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted DTO.</returns>
|
||||
public static MoodDto ToResponse(this TrackMoodEntity repositoryEntity)
|
||||
{
|
||||
return new MoodDto(
|
||||
repositoryEntity.Name
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="MoodDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>The converted DTOs.</returns>
|
||||
public static IEnumerable<MoodDto> ToResponses(this IEnumerable<TrackMoodEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(repositoryEntity => repositoryEntity.ToResponse());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="Mood"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully converted <see cref="Mood"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<Mood> ToDomainEntity(this TrackMoodEntity repositoryEntity)
|
||||
{
|
||||
return Mood.Create(repositoryEntity.Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="Mood"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a collection of converted <see cref="Mood"/>, or an error message.
|
||||
/// </returns>
|
||||
public static IEnumerable<Result<Mood>> ToDomainEntities(this IEnumerable<TrackMoodEntity> repositoryEntities)
|
||||
{
|
||||
return repositoryEntities.Select(repositoryEntity => repositoryEntity.ToDomainEntity());
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="Mood"/>.
|
||||
/// </summary>
|
||||
public static class MoodMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="TrackMoodEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static TrackMoodEntity ToRepositoryEntity(this Mood domainEntity)
|
||||
{
|
||||
return new TrackMoodEntity(
|
||||
domainEntity.Name
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainEntities"/> to a collection of <see cref="TrackMoodEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainEntities">The domain entities to be converted.</param>
|
||||
/// <returns>The converted repository entities.</returns>
|
||||
public static IEnumerable<TrackMoodEntity> ToRepositoryEntities(this IEnumerable<Mood> domainEntities)
|
||||
{
|
||||
return domainEntities.Select(domainEntity => domainEntity.ToRepositoryEntity());
|
||||
}
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.MediaContributors;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Common;
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Commands.AddTrack;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="AddTrackCommand"/>.
|
||||
/// </summary>
|
||||
public static class AddTrackCommandMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="command"/> to a domain <see cref="Track"/>.
|
||||
/// </summary>
|
||||
/// <param name="command">The command whose data is used to create the track.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="Track"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<Track> ToDomainEntity(this AddTrackCommand command)
|
||||
{
|
||||
Result<AudioMetadata> metadataResult = command.Metadata!.ToDomainEntity();
|
||||
if (metadataResult.IsFailure)
|
||||
return metadataResult.Errors;
|
||||
|
||||
IEnumerable<Result<Isrc>> domainIsrcsResult = (command.Isrcs ?? []).ToDomainEntities();
|
||||
List<Error> errors = [.. domainIsrcsResult.Where(isrcResult => isrcResult.IsFailure).SelectMany(isrcResult => isrcResult.Errors)];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
IEnumerable<Result<Mood>> domainMoodsResult = (command.Moods ?? []).ToDomainEntities();
|
||||
errors = [.. domainMoodsResult.Where(moodResult => moodResult.IsFailure).SelectMany(moodResult => moodResult.Errors)];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
IEnumerable<Result<MusicMediaContributor>> domainContributorsResult = (command.Contributors ?? []).ToMusicDomainEntities();
|
||||
errors = [.. domainContributorsResult.Where(contributorResult => contributorResult.IsFailure).SelectMany(contributorResult => contributorResult.Errors)];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
IEnumerable<Result<AudioRating>> domainRatingsResult = (command.Ratings ?? []).ToDomainEntities();
|
||||
errors = [.. domainRatingsResult.Where(ratingResult => ratingResult.IsFailure).SelectMany(ratingResult => ratingResult.Errors)];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
Optional<MusicBrainzId> musicBrainzRecordingId = Optional<MusicBrainzId>.None();
|
||||
if (command.MusicBrainzRecordingId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzRecordingIdResult = MusicBrainzId.Create(command.MusicBrainzRecordingId.Value);
|
||||
if (musicBrainzRecordingIdResult.IsFailure)
|
||||
return musicBrainzRecordingIdResult.Errors;
|
||||
musicBrainzRecordingId = musicBrainzRecordingIdResult.Value;
|
||||
}
|
||||
Optional<MusicBrainzId> musicBrainzTrackId = Optional<MusicBrainzId>.None();
|
||||
if (command.MusicBrainzTrackId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzTrackIdResult = MusicBrainzId.Create(command.MusicBrainzTrackId.Value);
|
||||
if (musicBrainzTrackIdResult.IsFailure)
|
||||
return musicBrainzTrackIdResult.Errors;
|
||||
musicBrainzTrackId = musicBrainzTrackIdResult.Value;
|
||||
}
|
||||
Optional<MusicBrainzId> musicBrainzWorkId = Optional<MusicBrainzId>.None();
|
||||
if (command.MusicBrainzWorkId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzWorkIdResult = MusicBrainzId.Create(command.MusicBrainzWorkId.Value);
|
||||
if (musicBrainzWorkIdResult.IsFailure)
|
||||
return musicBrainzWorkIdResult.Errors;
|
||||
musicBrainzWorkId = musicBrainzWorkIdResult.Value;
|
||||
}
|
||||
|
||||
return Track.Create(
|
||||
command.Path!,
|
||||
metadataResult.Value,
|
||||
command.TrackNumber ?? 1,
|
||||
Optional<int>.FromNullable(command.DiscNumber),
|
||||
[.. domainIsrcsResult.Select(isrcResult => isrcResult.Value)],
|
||||
Optional<string>.FromNullable(command.Script),
|
||||
Optional<MusicKey>.FromNullable(command.Key),
|
||||
Optional<int>.FromNullable(command.Bpm),
|
||||
[.. domainMoodsResult.Select(moodResult => moodResult.Value)],
|
||||
Optional<string>.FromNullable(command.Work),
|
||||
musicBrainzRecordingId,
|
||||
musicBrainzTrackId,
|
||||
musicBrainzWorkId,
|
||||
[.. domainContributorsResult.Select(contributorResult => contributorResult.Value)],
|
||||
[.. domainRatingsResult.Select(ratingResult => ratingResult.Value)]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="commands"/> to a collection of domain <see cref="Track"/>.
|
||||
/// </summary>
|
||||
/// <param name="commands">The commands whose data is used to create the tracks.</param>
|
||||
/// <returns>A collection of <see cref="Result{TValue}"/> containing either the converted tracks, or error messages.</returns>
|
||||
public static IEnumerable<Result<Track>> ToDomainEntities(this IEnumerable<AddTrackCommand> commands)
|
||||
{
|
||||
return commands.Select(command => command.ToDomainEntity());
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Commands.AddTrack;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="AddTrackRequest"/>.
|
||||
/// </summary>
|
||||
public static class AddTrackRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="AddTrackCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <param name="libraryId">The Id of the library the track belongs to, taken from the route.</param>
|
||||
/// <param name="artistId">The Id of the artist the track belongs to, taken from the route.</param>
|
||||
/// <param name="albumId">The Id of the album the track belongs to, taken from the route.</param>
|
||||
/// <returns>The converted command.</returns>
|
||||
public static AddTrackCommand ToCommand(this AddTrackRequest request, string? libraryId, string? artistId, string? albumId)
|
||||
{
|
||||
return new AddTrackCommand(
|
||||
libraryId,
|
||||
artistId,
|
||||
albumId,
|
||||
request.Path,
|
||||
request.Metadata,
|
||||
request.TrackNumber,
|
||||
request.DiscNumber,
|
||||
request.Script,
|
||||
request.Key,
|
||||
request.Bpm,
|
||||
request.Work,
|
||||
request.MusicBrainzRecordingId,
|
||||
request.MusicBrainzTrackId,
|
||||
request.MusicBrainzWorkId,
|
||||
request.Moods,
|
||||
request.Isrcs,
|
||||
request.Contributors,
|
||||
request.Ratings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="requests"/> to a collection of <see cref="AddTrackCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="requests">The requests to be converted.</param>
|
||||
/// <param name="libraryId">The Id of the library the tracks belong to, taken from the route.</param>
|
||||
/// <param name="artistId">The Id of the artist the tracks belong to, taken from the route.</param>
|
||||
/// <param name="albumId">The Id of the album the tracks belong to, taken from the route.</param>
|
||||
/// <returns>The converted commands.</returns>
|
||||
public static IEnumerable<AddTrackCommand> ToCommands(this IEnumerable<AddTrackRequest> requests, string? libraryId, string? artistId, string? albumId)
|
||||
{
|
||||
return requests.Select(request => request.ToCommand(libraryId, artistId, albumId));
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="AudioMetadataDto"/>.
|
||||
/// </summary>
|
||||
public static class AudioMetadataDtoMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="dto"/> to a domain <see cref="AudioMetadata"/>.
|
||||
/// </summary>
|
||||
/// <param name="dto">The data transfer object to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully converted <see cref="AudioMetadata"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<AudioMetadata> ToDomainEntity(this AudioMetadataDto dto)
|
||||
{
|
||||
ReleaseInfoDto? releaseInfoDto = dto.ReleaseInfo;
|
||||
Result<ReleaseInfo> releaseInfoResult = ReleaseInfo.Create(
|
||||
Optional<DateOnly>.FromNullable(releaseInfoDto?.OriginalReleaseDate),
|
||||
Optional<int>.FromNullable(releaseInfoDto?.OriginalReleaseYear),
|
||||
Optional<DateOnly>.FromNullable(releaseInfoDto?.ReReleaseDate),
|
||||
Optional<int>.FromNullable(releaseInfoDto?.ReReleaseYear),
|
||||
Optional<ReleaseCountry>.FromNullable(releaseInfoDto?.ReleaseCountry),
|
||||
Optional<string>.FromNullable(releaseInfoDto?.ReleaseVersion));
|
||||
if (releaseInfoResult.IsFailure)
|
||||
return releaseInfoResult.Errors;
|
||||
|
||||
List<Genre> domainGenres = [];
|
||||
foreach (GenreDto genre in dto.Genres ?? [])
|
||||
{
|
||||
Result<Genre> genreResult = genre.ToDomainEntity();
|
||||
if (genreResult.IsFailure)
|
||||
return genreResult.Errors;
|
||||
domainGenres.Add(genreResult.Value);
|
||||
}
|
||||
|
||||
List<Tag> domainTags = [];
|
||||
foreach (TagDto tag in dto.Tags ?? [])
|
||||
{
|
||||
Result<Tag> tagResult = tag.ToDomainEntity();
|
||||
if (tagResult.IsFailure)
|
||||
return tagResult.Errors;
|
||||
domainTags.Add(tagResult.Value);
|
||||
}
|
||||
|
||||
Optional<LanguageInfo> language = Optional<LanguageInfo>.None();
|
||||
if (dto.Language is not null && dto.Language.LanguageCode is not null && dto.Language.LanguageName is not null)
|
||||
language = LanguageInfo.Create(dto.Language.LanguageCode, dto.Language.LanguageName, Optional<string>.FromNullable(dto.Language.NativeName));
|
||||
|
||||
Optional<LanguageInfo> originalLanguage = Optional<LanguageInfo>.None();
|
||||
if (dto.OriginalLanguage is not null && dto.OriginalLanguage.LanguageCode is not null && dto.OriginalLanguage.LanguageName is not null)
|
||||
originalLanguage = LanguageInfo.Create(dto.OriginalLanguage.LanguageCode, dto.OriginalLanguage.LanguageName, Optional<string>.FromNullable(dto.OriginalLanguage.NativeName));
|
||||
|
||||
return AudioMetadata.Create(
|
||||
dto.Title!,
|
||||
Optional<string>.FromNullable(dto.OriginalTitle),
|
||||
dto.DurationInSeconds ?? 0,
|
||||
dto.SampleRate ?? 0,
|
||||
dto.Channels ?? 0,
|
||||
releaseInfoResult.Value,
|
||||
Optional<string>.FromNullable(dto.Description),
|
||||
domainGenres,
|
||||
domainTags,
|
||||
language,
|
||||
originalLanguage,
|
||||
Optional<int>.FromNullable(dto.BitDepth),
|
||||
Optional<string>.FromNullable(dto.AudioCodec),
|
||||
Optional<int>.FromNullable(dto.Bitrate));
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Commands.DeleteTrack;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="DeleteTrackRequest"/>.
|
||||
/// </summary>
|
||||
public static class DeleteTrackRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="DeleteTrackCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted command.</returns>
|
||||
public static DeleteTrackCommand ToCommand(this DeleteTrackRequest request)
|
||||
{
|
||||
return new DeleteTrackCommand(
|
||||
request.TrackId);
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Queries.GetTrack;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetTrackRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetTrackRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetTrackQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetTrackQuery ToQuery(this GetTrackRequest request)
|
||||
{
|
||||
return new GetTrackQuery(
|
||||
request.TrackId);
|
||||
}
|
||||
}
|
||||
+249
@@ -0,0 +1,249 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIdentifiers.MediaContributorBoundedContext.MediaContributorAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Common;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="TrackEntity"/>.
|
||||
/// </summary>
|
||||
public static class TrackEntityMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="Track"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully converted <see cref="Track"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<Track> ToDomainEntity(this TrackEntity repositoryEntity)
|
||||
{
|
||||
Result<ReleaseInfo> releaseInfoResult = ReleaseInfo.Create(
|
||||
Optional<DateOnly>.FromNullable(repositoryEntity.OriginalReleaseDate),
|
||||
Optional<int>.FromNullable(repositoryEntity.OriginalReleaseYear),
|
||||
Optional<DateOnly>.FromNullable(repositoryEntity.ReReleaseDate),
|
||||
Optional<int>.FromNullable(repositoryEntity.ReReleaseYear),
|
||||
Optional<ReleaseCountry>.FromNullable(repositoryEntity.ReleaseCountry),
|
||||
Optional<string>.FromNullable(repositoryEntity.ReleaseVersion));
|
||||
if (releaseInfoResult.IsFailure)
|
||||
return releaseInfoResult.Errors;
|
||||
|
||||
List<Genre> domainGenres = [];
|
||||
foreach (Result<Genre> genreResult in repositoryEntity.Genres.ToDomainEntities())
|
||||
{
|
||||
if (genreResult.IsFailure)
|
||||
return genreResult.Errors;
|
||||
domainGenres.Add(genreResult.Value);
|
||||
}
|
||||
|
||||
List<Tag> domainTags = [];
|
||||
foreach (Result<Tag> tagResult in repositoryEntity.Tags.ToDomainEntities())
|
||||
{
|
||||
if (tagResult.IsFailure)
|
||||
return tagResult.Errors;
|
||||
domainTags.Add(tagResult.Value);
|
||||
}
|
||||
|
||||
Optional<LanguageInfo> language = Optional<LanguageInfo>.None();
|
||||
if (repositoryEntity.LanguageCode is not null && repositoryEntity.LanguageName is not null)
|
||||
language = LanguageInfo.Create(repositoryEntity.LanguageCode, repositoryEntity.LanguageName, Optional<string>.FromNullable(repositoryEntity.LanguageNativeName));
|
||||
|
||||
Optional<LanguageInfo> originalLanguage = Optional<LanguageInfo>.None();
|
||||
if (repositoryEntity.OriginalLanguageCode is not null && repositoryEntity.OriginalLanguageName is not null)
|
||||
originalLanguage = LanguageInfo.Create(repositoryEntity.OriginalLanguageCode, repositoryEntity.OriginalLanguageName, Optional<string>.FromNullable(repositoryEntity.OriginalLanguageNativeName));
|
||||
|
||||
Result<AudioMetadata> metadataResult = AudioMetadata.Create(
|
||||
repositoryEntity.Title,
|
||||
Optional<string>.FromNullable(repositoryEntity.OriginalTitle),
|
||||
repositoryEntity.DurationInSeconds,
|
||||
repositoryEntity.SampleRate,
|
||||
repositoryEntity.Channels,
|
||||
releaseInfoResult.Value,
|
||||
Optional<string>.FromNullable(repositoryEntity.Description),
|
||||
domainGenres,
|
||||
domainTags,
|
||||
language,
|
||||
originalLanguage,
|
||||
Optional<int>.FromNullable(repositoryEntity.BitDepth),
|
||||
Optional<string>.FromNullable(repositoryEntity.AudioCodec),
|
||||
Optional<int>.FromNullable(repositoryEntity.Bitrate));
|
||||
if (metadataResult.IsFailure)
|
||||
return metadataResult.Errors;
|
||||
|
||||
Optional<MusicBrainzId> musicBrainzRecordingId = Optional<MusicBrainzId>.None();
|
||||
if (repositoryEntity.MusicBrainzRecordingId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzRecordingIdResult = MusicBrainzId.Create(repositoryEntity.MusicBrainzRecordingId.Value);
|
||||
if (musicBrainzRecordingIdResult.IsFailure)
|
||||
return musicBrainzRecordingIdResult.Errors;
|
||||
musicBrainzRecordingId = musicBrainzRecordingIdResult.Value;
|
||||
}
|
||||
Optional<MusicBrainzId> musicBrainzTrackId = Optional<MusicBrainzId>.None();
|
||||
if (repositoryEntity.MusicBrainzTrackId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzTrackIdResult = MusicBrainzId.Create(repositoryEntity.MusicBrainzTrackId.Value);
|
||||
if (musicBrainzTrackIdResult.IsFailure)
|
||||
return musicBrainzTrackIdResult.Errors;
|
||||
musicBrainzTrackId = musicBrainzTrackIdResult.Value;
|
||||
}
|
||||
Optional<MusicBrainzId> musicBrainzWorkId = Optional<MusicBrainzId>.None();
|
||||
if (repositoryEntity.MusicBrainzWorkId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzWorkIdResult = MusicBrainzId.Create(repositoryEntity.MusicBrainzWorkId.Value);
|
||||
if (musicBrainzWorkIdResult.IsFailure)
|
||||
return musicBrainzWorkIdResult.Errors;
|
||||
musicBrainzWorkId = musicBrainzWorkIdResult.Value;
|
||||
}
|
||||
|
||||
List<Isrc> domainIsrcs = [];
|
||||
foreach (Result<Isrc> isrcResult in repositoryEntity.Isrcs.ToDomainEntities())
|
||||
{
|
||||
if (isrcResult.IsFailure)
|
||||
return isrcResult.Errors;
|
||||
domainIsrcs.Add(isrcResult.Value);
|
||||
}
|
||||
|
||||
List<Mood> domainMoods = [];
|
||||
foreach (Result<Mood> moodResult in repositoryEntity.Moods.ToDomainEntities())
|
||||
{
|
||||
if (moodResult.IsFailure)
|
||||
return moodResult.Errors;
|
||||
domainMoods.Add(moodResult.Value);
|
||||
}
|
||||
|
||||
List<AudioRating> domainRatings = [];
|
||||
foreach (Result<AudioRating> ratingResult in repositoryEntity.Ratings.ToDomainEntities())
|
||||
{
|
||||
if (ratingResult.IsFailure)
|
||||
return ratingResult.Errors;
|
||||
domainRatings.Add(ratingResult.Value);
|
||||
}
|
||||
|
||||
List<MusicMediaContributor> domainContributors = [];
|
||||
foreach (TrackContributorEntity contributorEntity in repositoryEntity.Contributors)
|
||||
{
|
||||
Result<MusicMediaContributor> contributorResult = MusicMediaContributor.Create(MediaContributorId.Create(contributorEntity.MediaContributorId), contributorEntity.Role);
|
||||
if (contributorResult.IsFailure)
|
||||
return contributorResult.Errors;
|
||||
domainContributors.Add(contributorResult.Value);
|
||||
}
|
||||
|
||||
return Track.Create(
|
||||
TrackId.Create(repositoryEntity.Id),
|
||||
repositoryEntity.Path,
|
||||
metadataResult.Value,
|
||||
repositoryEntity.TrackNumber,
|
||||
Optional<int>.FromNullable(repositoryEntity.DiscNumber),
|
||||
domainIsrcs,
|
||||
Optional<string>.FromNullable(repositoryEntity.Script),
|
||||
Optional<MusicKey>.FromNullable(repositoryEntity.Key),
|
||||
Optional<int>.FromNullable(repositoryEntity.Bpm),
|
||||
domainMoods,
|
||||
Optional<string>.FromNullable(repositoryEntity.Work),
|
||||
musicBrainzRecordingId,
|
||||
musicBrainzTrackId,
|
||||
musicBrainzWorkId,
|
||||
domainContributors,
|
||||
domainRatings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntity"/> to <see cref="TrackResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntity">The repository entity to be converted.</param>
|
||||
/// <returns>The converted response entity.</returns>
|
||||
public static TrackResponse ToResponse(this TrackEntity repositoryEntity)
|
||||
{
|
||||
ReleaseInfoDto releaseInfo = new(
|
||||
repositoryEntity.OriginalReleaseDate,
|
||||
repositoryEntity.OriginalReleaseYear,
|
||||
repositoryEntity.ReReleaseDate,
|
||||
repositoryEntity.ReReleaseYear,
|
||||
repositoryEntity.ReleaseCountry,
|
||||
repositoryEntity.ReleaseVersion
|
||||
);
|
||||
// language and original language make sense only if their subproperties have values
|
||||
LanguageInfoDto? languageInfo = !string.IsNullOrWhiteSpace(repositoryEntity.LanguageCode) ||
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.LanguageName) ||
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.LanguageNativeName)
|
||||
? new LanguageInfoDto(
|
||||
repositoryEntity.LanguageCode,
|
||||
repositoryEntity.LanguageName,
|
||||
repositoryEntity.LanguageNativeName
|
||||
) : null;
|
||||
LanguageInfoDto? originalLanguageInfo = !string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageCode) ||
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageName) ||
|
||||
!string.IsNullOrWhiteSpace(repositoryEntity.OriginalLanguageNativeName)
|
||||
? new LanguageInfoDto(
|
||||
repositoryEntity.OriginalLanguageCode,
|
||||
repositoryEntity.OriginalLanguageName,
|
||||
repositoryEntity.OriginalLanguageNativeName
|
||||
) : null;
|
||||
AudioMetadataDto metadata = new(
|
||||
repositoryEntity.Title,
|
||||
repositoryEntity.OriginalTitle,
|
||||
repositoryEntity.Description,
|
||||
releaseInfo,
|
||||
languageInfo,
|
||||
originalLanguageInfo,
|
||||
[.. repositoryEntity.Tags.ToResponses()],
|
||||
[.. repositoryEntity.Genres.ToResponses()],
|
||||
repositoryEntity.DurationInSeconds,
|
||||
repositoryEntity.SampleRate,
|
||||
repositoryEntity.Channels,
|
||||
repositoryEntity.BitDepth,
|
||||
repositoryEntity.AudioCodec,
|
||||
repositoryEntity.Bitrate
|
||||
);
|
||||
return new TrackResponse(
|
||||
repositoryEntity.Id,
|
||||
repositoryEntity.AlbumId,
|
||||
repositoryEntity.LibraryId,
|
||||
repositoryEntity.Path,
|
||||
metadata,
|
||||
repositoryEntity.TrackNumber,
|
||||
repositoryEntity.DiscNumber,
|
||||
repositoryEntity.Script,
|
||||
repositoryEntity.Key,
|
||||
repositoryEntity.Bpm,
|
||||
repositoryEntity.Work,
|
||||
repositoryEntity.MusicBrainzRecordingId,
|
||||
repositoryEntity.MusicBrainzTrackId,
|
||||
repositoryEntity.MusicBrainzWorkId,
|
||||
repositoryEntity.CreatedOnUtc,
|
||||
repositoryEntity.UpdatedOnUtc,
|
||||
[.. repositoryEntity.Contributors.Select(contributor => new MediaContributorReferenceDto(contributor.MediaContributorId, contributor.Role))],
|
||||
[.. repositoryEntity.Ratings.ToResponses()],
|
||||
[.. repositoryEntity.Moods.ToResponses()],
|
||||
[.. repositoryEntity.Isrcs.ToResponses()]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="repositoryEntities"/> to a collection of <see cref="TrackResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="repositoryEntities">The repository entities to be converted.</param>
|
||||
/// <returns>The converted responses.</returns>
|
||||
public static IReadOnlyList<TrackResponse> ToResponses(this IEnumerable<TrackEntity> repositoryEntities)
|
||||
{
|
||||
return [.. repositoryEntities.Select(repositoryEntity => repositoryEntity.ToResponse())];
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Contracts.Responses.Common;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="TrackLiteRow"/>.
|
||||
/// </summary>
|
||||
public static class TrackLiteRowMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="readModel"/> to <see cref="TrackLiteResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="readModel">The read model to be converted.</param>
|
||||
/// <returns>The converted response.</returns>
|
||||
public static TrackLiteResponse ToResponse(this TrackLiteRow readModel)
|
||||
{
|
||||
return new TrackLiteResponse(
|
||||
readModel.Id,
|
||||
readModel.Title,
|
||||
readModel.TrackNumber,
|
||||
readModel.DiscNumber);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="readModels"/> to a collection of <see cref="TrackLiteResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="readModels">The read models to be converted.</param>
|
||||
/// <returns>The converted responses.</returns>
|
||||
public static IReadOnlyList<TrackLiteResponse> ToResponses(this IEnumerable<TrackLiteRow> readModels)
|
||||
{
|
||||
return [.. readModels.Select(readModel => readModel.ToResponse())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts <paramref name="readModels"/> to a paginated collection of <see cref="TrackLiteResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="readModels">The paginated read models to be converted.</param>
|
||||
/// <returns>The converted paginated responses.</returns>
|
||||
public static PaginatedResponse<TrackLiteResponse> ToResponses(this PaginatedResultDto<TrackLiteRow> readModels)
|
||||
{
|
||||
return new PaginatedResponse<TrackLiteResponse>
|
||||
{
|
||||
Data = readModels.Data.ToResponses(),
|
||||
CurrentPage = readModels.CurrentPage,
|
||||
PerPage = readModels.PerPage,
|
||||
Count = readModels.Count,
|
||||
NumberOfPages = readModels.NumberOfPages
|
||||
};
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Common;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="Track"/>.
|
||||
/// </summary>
|
||||
public static class TrackMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="domainEntity"/> to <see cref="TrackEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="domainEntity">The domain entity to be converted.</param>
|
||||
/// <param name="albumId">The Id of the album the track belongs to.</param>
|
||||
/// <param name="libraryId">The Id of the media library the album of the track belongs to.</param>
|
||||
/// <returns>The converted repository entity.</returns>
|
||||
public static TrackEntity ToRepositoryEntity(this Track domainEntity, Guid albumId, Guid libraryId)
|
||||
{
|
||||
return new TrackEntity
|
||||
{
|
||||
Id = domainEntity.Id.Value,
|
||||
AlbumId = albumId,
|
||||
LibraryId = libraryId,
|
||||
Path = domainEntity.Path,
|
||||
Title = domainEntity.Metadata.Title,
|
||||
OriginalTitle = domainEntity.Metadata.OriginalTitle.HasValue ? domainEntity.Metadata.OriginalTitle.Value : null,
|
||||
Description = domainEntity.Metadata.Description.HasValue ? domainEntity.Metadata.Description.Value : null,
|
||||
OriginalReleaseDate = domainEntity.Metadata.ReleaseInfo.OriginalReleaseDate.HasValue ? domainEntity.Metadata.ReleaseInfo.OriginalReleaseDate.Value : null,
|
||||
OriginalReleaseYear = domainEntity.Metadata.ReleaseInfo.OriginalReleaseYear.HasValue ? domainEntity.Metadata.ReleaseInfo.OriginalReleaseYear.Value : null,
|
||||
ReReleaseDate = domainEntity.Metadata.ReleaseInfo.ReReleaseDate.HasValue ? domainEntity.Metadata.ReleaseInfo.ReReleaseDate.Value : null,
|
||||
ReReleaseYear = domainEntity.Metadata.ReleaseInfo.ReReleaseYear.HasValue ? domainEntity.Metadata.ReleaseInfo.ReReleaseYear.Value : null,
|
||||
ReleaseCountry = domainEntity.Metadata.ReleaseInfo.ReleaseCountry.HasValue ? domainEntity.Metadata.ReleaseInfo.ReleaseCountry.Value : null,
|
||||
ReleaseVersion = domainEntity.Metadata.ReleaseInfo.ReleaseVersion.HasValue ? domainEntity.Metadata.ReleaseInfo.ReleaseVersion.Value : null,
|
||||
LanguageCode = domainEntity.Metadata.Language.HasValue ? domainEntity.Metadata.Language.Value.LanguageCode : null,
|
||||
LanguageName = domainEntity.Metadata.Language.HasValue ? domainEntity.Metadata.Language.Value.LanguageName : null,
|
||||
LanguageNativeName = domainEntity.Metadata.Language.HasValue && domainEntity.Metadata.Language.Value.NativeName.HasValue ? domainEntity.Metadata.Language.Value.NativeName.Value : null,
|
||||
OriginalLanguageCode = domainEntity.Metadata.OriginalLanguage.HasValue ? domainEntity.Metadata.OriginalLanguage.Value.LanguageCode : null,
|
||||
OriginalLanguageName = domainEntity.Metadata.OriginalLanguage.HasValue ? domainEntity.Metadata.OriginalLanguage.Value.LanguageName : null,
|
||||
OriginalLanguageNativeName = domainEntity.Metadata.OriginalLanguage.HasValue && domainEntity.Metadata.OriginalLanguage.Value.NativeName.HasValue ? domainEntity.Metadata.OriginalLanguage.Value.NativeName.Value : null,
|
||||
Genres = [.. domainEntity.Metadata.Genres.ToRepositoryEntities()],
|
||||
Tags = [.. domainEntity.Metadata.Tags.ToRepositoryEntities()],
|
||||
DurationInSeconds = domainEntity.Metadata.DurationInSeconds,
|
||||
SampleRate = domainEntity.Metadata.SampleRate,
|
||||
Channels = domainEntity.Metadata.Channels,
|
||||
BitDepth = domainEntity.Metadata.BitDepth.HasValue ? domainEntity.Metadata.BitDepth.Value : null,
|
||||
AudioCodec = domainEntity.Metadata.AudioCodec.HasValue ? domainEntity.Metadata.AudioCodec.Value : null,
|
||||
Bitrate = domainEntity.Metadata.Bitrate.HasValue ? domainEntity.Metadata.Bitrate.Value : null,
|
||||
TrackNumber = domainEntity.TrackNumber,
|
||||
DiscNumber = domainEntity.DiscNumber.HasValue ? domainEntity.DiscNumber.Value : null,
|
||||
Script = domainEntity.Script.HasValue ? domainEntity.Script.Value : null,
|
||||
Key = domainEntity.Key.HasValue ? domainEntity.Key.Value : null,
|
||||
Bpm = domainEntity.Bpm.HasValue ? domainEntity.Bpm.Value : null,
|
||||
Work = domainEntity.Work.HasValue ? domainEntity.Work.Value : null,
|
||||
MusicBrainzRecordingId = domainEntity.MusicBrainzRecordingId.HasValue ? domainEntity.MusicBrainzRecordingId.Value.Value : null,
|
||||
MusicBrainzTrackId = domainEntity.MusicBrainzTrackId.HasValue ? domainEntity.MusicBrainzTrackId.Value.Value : null,
|
||||
MusicBrainzWorkId = domainEntity.MusicBrainzWorkId.HasValue ? domainEntity.MusicBrainzWorkId.Value.Value : null,
|
||||
Contributors = [.. domainEntity.Contributors.Select(contributor => new TrackContributorEntity
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
TrackId = domainEntity.Id.Value,
|
||||
MediaContributorId = contributor.ContributorId.Value,
|
||||
Role = contributor.Role,
|
||||
CreatedOnUtc = default,
|
||||
CreatedBy = default
|
||||
})],
|
||||
Moods = [.. domainEntity.Moods.ToRepositoryEntities()],
|
||||
Isrcs = [.. domainEntity.Isrcs.ToRepositoryEntities()],
|
||||
Ratings = [.. domainEntity.Ratings.ToRepositoryEntities()],
|
||||
CreatedOnUtc = default,
|
||||
CreatedBy = default,
|
||||
UpdatedBy = default
|
||||
};
|
||||
}
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Common;
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Commands.UpdateTrack;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="UpdateTrackCommand"/>.
|
||||
/// </summary>
|
||||
public static class UpdateTrackCommandMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="command"/> to a domain <see cref="Track"/>, preserving the provided <paramref name="id"/>.
|
||||
/// </summary>
|
||||
/// <param name="command">The command whose data is used to create the track.</param>
|
||||
/// <param name="id">The unique identifier of the track.</param>
|
||||
/// <param name="libraryId">The Id of the media library the track belongs to.</param>
|
||||
/// <param name="ratings">The list of ratings of the track.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="Track"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<Track> ToDomainEntity(this UpdateTrackCommand command, TrackId id, Guid libraryId, List<AudioRating> ratings)
|
||||
{
|
||||
Result<AudioMetadata> metadataResult = command.Metadata!.ToDomainEntity();
|
||||
if (metadataResult.IsFailure)
|
||||
return metadataResult.Errors;
|
||||
|
||||
Optional<MusicBrainzId> musicBrainzRecordingId = Optional<MusicBrainzId>.None();
|
||||
if (command.MusicBrainzRecordingId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzRecordingIdResult = MusicBrainzId.Create(command.MusicBrainzRecordingId.Value);
|
||||
if (musicBrainzRecordingIdResult.IsFailure)
|
||||
return musicBrainzRecordingIdResult.Errors;
|
||||
musicBrainzRecordingId = musicBrainzRecordingIdResult.Value;
|
||||
}
|
||||
Optional<MusicBrainzId> musicBrainzTrackId = Optional<MusicBrainzId>.None();
|
||||
if (command.MusicBrainzTrackId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzTrackIdResult = MusicBrainzId.Create(command.MusicBrainzTrackId.Value);
|
||||
if (musicBrainzTrackIdResult.IsFailure)
|
||||
return musicBrainzTrackIdResult.Errors;
|
||||
musicBrainzTrackId = musicBrainzTrackIdResult.Value;
|
||||
}
|
||||
Optional<MusicBrainzId> musicBrainzWorkId = Optional<MusicBrainzId>.None();
|
||||
if (command.MusicBrainzWorkId is not null)
|
||||
{
|
||||
Result<MusicBrainzId> musicBrainzWorkIdResult = MusicBrainzId.Create(command.MusicBrainzWorkId.Value);
|
||||
if (musicBrainzWorkIdResult.IsFailure)
|
||||
return musicBrainzWorkIdResult.Errors;
|
||||
musicBrainzWorkId = musicBrainzWorkIdResult.Value;
|
||||
}
|
||||
|
||||
List<Isrc> domainIsrcs = [];
|
||||
foreach (IsrcDto isrc in command.Isrcs ?? [])
|
||||
{
|
||||
Result<Isrc> isrcResult = isrc.ToDomainEntity();
|
||||
if (isrcResult.IsFailure)
|
||||
return isrcResult.Errors;
|
||||
domainIsrcs.Add(isrcResult.Value);
|
||||
}
|
||||
|
||||
List<Mood> domainMoods = [];
|
||||
foreach (MoodDto mood in command.Moods ?? [])
|
||||
{
|
||||
Result<Mood> moodResult = mood.ToDomainEntity();
|
||||
if (moodResult.IsFailure)
|
||||
return moodResult.Errors;
|
||||
domainMoods.Add(moodResult.Value);
|
||||
}
|
||||
|
||||
return Track.Create(
|
||||
id,
|
||||
command.Path!,
|
||||
metadataResult.Value,
|
||||
command.TrackNumber ?? 1,
|
||||
Optional<int>.FromNullable(command.DiscNumber),
|
||||
domainIsrcs,
|
||||
Optional<string>.FromNullable(command.Script),
|
||||
Optional<MusicKey>.FromNullable(command.Key),
|
||||
Optional<int>.FromNullable(command.Bpm),
|
||||
domainMoods,
|
||||
Optional<string>.FromNullable(command.Work),
|
||||
musicBrainzRecordingId,
|
||||
musicBrainzTrackId,
|
||||
musicBrainzWorkId,
|
||||
[],
|
||||
ratings);
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Commands.UpdateTrack;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="UpdateTrackRequest"/>.
|
||||
/// </summary>
|
||||
public static class UpdateTrackRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="UpdateTrackCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <param name="libraryId">The Id of the library the track belongs to, taken from the route.</param>
|
||||
/// <param name="artistId">The Id of the artist the track belongs to, taken from the route.</param>
|
||||
/// <param name="albumId">The Id of the album the track belongs to, taken from the route.</param>
|
||||
/// <param name="trackId">The Id of the track to update, taken from the route.</param>
|
||||
/// <returns>The converted command.</returns>
|
||||
public static UpdateTrackCommand ToCommand(this UpdateTrackRequest request, string? libraryId, string? artistId, string? albumId, string? trackId)
|
||||
{
|
||||
return new UpdateTrackCommand(
|
||||
libraryId,
|
||||
artistId,
|
||||
albumId,
|
||||
trackId,
|
||||
request.Path,
|
||||
request.Metadata,
|
||||
request.TrackNumber,
|
||||
request.DiscNumber,
|
||||
request.Script,
|
||||
request.Key,
|
||||
request.Bpm,
|
||||
request.Work,
|
||||
request.MusicBrainzRecordingId,
|
||||
request.MusicBrainzTrackId,
|
||||
request.MusicBrainzWorkId,
|
||||
request.Ratings,
|
||||
request.Moods,
|
||||
request.Isrcs);
|
||||
}
|
||||
}
|
||||
+6
-5
@@ -26,18 +26,19 @@ public static class AddBookCommandMapping
|
||||
/// Converts <paramref name="command"/> to <see cref="Book"/>.
|
||||
/// </summary>
|
||||
/// <param name="command">The command to be converted.</param>
|
||||
/// <param name="libraryId">The Id of the media library the library is added to.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully converted <see cref="Book"/>, or an error message.
|
||||
/// </returns>
|
||||
public static Result<Book> ToDomainEntity(this AddBookCommand command, Guid libraryId)
|
||||
{
|
||||
IEnumerable<Result<BookRating>> domainRatingsResult = command.Ratings!.ToDomainEntities();
|
||||
List<Error> errors = [.. domainRatingsResult.Where(ratingResult => ratingResult.IsFailure).SelectMany(ratingResult => ratingResult.Errors) ?? []];
|
||||
List<Error> errors = [.. domainRatingsResult.Where(ratingResult => ratingResult.IsFailure).SelectMany(ratingResult => ratingResult.Errors)];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
IEnumerable<Result<Isbn>> domainIsbnsResult = command.ISBNs!.ToDomainEntities();
|
||||
errors = [.. domainIsbnsResult.Where(isbnResult => isbnResult.IsFailure).SelectMany(isbnResult => isbnResult.Errors) ?? []];
|
||||
errors = [.. domainIsbnsResult.Where(isbnResult => isbnResult.IsFailure).SelectMany(isbnResult => isbnResult.Errors)];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
@@ -45,7 +46,7 @@ public static class AddBookCommandMapping
|
||||
if (metadataResult.IsFailure)
|
||||
return metadataResult.Errors;
|
||||
|
||||
// TODO: update Api.Book.md documentation when the functionality is fully implemented.
|
||||
// TODO: update Api.Books.md documentation when the functionality is fully implemented.
|
||||
BookSeries? bookSeries = null;
|
||||
if (command.Series != null)
|
||||
{
|
||||
@@ -55,13 +56,13 @@ public static class AddBookCommandMapping
|
||||
|
||||
// Map the media contributors referenced by the user to their domain counterparts; a contributor is identified by its id and carries the role it played.
|
||||
IEnumerable<Result<BookMediaContributor>> domainContributorsResult = command.Contributors!.ToBookDomainEntities();
|
||||
errors = [.. domainContributorsResult.Where(domainContributor => domainContributor.IsFailure).SelectMany(domainContributor => domainContributor.Errors) ?? []];
|
||||
errors = [.. domainContributorsResult.Where(domainContributor => domainContributor.IsFailure).SelectMany(domainContributor => domainContributor.Errors)];
|
||||
if (errors.Count > 0)
|
||||
return errors;
|
||||
|
||||
return Book.Create(
|
||||
LibraryId.Create(libraryId),
|
||||
command.Path,
|
||||
command.Path!,
|
||||
metadataResult.Value,
|
||||
Optional<BookFormat>.FromNullable(command.Format),
|
||||
Optional<string>.FromNullable(command.Edition),
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Common.Mapping.Common.Metadata;
|
||||
@@ -61,7 +61,7 @@ public static class BookEntityMapping
|
||||
return bookRatingResult.Errors;
|
||||
|
||||
List<BookMediaContributor> domainContributors = [];
|
||||
foreach (BookContributorEntity bookContributor in repositoryEntity.BookContributors)
|
||||
foreach (BookContributorEntity bookContributor in repositoryEntity.Contributors)
|
||||
{
|
||||
Result<BookMediaContributor> contributorResult = BookMediaContributor.Create(
|
||||
MediaContributorId.Create(bookContributor.MediaContributorId), bookContributor.Role);
|
||||
@@ -219,14 +219,14 @@ public static class BookEntityMapping
|
||||
repositoryEntity.BarnesAndNobleId,
|
||||
repositoryEntity.AppleBooksId,
|
||||
[.. repositoryEntity.ISBNs.ToResponses()],
|
||||
[.. repositoryEntity.BookContributors.Select(contributor => new MediaContributorReferenceDto(contributor.MediaContributorId, contributor.Role))],
|
||||
[.. repositoryEntity.Contributors.Select(contributor => new MediaContributorReferenceDto(contributor.MediaContributorId, contributor.Role))],
|
||||
[.. repositoryEntity.Ratings.ToResponses()],
|
||||
repositoryEntity.MetadataStatus,
|
||||
repositoryEntity.LastMetadataUpdateUtc,
|
||||
repositoryEntity.MetadataProvider,
|
||||
repositoryEntity.CreatedOnUtc,
|
||||
repositoryEntity.UpdatedOnUtc,
|
||||
repositoryEntity.BookArtwork.FirstOrDefault(artwork => artwork.ArtworkType == ArtworkType.Cover)?.FileName
|
||||
repositoryEntity.Artwork.FirstOrDefault(artwork => artwork.ArtworkType == ArtworkType.Cover)?.FileName
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public static class BookMapping
|
||||
BarnesAndNobleId = domainEntity.BarnesAndNobleId.HasValue ? domainEntity.BarnesAndNobleId.Value : null,
|
||||
AppleBooksId = domainEntity.AppleBooksId.HasValue ? domainEntity.AppleBooksId.Value : null,
|
||||
ISBNs = [.. domainEntity.ISBNs.ToRepositoryEntities()],
|
||||
BookContributors = [.. domainEntity.Contributors.Select(contributor => new BookContributorEntity
|
||||
Contributors = [.. domainEntity.Contributors.Select(contributor => new BookContributorEntity
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
BookId = domainEntity.Id.Value,
|
||||
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingAvailability;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetReadingAvailabilityRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetReadingAvailabilityRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetReadingAvailabilityQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetReadingAvailabilityQuery ToQuery(this GetReadingAvailabilityRequest request)
|
||||
{
|
||||
return new GetReadingAvailabilityQuery(
|
||||
request.BookId
|
||||
);
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingManifest;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetReadingManifestRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetReadingManifestRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetReadingManifestQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetReadingManifestQuery ToQuery(this GetReadingManifestRequest request)
|
||||
{
|
||||
return new GetReadingManifestQuery(
|
||||
request.BookId
|
||||
);
|
||||
}
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingResource;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetReadingResourceRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetReadingResourceRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetReadingResourceQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetReadingResourceQuery ToQuery(this GetReadingResourceRequest request)
|
||||
{
|
||||
return new GetReadingResourceQuery(
|
||||
request.BookId,
|
||||
request.ResourceKey
|
||||
);
|
||||
}
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading.Queries.GetReadingSection;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="GetReadingSectionRequest"/>.
|
||||
/// </summary>
|
||||
public static class GetReadingSectionRequestMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="request"/> to <see cref="GetReadingSectionQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be converted.</param>
|
||||
/// <returns>The converted query.</returns>
|
||||
public static GetReadingSectionQuery ToQuery(this GetReadingSectionRequest request)
|
||||
{
|
||||
return new GetReadingSectionQuery(
|
||||
request.BookId,
|
||||
request.LocationRef
|
||||
);
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Commands.UpdateBookCover;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for converting <see cref="UpdateBookCoverCommand"/>.
|
||||
/// </summary>
|
||||
public static class UpdateBookCoverCommandMapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts <paramref name="command"/> to the cover artwork of the book identified by <paramref name="bookId"/>, replacing the
|
||||
/// file of <paramref name="existingCover"/> when the book already has a cover, or creating a new cover artwork when it does not.
|
||||
/// </summary>
|
||||
/// <param name="command">The command whose cover image was stored.</param>
|
||||
/// <param name="existingCover">The existing cover artwork of the book, or <see langword="null"/> when the book has none.</param>
|
||||
/// <param name="bookId">The Id of the book the cover belongs to.</param>
|
||||
/// <param name="storedCoverPath">The relative path of the stored cover image.</param>
|
||||
/// <param name="userId">The Id of the user that stored the cover image.</param>
|
||||
/// <returns>The cover artwork of the book, carrying the stored cover image.</returns>
|
||||
public static BookArtworkEntity ToRepositoryEntity(this UpdateBookCoverCommand command, BookArtworkEntity? existingCover, Guid bookId, string storedCoverPath, Guid userId)
|
||||
{
|
||||
if (existingCover is null)
|
||||
{
|
||||
return new BookArtworkEntity
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
BookId = bookId,
|
||||
ArtworkType = ArtworkType.Cover,
|
||||
Ordinal = 0,
|
||||
FileName = storedCoverPath,
|
||||
Status = ArtworkStatus.Enriched,
|
||||
CreatedOnUtc = DateTime.UtcNow,
|
||||
CreatedBy = userId,
|
||||
UpdatedBy = null
|
||||
};
|
||||
}
|
||||
|
||||
existingCover.FileName = storedCoverPath;
|
||||
existingCover.Status = ArtworkStatus.Enriched;
|
||||
existingCover.LastUpdateUtc = DateTime.UtcNow;
|
||||
existingCover.UpdatedOnUtc = DateTime.UtcNow;
|
||||
existingCover.UpdatedBy = userId;
|
||||
return existingCover;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 439 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user