Skip to content

best way to save what you love

api/soundcloud: add more metadata fields (#1313)

nexpid170cf293bfd1
diff --git a/api/src/processing/services/soundcloud.js b/api/src/processing/services/soundcloud.js
index 890af8db..c5f0c6eb 100644
--- a/api/src/processing/services/soundcloud.js
+++ b/api/src/processing/services/soundcloud.js
@@ -113,9 +113,16 @@ export default async function(obj) {
if (!file) return { error: "fetch.empty" };
+ const artist = json.user?.username?.trim();
const fileMetadata = {
- title: json.title.trim(),
- artist: json.user.username.trim(),
+ title: json.title?.trim(),
+ album: json.publisher_metadata?.album_title?.trim(),
+ artist,
+ album_artist: artist,
+ composer: json.publisher_metadata?.writer_composer?.trim(),
+ genre: json.genre?.trim(),
+ date: json.display_date?.trim().slice(0, 10),
+ copyright: json.license?.trim(),
}
return {
diff --git a/api/src/stream/types.js b/api/src/stream/types.js
index 1e270df8..6b493efa 100644
--- a/api/src/stream/types.js
+++ b/api/src/stream/types.js
@@ -17,9 +17,12 @@ const ffmpegArgs = {
const metadataTags = [
"album",
+ "composer",
+ "genre",
"copyright",
"title",
"artist",
+ "album_artist",
"track",
"date",
];
diff --git a/docs/api.md b/docs/api.md
index ac536380..f093e148 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -129,14 +129,17 @@ the response will always be a JSON object containing the `status` key, which is
#### output.metadata object
all keys in this table are optional.
-| key | type | description |
-|:------------|:---------|:-------------------------------------------|
-| `album` | `string` | album name or collection title |
-| `copyright` | `string` | copyright information or ownership details |
-| `title` | `string` | title of the track or media file |
-| `artist` | `string` | artist or creator name |
-| `track` | `string` | track number or position in album |
-| `date` | `string` | release date or creation date |
+| key | type | description |
+|:---------------|:---------|:-------------------------------------------|
+| `album` | `string` | album name or collection title |
+| `composer` | `string` | composer of the track |
+| `genre` | `string` | track's genre(s) |
+| `copyright` | `string` | copyright information or ownership details |
+| `title` | `string` | title of the track or media file |
+| `artist` | `string` | artist or creator name |
+| `album_artist` | `string` | album's artist or creator name |
+| `track` | `string` | track number or position in album |
+| `date` | `string` | release date or creation date |
#### audio object
| key | type | value |
diff --git a/web/src/lib/types/api.ts b/web/src/lib/types/api.ts
index 6e030856..13d2b8b7 100644
--- a/web/src/lib/types/api.ts
+++ b/web/src/lib/types/api.ts
@@ -45,9 +45,12 @@ type CobaltTunnelResponse = {
export const CobaltFileMetadataKeys = [
'album',
+ 'composer',
+ 'genre',
'copyright',
'title',
'artist',
+ 'album_artist',
'track',
'date'
];