Skip to content

Commit

Permalink
fix:Removed unused variables, WatchlistSyncMusic column and multiples…
Browse files Browse the repository at this point in the history
… bug fixed
  • Loading branch information
0-Pierre committed Jan 9, 2025
1 parent 9b7b574 commit f45dea1
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 17 deletions.
3 changes: 1 addition & 2 deletions server/api/musicbrainz/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,12 @@ class MusicBrainz extends ExternalAPI {
? await this.get<MbAlbumDetails>(`/album/${id}`, { language }, 43200)
: await this.get<MbArtistDetails>(`/artist/${id}`, { language }, 43200);

// Get the appropriate links
let targetLinks: MbLink[] | undefined;
if (type === 'album') {
const albumData = data as MbAlbumDetails;
const artistId = albumData.artists?.[0]?.id;
if (!artistId) return null;

// Get artist details to access links
const artistData = await this.get<MbArtistDetails>(`/artist/${artistId}`, { language }, 43200);
targetLinks = artistData.links;
} else {
Expand Down Expand Up @@ -170,6 +168,7 @@ class MusicBrainz extends ExternalAPI {
if (!extract) return null;

const decoded = extract
.replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi, '')

Check failure

Code scanning / CodeQL

Incomplete multi-character sanitization High

This string may still contain
<script
, which may cause an HTML element injection vulnerability.

Check failure

Code scanning / CodeQL

Bad HTML filtering regexp High

This regular expression does not match script end tags like </script >.
.replace(/\\u[\dA-F]{4}/gi, match =>
String.fromCharCode(parseInt(match.replace(/\\u/g, ''), 16))
)
Expand Down
3 changes: 0 additions & 3 deletions server/entity/UserSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ export class UserSettings {
@Column({ nullable: true })
public watchlistSyncTv?: boolean;

@Column({ default: false })
public watchlistSyncMusic?: boolean;

@Column({
type: 'text',
nullable: true,
Expand Down
4 changes: 0 additions & 4 deletions server/lib/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ import {
isMovie,
isMovieDetails,
isTvDetails,
isArtist,
isAlbum,
isArtistDetails,
isAlbumDetails
} from '@server/utils/typeHelpers';


Expand Down
14 changes: 14 additions & 0 deletions server/routes/person.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ personRoutes.get('/:id', async (req, res, next) => {

personRoutes.get('/:id/discography', async (req, res, next) => {
const musicBrainz = new MusicBrainz();
const tmdb = new TheMovieDb();
const coverArtArchive = new CoverArtArchive();
const artistId = req.query.artistId as string;
const type = req.query.type as string;
Expand All @@ -84,6 +85,19 @@ personRoutes.get('/:id/discography', async (req, res, next) => {
});
}

const person = await tmdb.getPerson({
personId: Number(req.params.id),
language: (req.query.language as string) ?? req.locale,
});

if (!person.birthday) {
return res.status(200).json({
page: 1,
pageInfo: { total: 0, totalPages: 0 },
results: [],
});
}

try {
const artistDetails = await musicBrainz.getArtist({
artistId: artistId,
Expand Down
1 change: 0 additions & 1 deletion server/routes/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ searchRoutes.get('/', async (req, res, next) => {
language: (req.query.language as string) ?? req.locale,
query: queryString,
});
combinedResults = results.results;
} else {
const tmdb = new TheMovieDb();
const tmdbResults = await tmdb.searchMulti({
Expand Down
2 changes: 1 addition & 1 deletion server/routes/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const settingsRoutes = Router();
settingsRoutes.use('/notifications', notificationRoutes);
settingsRoutes.use('/radarr', radarrRoutes);
settingsRoutes.use('/sonarr', sonarrRoutes);
settingsRoutes.use('/lidarr', lidarrRoutes)
settingsRoutes.use('/lidarr', lidarrRoutes);
settingsRoutes.use('/discover', discoverSettingRoutes);

const filteredMainSettings = (
Expand Down
17 changes: 11 additions & 6 deletions src/components/MusicDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const messages = defineMessages('components.MusicDetails', {
managemusic: 'Manage Music',
biographyunavailable: 'Biography unavailable.',
trackstitle: 'Tracks',
tracksunavailable: 'No tracks available.',
watchlistSuccess: '<strong>{title}</strong> added to watchlist successfully!',
watchlistDeleted: '<strong>{title}</strong> removed from watchlist successfully!',
watchlistError: 'Something went wrong try again.',
Expand Down Expand Up @@ -512,35 +513,39 @@ const MusicDetails = ({ music }: MusicDetailsProps) => {
: intl.formatMessage(messages.biographyunavailable)}
</p>
<h2 className="py-4">{intl.formatMessage(messages.trackstitle)}</h2>
{data.releases[0].tracks && (
{data.releases?.[0]?.tracks?.length > 0 ? (
<div className="divide-y divide-gray-700 rounded-lg border border-gray-700">
{data.releases[0].tracks.map((track, index) => (
<div
key={track.id}
key={track.id ?? index}
className="flex items-center justify-between px-4 py-2 text-sm transition duration-150 hover:bg-gray-700"
>
<div className="flex flex-1 items-center space-x-4">
<span className="w-8 text-gray-500">{index + 1}</span>
<span className="flex-1 truncate text-gray-300">{track.trackName}</span>
<span className="text-right text-gray-500">
{Math.floor((track.durationMs / 1000) / 60)}:
{String(Math.floor((track.durationMs / 1000) % 60)).padStart(2, '0')}
{Math.floor((track.durationMs ?? 0) / 1000 / 60)}:
{String(Math.floor((track.durationMs ?? 0) / 1000 % 60)).padStart(2, '0')}
</span>
</div>
</div>
))}
</div>
) : (
<div className="text-gray-400">
{intl.formatMessage(messages.tracksunavailable)}
</div>
)}
</div>
<div className="media-overview-right">
<div className="media-facts">
{data.releases[0].status && (
{data.releases?.[0]?.status && (
<div className="media-fact">
<span>{intl.formatMessage(globalMessages.status)}</span>
<span className="media-fact-value">{data.releases[0].status}</span>
</div>
)}
{data.releases[0].label?.length > 0 && (
{data.releases?.[0]?.label?.length > 0 && (
<div className="media-fact">
<span>{intl.formatMessage(messages.label)}</span>
<span className="media-fact-value">
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@
"components.MusicDetails.managemusic": "Manage Music",
"components.MusicDetails.biographyunavailable": "Biography unavailable.",
"components.MusicDetails.trackstitle": "Tracks",
"components.MusicDetails.tracksunavailable": "No tracks available.",
"components.MusicDetails.watchlistSuccess": "<strong>{title}</strong> added to watchlist successfully!",
"components.MusicDetails.watchlistDeleted": "<strong>{title}</strong> removed from watchlist successfully!",
"components.MusicDetails.watchlistError": "Something went wrong try again.",
Expand Down

0 comments on commit f45dea1

Please sign in to comment.