Add "slug" field to Track and Album

This commit is contained in:
encode42 2024-12-08 18:07:29 -05:00
parent 48837d80fa
commit 8b14c2fa84
4 changed files with 14 additions and 1 deletions

View File

@ -96,6 +96,9 @@ export default class AlbumInfoParser {
const releaseUrl = normalizeUrl(release['@id'], album.url);
if (releaseUrl) {
releaseItem.url = releaseUrl;
const urlParts = releaseUrl.split('/');
releaseItem.slug = urlParts[urlParts.length - 1];
}
if (release.image) {
if (Array.isArray(release.image) && release.image[0]) {

View File

@ -60,14 +60,21 @@ export default class TrackInfoParser {
throw new ParseError('Failed to parse track info: invalid extra data');
}
const url = basic['@id'];
const track: Track = {
type: 'track',
name: basic.name,
description: basic.description.replaceAll('\r\n', '\n') || '',
url: basic['@id'],
url,
position: extra.current?.track_number
};
if (url) {
const urlParts = url.split('/');
url.slug = urlParts[urlParts.length - 1];
}
const imageUrl = reformatImageUrl(basic.image, opts.albumImageFormat);
if (imageUrl) {
track.imageUrl = imageUrl;

View File

@ -17,6 +17,7 @@ export interface AlbumRelease {
name: string;
format: string;
url?: string;
slug?: string;
imageUrl?: string;
description?: string;
}

View File

@ -4,6 +4,8 @@ import MediaKind from './MediaKind.js';
interface Track extends MediaKind {
type: 'track';
description?: string;
url?: string;
slug?: string;
duration?: number;
seekPosition?: number;
streamUrl?: string;