Added artist to the releases page & fixed the title cards not working 100% of the time & fixed Tags not being properly applied to search

pull/3800/merge^2
Anatole Sot 4 months ago
parent eb8c9ae892
commit f9b130c0d9

@ -5101,11 +5101,6 @@ paths:
schema:
type: string
example: 1,2
- in: query
name: sortBy
schema:
type: string
example: popularity.desc
responses:
'200':
description: Results
@ -5126,7 +5121,9 @@ paths:
results:
type: array
items:
$ref: '#/components/schemas/ReleaseResult'
anyOf:
- $ref: '#/components/schemas/ReleaseResult'
- $ref: '#/components/schemas/ArtistResult'
'500':
description: An error occured while getting musics
content:

@ -231,10 +231,12 @@ function processReleaseSearchParams(
offset: search.offset,
};
if (search.artistname) {
processedSearchParams.query += ` AND artist:${search.artistname}`;
processedSearchParams.query += ` AND artist:"${search.artistname}"`;
}
if (search.tags) {
processedSearchParams.query += ` AND tag:${search.tags.join(' AND tag:')}`;
processedSearchParams.query += ` AND tag:"${search.tags.join(
'" AND tag:"'
)}"`;
}
return processedSearchParams;
}
@ -248,7 +250,9 @@ function processArtistSearchParams(
offset: search.offset,
};
if (search.tags) {
processedSearchParams.query += ` AND tag:${search.tags.join(' AND tag:')}`;
processedSearchParams.query += ` AND tag:"${search.tags.join(
'" AND tag:"'
)}"`;
}
return processedSearchParams;
}

@ -2,9 +2,9 @@ import LidarrAPI from '@server/api/servarr/lidarr';
import { getSettings } from '@server/lib/settings';
import type { mbArtist, mbRelease, mbReleaseGroup } from './interfaces';
function getPosterFromMB(
async function getPosterFromMB(
element: mbRelease | mbReleaseGroup | mbArtist
): string | undefined {
): Promise<string | undefined> {
if (element.media_type === 'artist') {
const settings = getSettings();
const lidarrSettings = settings.lidarr.find((lidarr) => lidarr.isDefault);
@ -16,7 +16,7 @@ function getPosterFromMB(
url: LidarrAPI.buildUrl(lidarrSettings, '/api/v1'),
});
try {
const artist = (lidarr as LidarrAPI).getArtist(element.id);
const artist = await (lidarr as LidarrAPI).getArtist(element.id);
if (artist.images.find((i) => i.coverType === 'poster')?.url) {
return LidarrAPI.buildUrl(
lidarrSettings,
@ -43,7 +43,7 @@ async function getFanartFromMB(element: mbArtist): Promise<string | undefined> {
url: LidarrAPI.buildUrl(lidarrSettings, '/api/v1'),
});
try {
const artist = lidarr.getArtist(element.id);
const artist = await lidarr.getArtist(element.id);
return (
artist.images ?? [{ coverType: 'fanart', remoteUrl: undefined }]
).filter((i) => i.coverType === 'fanart')[0].remoteUrl;

@ -172,7 +172,7 @@ class LidarrAPI extends ServarrBase<{ musicId: number }> {
}
};
public getArtist = (id: string | number): LidarrArtist => {
public getArtist = async (id: string | number): Promise<LidarrArtist> => {
try {
if (LidarrAPI.lastArtistsUpdate < Date.now() - LidarrAPI.delay) {
this.getArtists();
@ -190,7 +190,11 @@ class LidarrAPI extends ServarrBase<{ musicId: number }> {
if (result) {
return result;
}
throw new Error(`Artist not found (using MusicBrainzId): ${id}`);
const artist = await this.getArtistByMusicBrainzId(id);
if (artist) {
return artist;
}
throw new Error(`Artist not found (using MusicBrainz Id): ${id}`);
} catch (e) {
throw new Error(`[Lidarr] ${e.message}`);
}

@ -286,7 +286,7 @@ export const mapReleaseGroupResult = async (
)
),
tags: releaseGroupResult.tags,
posterPath: getPosterFromMB(releaseGroupResult),
posterPath: await getPosterFromMB(releaseGroupResult),
mediaInfo: media ?? undefined,
};
};

@ -138,8 +138,8 @@ const ListView = ({
titleCard = (
<TitleCard
id={title.id}
title={title.name}
image={title.posterPath}
title={title.name}
mediaType={title.mediaType}
canExpand
force_big={force_big}

@ -12,7 +12,7 @@ import RecentlyAddedSlider from '@app/components/Discover/RecentlyAddedSlider';
import useDiscover from '@app/hooks/useDiscover';
import Error from '@app/pages/_error';
import { FunnelIcon } from '@heroicons/react/24/solid';
import type { ReleaseResult } from '@server/models/Search';
import type { ArtistResult, ReleaseResult } from '@server/models/Search';
import { useRouter } from 'next/router';
import { useState } from 'react';
import { defineMessages, useIntl } from 'react-intl';
@ -38,7 +38,7 @@ const DiscoverMusics = () => {
titles,
fetchMore,
error,
} = useDiscover<ReleaseResult, unknown, FilterOptions>(
} = useDiscover<ReleaseResult | ArtistResult, unknown, FilterOptions>(
'/api/v1/discover/musics',
preparedFilters
);

@ -163,7 +163,21 @@ const ReleaseDetails = ({ release }: ReleaseDetailsProp) => {
<span className="media-year">({mainDateDisplay})</span>
)}
</h1>
<span className="media-attributes"></span>
<span className="media-attributes">
By&nbsp;
{data.artist.map((artist, index) => (
<>
{' '}
<Link
href={`/music/artist/${artist.id}`}
key={`artist-${index}`}
>
<a className="hover:underline">{artist.name}</a>
</Link>
{index < data.artist.length - 1 ? ', ' : ''}
</>
))}
</span>
</div>
<div className="media-actions">
<PlayButton links={mediaLinks} />

@ -195,7 +195,7 @@ const TitleCard = ({
<Transition
as={Fragment}
show={!image || showDetail || showRequestModal}
show={showDetail || showRequestModal}
enter="transition-opacity"
enterFrom="opacity-0"
enterTo="opacity-100"

Loading…
Cancel
Save