debug de l'application vue
This commit is contained in:
@@ -2,27 +2,32 @@
|
||||
* Service API pour interagir avec le cache de pistes audio
|
||||
*/
|
||||
|
||||
export interface AudioMetadata {
|
||||
export interface AudioCacheMetadata {
|
||||
origin_url?: string;
|
||||
title?: string;
|
||||
artist?: string;
|
||||
album?: string;
|
||||
year?: number;
|
||||
genre?: string;
|
||||
track_number?: number;
|
||||
track_total?: number;
|
||||
disc_number?: number;
|
||||
disc_total?: number;
|
||||
duration_ms?: number;
|
||||
duration_secs?: number;
|
||||
sample_rate?: number;
|
||||
bitrate?: number;
|
||||
channels?: number;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface AudioCacheEntry {
|
||||
pk: string;
|
||||
source_url: string;
|
||||
id: string | null;
|
||||
hits: number;
|
||||
last_used: string | null;
|
||||
collection?: string;
|
||||
metadata?: AudioMetadata;
|
||||
collection?: string | null;
|
||||
metadata?: AudioCacheMetadata | null;
|
||||
}
|
||||
|
||||
export interface AddTrackRequest {
|
||||
@@ -48,6 +53,28 @@ export interface ApiError {
|
||||
message: string;
|
||||
}
|
||||
|
||||
export function getOriginUrl(entry: AudioCacheEntry): string | undefined {
|
||||
const metadata = entry.metadata;
|
||||
if (metadata && typeof metadata === "object") {
|
||||
const origin = (metadata as { origin_url?: unknown }).origin_url;
|
||||
if (typeof origin === "string" && origin.trim().length > 0) {
|
||||
return origin;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function getDurationMs(metadata?: AudioCacheMetadata | null): number | undefined {
|
||||
if (!metadata) return undefined;
|
||||
if (typeof metadata.duration_ms === "number" && !Number.isNaN(metadata.duration_ms)) {
|
||||
return metadata.duration_ms;
|
||||
}
|
||||
if (typeof metadata.duration_secs === "number" && !Number.isNaN(metadata.duration_secs)) {
|
||||
return metadata.duration_secs * 1000;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Liste toutes les pistes en cache
|
||||
*/
|
||||
|
||||
@@ -2,11 +2,18 @@
|
||||
* Service API pour interagir avec le cache d'images de couvertures
|
||||
*/
|
||||
|
||||
export interface CacheMetadata {
|
||||
origin_url?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface CacheEntry {
|
||||
pk: string;
|
||||
source_url: string;
|
||||
id: string | null;
|
||||
collection?: string | null;
|
||||
hits: number;
|
||||
last_used: string | null;
|
||||
metadata?: CacheMetadata | null;
|
||||
}
|
||||
|
||||
export interface AddImageRequest {
|
||||
@@ -168,6 +175,17 @@ export async function waitForDownload(
|
||||
/**
|
||||
* Génère l'URL pour afficher une image
|
||||
*/
|
||||
export function getOriginUrl(entry: CacheEntry): string | undefined {
|
||||
const metadata = entry.metadata;
|
||||
if (metadata && typeof metadata === "object") {
|
||||
const origin = (metadata as { origin_url?: unknown }).origin_url;
|
||||
if (typeof origin === "string" && origin.trim().length > 0) {
|
||||
return origin;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function getImageUrl(pk: string, size?: number): string {
|
||||
if (size) {
|
||||
return `/covers/image/${pk}/${size}`;
|
||||
|
||||
Reference in New Issue
Block a user