mirror of
https://github.com/antebudimir/feishin.git
synced 2025-12-31 10:03:33 +00:00
feat: Add explicit status for Navidrome and OpenSubsonic (#1220)
* add navidrome explicit status * add ExplicitStatus enum and support opensubsonic * add explicit status to cards
This commit is contained in:
parent
68f242d208
commit
4dd52b0cef
16 changed files with 131 additions and 10 deletions
|
|
@ -24,6 +24,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"common": {
|
"common": {
|
||||||
|
"explicitStatus": "explicit status",
|
||||||
"action_one": "action",
|
"action_one": "action",
|
||||||
"action_other": "actions",
|
"action_other": "actions",
|
||||||
"add": "add",
|
"add": "add",
|
||||||
|
|
@ -120,7 +121,9 @@
|
||||||
"unknown": "unknown",
|
"unknown": "unknown",
|
||||||
"version": "version",
|
"version": "version",
|
||||||
"year": "year",
|
"year": "year",
|
||||||
"yes": "yes"
|
"yes": "yes",
|
||||||
|
"explicit": "explicit",
|
||||||
|
"clean": "clean"
|
||||||
},
|
},
|
||||||
"entity": {
|
"entity": {
|
||||||
"album_one": "album",
|
"album_one": "album",
|
||||||
|
|
@ -227,7 +230,8 @@
|
||||||
"songCount": "song count",
|
"songCount": "song count",
|
||||||
"title": "title",
|
"title": "title",
|
||||||
"toYear": "to year",
|
"toYear": "to year",
|
||||||
"trackNumber": "track"
|
"trackNumber": "track",
|
||||||
|
"explicitStatus": "$t(common.explicitStatus)"
|
||||||
},
|
},
|
||||||
"form": {
|
"form": {
|
||||||
"addServer": {
|
"addServer": {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ const ALBUM_LIST_SORT_MAPPING: Record<AlbumListSort, AlbumListSortType | undefin
|
||||||
[AlbumListSort.COMMUNITY_RATING]: undefined,
|
[AlbumListSort.COMMUNITY_RATING]: undefined,
|
||||||
[AlbumListSort.CRITIC_RATING]: undefined,
|
[AlbumListSort.CRITIC_RATING]: undefined,
|
||||||
[AlbumListSort.DURATION]: undefined,
|
[AlbumListSort.DURATION]: undefined,
|
||||||
|
[AlbumListSort.EXPLICIT_STATUS]: undefined,
|
||||||
[AlbumListSort.FAVORITED]: AlbumListSortType.STARRED,
|
[AlbumListSort.FAVORITED]: AlbumListSortType.STARRED,
|
||||||
[AlbumListSort.NAME]: AlbumListSortType.ALPHABETICAL_BY_NAME,
|
[AlbumListSort.NAME]: AlbumListSortType.ALPHABETICAL_BY_NAME,
|
||||||
[AlbumListSort.PLAY_COUNT]: AlbumListSortType.FREQUENT,
|
[AlbumListSort.PLAY_COUNT]: AlbumListSortType.FREQUENT,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import formatDuration from 'format-duration';
|
import formatDuration from 'format-duration';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
import { generatePath } from 'react-router';
|
import { generatePath } from 'react-router';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
|
|
@ -9,7 +10,14 @@ import styles from './card-rows.module.css';
|
||||||
import { AppRoute } from '/@/renderer/router/routes';
|
import { AppRoute } from '/@/renderer/router/routes';
|
||||||
import { formatDateAbsolute, formatDateRelative, formatRating } from '/@/renderer/utils/format';
|
import { formatDateAbsolute, formatDateRelative, formatRating } from '/@/renderer/utils/format';
|
||||||
import { Text } from '/@/shared/components/text/text';
|
import { Text } from '/@/shared/components/text/text';
|
||||||
import { Album, AlbumArtist, Artist, Playlist, Song } from '/@/shared/types/domain-types';
|
import {
|
||||||
|
Album,
|
||||||
|
AlbumArtist,
|
||||||
|
Artist,
|
||||||
|
ExplicitStatus,
|
||||||
|
Playlist,
|
||||||
|
Song,
|
||||||
|
} from '/@/shared/types/domain-types';
|
||||||
import { CardRow } from '/@/shared/types/types';
|
import { CardRow } from '/@/shared/types/types';
|
||||||
|
|
||||||
interface CardRowsProps {
|
interface CardRowsProps {
|
||||||
|
|
@ -18,6 +26,8 @@ interface CardRowsProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CardRows = ({ data, rows }: CardRowsProps) => {
|
export const CardRows = ({ data, rows }: CardRowsProps) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{rows.map((row, index: number) => {
|
{rows.map((row, index: number) => {
|
||||||
|
|
@ -66,7 +76,7 @@ export const CardRows = ({ data, rows }: CardRowsProps) => {
|
||||||
>
|
>
|
||||||
{row.arrayProperty &&
|
{row.arrayProperty &&
|
||||||
(row.format
|
(row.format
|
||||||
? row.format(item)
|
? row.format(item, t)
|
||||||
: item[row.arrayProperty])}
|
: item[row.arrayProperty])}
|
||||||
</Text>
|
</Text>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
|
|
@ -92,7 +102,9 @@ export const CardRows = ({ data, rows }: CardRowsProps) => {
|
||||||
size={index > 0 ? 'sm' : 'md'}
|
size={index > 0 ? 'sm' : 'md'}
|
||||||
>
|
>
|
||||||
{row.arrayProperty &&
|
{row.arrayProperty &&
|
||||||
(row.format ? row.format(item) : item[row.arrayProperty])}
|
(row.format
|
||||||
|
? row.format(item, t)
|
||||||
|
: item[row.arrayProperty])}
|
||||||
</Text>
|
</Text>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -123,7 +135,7 @@ export const CardRows = ({ data, rows }: CardRowsProps) => {
|
||||||
}, {}),
|
}, {}),
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{data && (row.format ? row.format(data) : data[row.property])}
|
{data && (row.format ? row.format(data, t) : data[row.property])}
|
||||||
</Text>
|
</Text>
|
||||||
) : (
|
) : (
|
||||||
<Text
|
<Text
|
||||||
|
|
@ -132,7 +144,7 @@ export const CardRows = ({ data, rows }: CardRowsProps) => {
|
||||||
overflow="hidden"
|
overflow="hidden"
|
||||||
size={index > 0 ? 'sm' : 'md'}
|
size={index > 0 ? 'sm' : 'md'}
|
||||||
>
|
>
|
||||||
{data && (row.format ? row.format(data) : data[row.property])}
|
{data && (row.format ? row.format(data, t) : data[row.property])}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -167,6 +179,15 @@ export const ALBUM_CARD_ROWS: { [key: string]: CardRow<Album> } = {
|
||||||
format: (album) => (album.duration === null ? null : formatDuration(album.duration)),
|
format: (album) => (album.duration === null ? null : formatDuration(album.duration)),
|
||||||
property: 'duration',
|
property: 'duration',
|
||||||
},
|
},
|
||||||
|
explicitStatus: {
|
||||||
|
format: (album, t) =>
|
||||||
|
album.explicitStatus === ExplicitStatus.EXPLICIT
|
||||||
|
? t('common.explicit', { postProcess: 'sentenceCase' })
|
||||||
|
: album.explicitStatus === ExplicitStatus.CLEAN
|
||||||
|
? t('common.clean', { postProcess: 'sentenceCase' })
|
||||||
|
: null,
|
||||||
|
property: 'explicitStatus',
|
||||||
|
},
|
||||||
lastPlayedAt: {
|
lastPlayedAt: {
|
||||||
format: (album) => formatDateRelative(album.lastPlayedAt),
|
format: (album) => formatDateRelative(album.lastPlayedAt),
|
||||||
property: 'lastPlayedAt',
|
property: 'lastPlayedAt',
|
||||||
|
|
@ -228,6 +249,15 @@ export const SONG_CARD_ROWS: { [key: string]: CardRow<Song> } = {
|
||||||
format: (song) => (song.duration === null ? null : formatDuration(song.duration)),
|
format: (song) => (song.duration === null ? null : formatDuration(song.duration)),
|
||||||
property: 'duration',
|
property: 'duration',
|
||||||
},
|
},
|
||||||
|
explicitStatus: {
|
||||||
|
format: (song, t) =>
|
||||||
|
song.explicitStatus === ExplicitStatus.EXPLICIT
|
||||||
|
? t('common.explicit', { postProcess: 'sentenceCase' })
|
||||||
|
: song.explicitStatus === ExplicitStatus.CLEAN
|
||||||
|
? t('common.clean', { postProcess: 'sentenceCase' })
|
||||||
|
: null,
|
||||||
|
property: 'explicitStatus',
|
||||||
|
},
|
||||||
lastPlayedAt: {
|
lastPlayedAt: {
|
||||||
format: (song) => formatDateRelative(song.lastPlayedAt),
|
format: (song) => formatDateRelative(song.lastPlayedAt),
|
||||||
property: 'lastPlayedAt',
|
property: 'lastPlayedAt',
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,10 @@ export const AlbumListGridView = ({ gridRef, itemCount }: any) => {
|
||||||
rows.push(ALBUM_CARD_ROWS.albumArtists);
|
rows.push(ALBUM_CARD_ROWS.albumArtists);
|
||||||
rows.push(ALBUM_CARD_ROWS.duration);
|
rows.push(ALBUM_CARD_ROWS.duration);
|
||||||
break;
|
break;
|
||||||
|
case AlbumListSort.EXPLICIT_STATUS:
|
||||||
|
rows.push(ALBUM_CARD_ROWS.albumArtists);
|
||||||
|
rows.push(ALBUM_CARD_ROWS.explicitStatus);
|
||||||
|
break;
|
||||||
case AlbumListSort.FAVORITED:
|
case AlbumListSort.FAVORITED:
|
||||||
rows.push(ALBUM_CARD_ROWS.albumArtists);
|
rows.push(ALBUM_CARD_ROWS.albumArtists);
|
||||||
rows.push(ALBUM_CARD_ROWS.releaseYear);
|
rows.push(ALBUM_CARD_ROWS.releaseYear);
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,11 @@ const FILTERS = {
|
||||||
name: i18n.t('filter.duration', { postProcess: 'titleCase' }),
|
name: i18n.t('filter.duration', { postProcess: 'titleCase' }),
|
||||||
value: AlbumListSort.DURATION,
|
value: AlbumListSort.DURATION,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
defaultOrder: SortOrder.DESC,
|
||||||
|
name: i18n.t('filter.explicitStatus', { postProcess: 'titleCase' }),
|
||||||
|
value: AlbumListSort.EXPLICIT_STATUS,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
defaultOrder: SortOrder.DESC,
|
defaultOrder: SortOrder.DESC,
|
||||||
name: i18n.t('filter.mostPlayed', { postProcess: 'titleCase' }),
|
name: i18n.t('filter.mostPlayed', { postProcess: 'titleCase' }),
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import { Separator } from '/@/shared/components/separator/separator';
|
||||||
import { Spoiler } from '/@/shared/components/spoiler/spoiler';
|
import { Spoiler } from '/@/shared/components/spoiler/spoiler';
|
||||||
import { Table } from '/@/shared/components/table/table';
|
import { Table } from '/@/shared/components/table/table';
|
||||||
import { Text } from '/@/shared/components/text/text';
|
import { Text } from '/@/shared/components/text/text';
|
||||||
|
import { ExplicitStatus } from '/@/shared/types/domain-types';
|
||||||
import {
|
import {
|
||||||
Album,
|
Album,
|
||||||
AlbumArtist,
|
AlbumArtist,
|
||||||
|
|
@ -34,14 +35,14 @@ type ItemDetailRow<T> = {
|
||||||
key?: keyof T;
|
key?: keyof T;
|
||||||
label: string;
|
label: string;
|
||||||
postprocess?: string[];
|
postprocess?: string[];
|
||||||
render?: (item: T) => ReactNode;
|
render?: (item: T, t: TFunction) => ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRow = <T extends AnyLibraryItem>(t: TFunction, item: T, rule: ItemDetailRow<T>) => {
|
const handleRow = <T extends AnyLibraryItem>(t: TFunction, item: T, rule: ItemDetailRow<T>) => {
|
||||||
let value: ReactNode;
|
let value: ReactNode;
|
||||||
|
|
||||||
if (rule.render) {
|
if (rule.render) {
|
||||||
value = rule.render(item);
|
value = rule.render(item, t);
|
||||||
} else {
|
} else {
|
||||||
const prop = item[rule.key!];
|
const prop = item[rule.key!];
|
||||||
value = prop !== undefined && prop !== null ? String(prop) : null;
|
value = prop !== undefined && prop !== null ? String(prop) : null;
|
||||||
|
|
@ -128,6 +129,15 @@ const AlbumPropertyMapping: ItemDetailRow<Album>[] = [
|
||||||
},
|
},
|
||||||
{ key: 'releaseYear', label: 'filter.releaseYear' },
|
{ key: 'releaseYear', label: 'filter.releaseYear' },
|
||||||
{ key: 'songCount', label: 'filter.songCount' },
|
{ key: 'songCount', label: 'filter.songCount' },
|
||||||
|
{
|
||||||
|
label: 'filter.explicitStatus',
|
||||||
|
render: (album, t) =>
|
||||||
|
album.explicitStatus === ExplicitStatus.EXPLICIT
|
||||||
|
? t('common.explicit', { postProcess: 'sentenceCase' })
|
||||||
|
: album.explicitStatus === ExplicitStatus.CLEAN
|
||||||
|
? t('common.clean', { postProcess: 'sentenceCase' })
|
||||||
|
: null,
|
||||||
|
},
|
||||||
{ label: 'filter.isCompilation', render: (album) => BoolField(album.isCompilation || false) },
|
{ label: 'filter.isCompilation', render: (album) => BoolField(album.isCompilation || false) },
|
||||||
{
|
{
|
||||||
key: 'size',
|
key: 'size',
|
||||||
|
|
@ -266,6 +276,15 @@ const SongPropertyMapping: ItemDetailRow<Song>[] = [
|
||||||
{ key: 'discNumber', label: 'common.disc' },
|
{ key: 'discNumber', label: 'common.disc' },
|
||||||
{ key: 'trackNumber', label: 'common.trackNumber' },
|
{ key: 'trackNumber', label: 'common.trackNumber' },
|
||||||
{ key: 'releaseYear', label: 'filter.releaseYear' },
|
{ key: 'releaseYear', label: 'filter.releaseYear' },
|
||||||
|
{
|
||||||
|
label: 'filter.explicitStatus',
|
||||||
|
render: (song, t) =>
|
||||||
|
song.explicitStatus === ExplicitStatus.EXPLICIT
|
||||||
|
? t('common.explicit', { postProcess: 'sentenceCase' })
|
||||||
|
: song.explicitStatus === ExplicitStatus.CLEAN
|
||||||
|
? t('common.clean', { postProcess: 'sentenceCase' })
|
||||||
|
: null,
|
||||||
|
},
|
||||||
{ label: 'entity.genre_other', render: FormatGenre },
|
{ label: 'entity.genre_other', render: FormatGenre },
|
||||||
{
|
{
|
||||||
label: 'common.duration',
|
label: 'common.duration',
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,9 @@ export const SongListGridView = ({ gridRef, itemCount }: SongListGridViewProps)
|
||||||
case SongListSort.DURATION:
|
case SongListSort.DURATION:
|
||||||
rows.push(SONG_CARD_ROWS.duration);
|
rows.push(SONG_CARD_ROWS.duration);
|
||||||
break;
|
break;
|
||||||
|
case SongListSort.EXPLICIT_STATUS:
|
||||||
|
rows.push(SONG_CARD_ROWS.explicitStatus);
|
||||||
|
break;
|
||||||
case SongListSort.FAVORITED:
|
case SongListSort.FAVORITED:
|
||||||
break;
|
break;
|
||||||
case SongListSort.NAME:
|
case SongListSort.NAME:
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,11 @@ const FILTERS = {
|
||||||
name: i18n.t('filter.duration', { postProcess: 'titleCase' }),
|
name: i18n.t('filter.duration', { postProcess: 'titleCase' }),
|
||||||
value: SongListSort.DURATION,
|
value: SongListSort.DURATION,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
defaultOrder: SortOrder.DESC,
|
||||||
|
name: i18n.t('filter.explicitStatus', { postProcess: 'titleCase' }),
|
||||||
|
value: SongListSort.EXPLICIT_STATUS,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
defaultOrder: SortOrder.DESC,
|
defaultOrder: SortOrder.DESC,
|
||||||
name: i18n.t('filter.isFavorited', { postProcess: 'titleCase' }),
|
name: i18n.t('filter.isFavorited', { postProcess: 'titleCase' }),
|
||||||
|
|
|
||||||
|
|
@ -245,6 +245,7 @@ const normalizeSong = (
|
||||||
discNumber: (item.ParentIndexNumber && item.ParentIndexNumber) || 1,
|
discNumber: (item.ParentIndexNumber && item.ParentIndexNumber) || 1,
|
||||||
discSubtitle: null,
|
discSubtitle: null,
|
||||||
duration: item.RunTimeTicks / 10000,
|
duration: item.RunTimeTicks / 10000,
|
||||||
|
explicitStatus: null,
|
||||||
gain:
|
gain:
|
||||||
item.NormalizationGain !== undefined
|
item.NormalizationGain !== undefined
|
||||||
? {
|
? {
|
||||||
|
|
@ -317,6 +318,7 @@ const normalizeAlbum = (
|
||||||
comment: null,
|
comment: null,
|
||||||
createdAt: item.DateCreated,
|
createdAt: item.DateCreated,
|
||||||
duration: item.RunTimeTicks / 10000,
|
duration: item.RunTimeTicks / 10000,
|
||||||
|
explicitStatus: null,
|
||||||
genres: item.GenreItems?.map((entry) => ({
|
genres: item.GenreItems?.map((entry) => ({
|
||||||
id: entry.Id,
|
id: entry.Id,
|
||||||
imageUrl: null,
|
imageUrl: null,
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ export enum NDAlbumListSort {
|
||||||
ALBUM_ARTIST = 'album_artist',
|
ALBUM_ARTIST = 'album_artist',
|
||||||
ARTIST = 'artist',
|
ARTIST = 'artist',
|
||||||
DURATION = 'duration',
|
DURATION = 'duration',
|
||||||
|
EXPLICIT_STATUS = 'explicitStatus',
|
||||||
NAME = 'name',
|
NAME = 'name',
|
||||||
PLAY_COUNT = 'play_count',
|
PLAY_COUNT = 'play_count',
|
||||||
PLAY_DATE = 'play_date',
|
PLAY_DATE = 'play_date',
|
||||||
|
|
@ -46,6 +47,7 @@ export enum NDSongListSort {
|
||||||
CHANNELS = 'channels',
|
CHANNELS = 'channels',
|
||||||
COMMENT = 'comment',
|
COMMENT = 'comment',
|
||||||
DURATION = 'duration',
|
DURATION = 'duration',
|
||||||
|
EXPLICIT_STATUS = 'explicitStatus',
|
||||||
FAVORITED = 'starred_at',
|
FAVORITED = 'starred_at',
|
||||||
GENRE = 'genre',
|
GENRE = 'genre',
|
||||||
ID = 'id',
|
ID = 'id',
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import { ssType } from '/@/shared/api/subsonic/subsonic-types';
|
||||||
import {
|
import {
|
||||||
Album,
|
Album,
|
||||||
AlbumArtist,
|
AlbumArtist,
|
||||||
|
ExplicitStatus,
|
||||||
Genre,
|
Genre,
|
||||||
LibraryItem,
|
LibraryItem,
|
||||||
Playlist,
|
Playlist,
|
||||||
|
|
@ -164,6 +165,12 @@ const normalizeSong = (
|
||||||
discNumber: item.discNumber,
|
discNumber: item.discNumber,
|
||||||
discSubtitle: item.discSubtitle ? item.discSubtitle : null,
|
discSubtitle: item.discSubtitle ? item.discSubtitle : null,
|
||||||
duration: item.duration * 1000,
|
duration: item.duration * 1000,
|
||||||
|
explicitStatus:
|
||||||
|
item.explicitStatus === 'e'
|
||||||
|
? ExplicitStatus.EXPLICIT
|
||||||
|
: item.explicitStatus === 'c'
|
||||||
|
? ExplicitStatus.CLEAN
|
||||||
|
: null,
|
||||||
gain:
|
gain:
|
||||||
item.rgAlbumGain || item.rgTrackGain
|
item.rgAlbumGain || item.rgTrackGain
|
||||||
? { album: item.rgAlbumGain, track: item.rgTrackGain }
|
? { album: item.rgAlbumGain, track: item.rgTrackGain }
|
||||||
|
|
@ -237,6 +244,12 @@ const normalizeAlbum = (
|
||||||
comment: item.comment || null,
|
comment: item.comment || null,
|
||||||
createdAt: item.createdAt.split('T')[0],
|
createdAt: item.createdAt.split('T')[0],
|
||||||
duration: item.duration !== undefined ? item.duration * 1000 : null,
|
duration: item.duration !== undefined ? item.duration * 1000 : null,
|
||||||
|
explicitStatus:
|
||||||
|
item.explicitStatus === 'e'
|
||||||
|
? ExplicitStatus.EXPLICIT
|
||||||
|
: item.explicitStatus === 'c'
|
||||||
|
? ExplicitStatus.CLEAN
|
||||||
|
: null,
|
||||||
genres: (item.genres || []).map((genre) => ({
|
genres: (item.genres || []).map((genre) => ({
|
||||||
id: genre.id,
|
id: genre.id,
|
||||||
imageUrl: null,
|
imageUrl: null,
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,7 @@ const album = z.object({
|
||||||
coverArtPath: z.string().optional(), // Removed after v0.48.0
|
coverArtPath: z.string().optional(), // Removed after v0.48.0
|
||||||
createdAt: z.string(),
|
createdAt: z.string(),
|
||||||
duration: z.number().optional(),
|
duration: z.number().optional(),
|
||||||
|
explicitStatus: z.string().optional(),
|
||||||
fullText: z.string(),
|
fullText: z.string(),
|
||||||
genre: z.string(),
|
genre: z.string(),
|
||||||
genres: z.array(genre).nullable(),
|
genres: z.array(genre).nullable(),
|
||||||
|
|
@ -200,6 +201,7 @@ const song = z.object({
|
||||||
discSubtitle: z.string().optional(),
|
discSubtitle: z.string().optional(),
|
||||||
duration: z.number(),
|
duration: z.number(),
|
||||||
embedArtPath: z.string().optional(),
|
embedArtPath: z.string().optional(),
|
||||||
|
explicitStatus: z.string().optional(),
|
||||||
externalInfoUpdatedAt: z.string().optional(),
|
externalInfoUpdatedAt: z.string().optional(),
|
||||||
externalUrl: z.string().optional(),
|
externalUrl: z.string().optional(),
|
||||||
fullText: z.string(),
|
fullText: z.string(),
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { ssType } from '/@/shared/api/subsonic/subsonic-types';
|
||||||
import {
|
import {
|
||||||
Album,
|
Album,
|
||||||
AlbumArtist,
|
AlbumArtist,
|
||||||
|
ExplicitStatus,
|
||||||
Genre,
|
Genre,
|
||||||
LibraryItem,
|
LibraryItem,
|
||||||
Playlist,
|
Playlist,
|
||||||
|
|
@ -146,6 +147,12 @@ const normalizeSong = (
|
||||||
discNumber: item.discNumber || 1,
|
discNumber: item.discNumber || 1,
|
||||||
discSubtitle: null,
|
discSubtitle: null,
|
||||||
duration: item.duration ? item.duration * 1000 : 0,
|
duration: item.duration ? item.duration * 1000 : 0,
|
||||||
|
explicitStatus:
|
||||||
|
item.explicitStatus === 'explicit'
|
||||||
|
? ExplicitStatus.EXPLICIT
|
||||||
|
: item.explicitStatus === 'clean'
|
||||||
|
? ExplicitStatus.CLEAN
|
||||||
|
: null,
|
||||||
gain:
|
gain:
|
||||||
item.replayGain && (item.replayGain.albumGain || item.replayGain.trackGain)
|
item.replayGain && (item.replayGain.albumGain || item.replayGain.trackGain)
|
||||||
? {
|
? {
|
||||||
|
|
@ -247,6 +254,12 @@ const normalizeAlbum = (
|
||||||
comment: null,
|
comment: null,
|
||||||
createdAt: item.created,
|
createdAt: item.created,
|
||||||
duration: item.duration * 1000,
|
duration: item.duration * 1000,
|
||||||
|
explicitStatus:
|
||||||
|
item.explicitStatus === 'explicit'
|
||||||
|
? ExplicitStatus.EXPLICIT
|
||||||
|
: item.explicitStatus === 'clean'
|
||||||
|
? ExplicitStatus.CLEAN
|
||||||
|
: null,
|
||||||
genres: getGenres(item),
|
genres: getGenres(item),
|
||||||
id: item.id.toString(),
|
id: item.id.toString(),
|
||||||
imagePlaceholderUrl: null,
|
imagePlaceholderUrl: null,
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,7 @@ const song = z.object({
|
||||||
created: z.string(),
|
created: z.string(),
|
||||||
discNumber: z.number(),
|
discNumber: z.number(),
|
||||||
duration: z.number().optional(),
|
duration: z.number().optional(),
|
||||||
|
explicitStatus: z.string().optional(),
|
||||||
genre: z.string().optional(),
|
genre: z.string().optional(),
|
||||||
genres: z.array(genreItem).optional(),
|
genres: z.array(genreItem).optional(),
|
||||||
id,
|
id,
|
||||||
|
|
@ -125,6 +126,7 @@ const album = z.object({
|
||||||
coverArt: z.string(),
|
coverArt: z.string(),
|
||||||
created: z.string(),
|
created: z.string(),
|
||||||
duration: z.number(),
|
duration: z.number(),
|
||||||
|
explicitStatus: z.string().optional(),
|
||||||
genre: z.string().optional(),
|
genre: z.string().optional(),
|
||||||
genres: z.array(genreItem).optional(),
|
genres: z.array(genreItem).optional(),
|
||||||
id,
|
id,
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,11 @@ export const sortOrderMap: SortOrderMap = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export enum ExplicitStatus {
|
||||||
|
CLEAN = 'CLEAN',
|
||||||
|
EXPLICIT = 'EXPLICIT',
|
||||||
|
}
|
||||||
|
|
||||||
export enum ExternalSource {
|
export enum ExternalSource {
|
||||||
LASTFM = 'LASTFM',
|
LASTFM = 'LASTFM',
|
||||||
MUSICBRAINZ = 'MUSICBRAINZ',
|
MUSICBRAINZ = 'MUSICBRAINZ',
|
||||||
|
|
@ -160,6 +165,7 @@ export type Album = {
|
||||||
comment: null | string;
|
comment: null | string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
duration: null | number;
|
duration: null | number;
|
||||||
|
explicitStatus: ExplicitStatus | null;
|
||||||
genres: Genre[];
|
genres: Genre[];
|
||||||
id: string;
|
id: string;
|
||||||
imagePlaceholderUrl: null | string;
|
imagePlaceholderUrl: null | string;
|
||||||
|
|
@ -332,6 +338,7 @@ export type Song = {
|
||||||
discNumber: number;
|
discNumber: number;
|
||||||
discSubtitle: null | string;
|
discSubtitle: null | string;
|
||||||
duration: number;
|
duration: number;
|
||||||
|
explicitStatus: ExplicitStatus | null;
|
||||||
gain: GainInfo | null;
|
gain: GainInfo | null;
|
||||||
genres: Genre[];
|
genres: Genre[];
|
||||||
id: string;
|
id: string;
|
||||||
|
|
@ -394,6 +401,7 @@ export enum AlbumListSort {
|
||||||
COMMUNITY_RATING = 'communityRating',
|
COMMUNITY_RATING = 'communityRating',
|
||||||
CRITIC_RATING = 'criticRating',
|
CRITIC_RATING = 'criticRating',
|
||||||
DURATION = 'duration',
|
DURATION = 'duration',
|
||||||
|
EXPLICIT_STATUS = 'explicitStatus',
|
||||||
FAVORITED = 'favorited',
|
FAVORITED = 'favorited',
|
||||||
NAME = 'name',
|
NAME = 'name',
|
||||||
PLAY_COUNT = 'playCount',
|
PLAY_COUNT = 'playCount',
|
||||||
|
|
@ -441,6 +449,7 @@ export const albumListSortMap: AlbumListSortMap = {
|
||||||
communityRating: JFAlbumListSort.COMMUNITY_RATING,
|
communityRating: JFAlbumListSort.COMMUNITY_RATING,
|
||||||
criticRating: JFAlbumListSort.CRITIC_RATING,
|
criticRating: JFAlbumListSort.CRITIC_RATING,
|
||||||
duration: undefined,
|
duration: undefined,
|
||||||
|
explicitStatus: undefined,
|
||||||
favorited: undefined,
|
favorited: undefined,
|
||||||
name: JFAlbumListSort.NAME,
|
name: JFAlbumListSort.NAME,
|
||||||
playCount: JFAlbumListSort.PLAY_COUNT,
|
playCount: JFAlbumListSort.PLAY_COUNT,
|
||||||
|
|
@ -458,6 +467,7 @@ export const albumListSortMap: AlbumListSortMap = {
|
||||||
communityRating: undefined,
|
communityRating: undefined,
|
||||||
criticRating: undefined,
|
criticRating: undefined,
|
||||||
duration: NDAlbumListSort.DURATION,
|
duration: NDAlbumListSort.DURATION,
|
||||||
|
explicitStatus: NDAlbumListSort.EXPLICIT_STATUS,
|
||||||
favorited: NDAlbumListSort.STARRED,
|
favorited: NDAlbumListSort.STARRED,
|
||||||
name: NDAlbumListSort.NAME,
|
name: NDAlbumListSort.NAME,
|
||||||
playCount: NDAlbumListSort.PLAY_COUNT,
|
playCount: NDAlbumListSort.PLAY_COUNT,
|
||||||
|
|
@ -476,6 +486,7 @@ export const albumListSortMap: AlbumListSortMap = {
|
||||||
communityRating: undefined,
|
communityRating: undefined,
|
||||||
criticRating: undefined,
|
criticRating: undefined,
|
||||||
duration: undefined,
|
duration: undefined,
|
||||||
|
explicitStatus: undefined,
|
||||||
favorited: undefined,
|
favorited: undefined,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
playCount: undefined,
|
playCount: undefined,
|
||||||
|
|
@ -497,6 +508,7 @@ export enum SongListSort {
|
||||||
CHANNELS = 'channels',
|
CHANNELS = 'channels',
|
||||||
COMMENT = 'comment',
|
COMMENT = 'comment',
|
||||||
DURATION = 'duration',
|
DURATION = 'duration',
|
||||||
|
EXPLICIT_STATUS = 'explicitStatus',
|
||||||
FAVORITED = 'favorited',
|
FAVORITED = 'favorited',
|
||||||
GENRE = 'genre',
|
GENRE = 'genre',
|
||||||
ID = 'id',
|
ID = 'id',
|
||||||
|
|
@ -562,6 +574,7 @@ export const songListSortMap: SongListSortMap = {
|
||||||
channels: undefined,
|
channels: undefined,
|
||||||
comment: undefined,
|
comment: undefined,
|
||||||
duration: JFSongListSort.DURATION,
|
duration: JFSongListSort.DURATION,
|
||||||
|
explicitStatus: undefined,
|
||||||
favorited: undefined,
|
favorited: undefined,
|
||||||
genre: undefined,
|
genre: undefined,
|
||||||
id: undefined,
|
id: undefined,
|
||||||
|
|
@ -582,6 +595,7 @@ export const songListSortMap: SongListSortMap = {
|
||||||
channels: NDSongListSort.CHANNELS,
|
channels: NDSongListSort.CHANNELS,
|
||||||
comment: NDSongListSort.COMMENT,
|
comment: NDSongListSort.COMMENT,
|
||||||
duration: NDSongListSort.DURATION,
|
duration: NDSongListSort.DURATION,
|
||||||
|
explicitStatus: NDSongListSort.EXPLICIT_STATUS,
|
||||||
favorited: NDSongListSort.FAVORITED,
|
favorited: NDSongListSort.FAVORITED,
|
||||||
genre: NDSongListSort.GENRE,
|
genre: NDSongListSort.GENRE,
|
||||||
id: NDSongListSort.ID,
|
id: NDSongListSort.ID,
|
||||||
|
|
@ -602,6 +616,7 @@ export const songListSortMap: SongListSortMap = {
|
||||||
channels: undefined,
|
channels: undefined,
|
||||||
comment: undefined,
|
comment: undefined,
|
||||||
duration: undefined,
|
duration: undefined,
|
||||||
|
explicitStatus: undefined,
|
||||||
favorited: undefined,
|
favorited: undefined,
|
||||||
genre: undefined,
|
genre: undefined,
|
||||||
id: undefined,
|
id: undefined,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { AppRoute } from '@ts-rest/core';
|
import { AppRoute } from '@ts-rest/core';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
|
import { TFunction } from 'react-i18next';
|
||||||
import { Song } from 'src/main/features/core/lyrics/netease';
|
import { Song } from 'src/main/features/core/lyrics/netease';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|
@ -40,7 +41,7 @@ export type CardRoute = {
|
||||||
|
|
||||||
export type CardRow<T> = {
|
export type CardRow<T> = {
|
||||||
arrayProperty?: string;
|
arrayProperty?: string;
|
||||||
format?: (value: T) => ReactNode;
|
format?: (value: T, t: TFunction) => ReactNode;
|
||||||
property: keyof T;
|
property: keyof T;
|
||||||
route?: CardRoute;
|
route?: CardRoute;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue