Skip to content

Commit

Permalink
chore: Standardise on "length" for property names
Browse files Browse the repository at this point in the history
MusicBrainz recently switched from using a mix of "duration" and
"length" to just "length", so follow suit for consistency.
  • Loading branch information
atj committed May 9, 2024
1 parent fff3756 commit af99b6a
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion harmonizer/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ export const immutableReleaseProperties = [
/** Track properties which have to be taken from one provider and can not be combined from data of multiple providers. */
export const immutableTrackProperties = [
'isrc',
'duration',
'length',
] as const;
4 changes: 2 additions & 2 deletions harmonizer/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export type HarmonyTrack = {
title: string;
artists?: ArtistCredit;
number?: number | string;
/** Track duration in milliseconds. */
duration?: number;
/** Track length in milliseconds. */
length?: number;
isrc?: string;
availableIn?: CountryCode[];
};
Expand Down
2 changes: 1 addition & 1 deletion musicbrainz/seeding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function createReleaseSeed(release: HarmonyRelease, options: ReleaseSeedO
name: track.title,
artist_credit: convertArtistCredit(track.artists),
number: track.number?.toString(),
length: track.duration,
length: track.length,
})),
})),
language: release.language?.code,
Expand Down
2 changes: 1 addition & 1 deletion providers/Bandcamp/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export class BandcampReleaseLookup extends ReleaseLookup<BandcampProvider, Album
number: 'track_num' in rawTrack ? rawTrack.track_num : rawTrack.tracknum + 1,
title: rawTrack.title,
artists: rawTrack.artist ? [this.makeArtistCreditName(rawTrack.artist)] : undefined,
duration: rawTrack.duration * 1000,
length: rawTrack.duration * 1000,
};
}

Expand Down
2 changes: 1 addition & 1 deletion providers/Beatport/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class BeatportReleaseLookup extends ReleaseLookup<BeatportProvider, Relea
number: index + 1,
title: title,
artists: rawTrack.artists.map(this.makeArtistCreditName.bind(this)),
duration: rawTrack.length_ms,
length: rawTrack.length_ms,
isrc: rawTrack.isrc,
};
}
Expand Down
2 changes: 1 addition & 1 deletion providers/Deezer/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export class DeezerReleaseLookup extends ReleaseLookup<DeezerProvider, Release>
const result: HarmonyTrack = {
number: index + 1,
title: track.title,
duration: track.duration * 1000,
length: track.duration * 1000,
};

if ('isrc' in track) {
Expand Down
2 changes: 1 addition & 1 deletion providers/iTunes/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export class iTunesReleaseLookup extends ReleaseLookup<iTunesProvider, ReleaseRe
medium.tracklist.push({
number: track.trackNumber,
title,
duration: track.trackTimeMillis,
length: track.trackTimeMillis,
artists: [this.convertRawArtist(track.artistName, track.artistViewUrl)],
});
});
Expand Down
4 changes: 2 additions & 2 deletions providers/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export function constructEntityUrl(entityId: ExternalEntityId): URL {

/** Recommended default preferences which sort providers by quality. */
export const defaultProviderPreferences: ProviderPreferences = {
// get track durations from the provider with the highest precision
duration: sortProvidersByQuality('durationPrecision'),
// get track lengths from the provider with the highest precision
length: sortProvidersByQuality('durationPrecision'),
// get cover art from the provider with the highest quality (currently: image resolution)
images: sortProvidersByQuality('artworkQuality'),
// use region-specific external URLs last (TODO: derive this from provider properties)
Expand Down
4 changes: 2 additions & 2 deletions server/components/Tracklist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function Tracklist({ medium, showTitle = false }: Props) {
<th>Track</th>
<th>Title</th>
<th>Artists</th>
<th>Duration</th>
<th>Length</th>
<th>ISRC</th>
{medium.tracklist.some((track) => track.availableIn) && <th>Availability</th>}
</tr>
Expand All @@ -37,7 +37,7 @@ export function Tracklist({ medium, showTitle = false }: Props) {
<td class='numeric'>{track.number}</td>
<td>{track.title}</td>
<td>{track.artists && <ArtistCredit artists={track.artists} />}</td>
<td class='numeric'>{formatDuration(track.duration, { showMs: true })}</td>
<td class='numeric'>{formatDuration(track.length, { showMs: true })}</td>
<td>
{track.isrc && <ISRC code={track.isrc} />}
</td>
Expand Down

0 comments on commit af99b6a

Please sign in to comment.