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); const releaseUrl = normalizeUrl(release['@id'], album.url);
if (releaseUrl) { if (releaseUrl) {
releaseItem.url = releaseUrl; releaseItem.url = releaseUrl;
const urlParts = releaseUrl.split('/');
releaseItem.slug = urlParts[urlParts.length - 1];
} }
if (release.image) { if (release.image) {
if (Array.isArray(release.image) && release.image[0]) { 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'); throw new ParseError('Failed to parse track info: invalid extra data');
} }
const url = basic['@id'];
const track: Track = { const track: Track = {
type: 'track', type: 'track',
name: basic.name, name: basic.name,
description: basic.description.replaceAll('\r\n', '\n') || '', description: basic.description.replaceAll('\r\n', '\n') || '',
url: basic['@id'], url,
position: extra.current?.track_number position: extra.current?.track_number
}; };
if (url) {
const urlParts = url.split('/');
url.slug = urlParts[urlParts.length - 1];
}
const imageUrl = reformatImageUrl(basic.image, opts.albumImageFormat); const imageUrl = reformatImageUrl(basic.image, opts.albumImageFormat);
if (imageUrl) { if (imageUrl) {
track.imageUrl = imageUrl; track.imageUrl = imageUrl;

View File

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

View File

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