Skip to content

Commit 5d2413f

Browse files
committed
fix(SoundCloud): Preserve credited track artist & Ignore preview lengths
1 parent 2c284c8 commit 5d2413f

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

providers/SoundCloud/api_types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ export interface SoundcloudTrack {
9292
user_favorite: boolean | null;
9393
user_playback_count: number | null;
9494
favoritings_count: number;
95-
access: string;
95+
access: 'playable' | 'preview' | 'blocked' | string;
96+
/** Artist credit, may contain featured artists. */
9697
metadata_artist: string;
9798
}
9899

providers/SoundCloud/mod.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ export class SoundCloudReleaseLookup extends ReleaseLookup<SoundCloudProvider, R
243243
const rawTrack = rawRelease;
244244
const release: HarmonyRelease = {
245245
title: rawTrack.title,
246-
artists: [this.makeArtistCredit(rawTrack.user)],
246+
artists: this.makeArtistCredit(rawTrack.user, rawRelease.metadata_artist),
247247
externalLinks: [{
248248
url: releaseUrl.href,
249249
types: this.getLinkTypes(rawTrack),
@@ -279,7 +279,7 @@ export class SoundCloudReleaseLookup extends ReleaseLookup<SoundCloudProvider, R
279279
}
280280
const release: HarmonyRelease = {
281281
title: rawRelease.title,
282-
artists: [this.makeArtistCredit(rawRelease.user)],
282+
artists: this.makeArtistCredit(rawRelease.user),
283283
externalLinks: [{
284284
url: releaseUrl.href,
285285
types: this.getLinkTypes(rawRelease),
@@ -389,8 +389,9 @@ export class SoundCloudReleaseLookup extends ReleaseLookup<SoundCloudProvider, R
389389
return {
390390
number: trackNumber,
391391
title: rawTrack.title,
392-
artists: [this.makeArtistCredit(rawTrack.user)],
393-
length: rawTrack.duration,
392+
artists: this.makeArtistCredit(rawTrack.user, rawTrack.metadata_artist),
393+
// API returns a constant track length (30s) for previews.
394+
length: rawTrack.access !== 'preview' ? rawTrack.duration : undefined,
394395
isrc: rawTrack.isrc || undefined,
395396
availableIn: this.getCountryCodes(rawTrack),
396397
recording: {
@@ -406,11 +407,12 @@ export class SoundCloudReleaseLookup extends ReleaseLookup<SoundCloudProvider, R
406407
return undefined;
407408
}
408409

409-
makeArtistCredit(user: SoundcloudUser): ArtistCreditName {
410-
return {
410+
makeArtistCredit(user: SoundcloudUser, artists?: string): ArtistCreditName[] {
411+
// TODO: Split off featured artists from artists string
412+
return [{
411413
name: user.username,
412-
creditedName: user.username,
414+
creditedName: artists ?? user.username,
413415
externalIds: this.provider.makeExternalIdsFromUrl(user.permalink_url),
414-
};
416+
}];
415417
}
416418
}

0 commit comments

Comments
 (0)