mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
normalize dates to UTC, remove year to date conversions
This commit is contained in:
@@ -256,11 +256,7 @@ const normalizeSong = (
|
|||||||
peak: null,
|
peak: null,
|
||||||
playCount: (item.UserData && item.UserData.PlayCount) || 0,
|
playCount: (item.UserData && item.UserData.PlayCount) || 0,
|
||||||
playlistItemId: item.PlaylistItemId,
|
playlistItemId: item.PlaylistItemId,
|
||||||
releaseDate: item.PremiereDate
|
releaseDate: item.PremiereDate ? item.PremiereDate : null,
|
||||||
? new Date(item.PremiereDate).toISOString()
|
|
||||||
: item.ProductionYear
|
|
||||||
? new Date(item.ProductionYear, 0, 1).toISOString()
|
|
||||||
: null,
|
|
||||||
releaseYear: item.ProductionYear || null,
|
releaseYear: item.ProductionYear || null,
|
||||||
sampleRate,
|
sampleRate,
|
||||||
size,
|
size,
|
||||||
@@ -326,7 +322,7 @@ const normalizeAlbum = (
|
|||||||
participants: getPeople(item),
|
participants: getPeople(item),
|
||||||
playCount: item.UserData?.PlayCount || 0,
|
playCount: item.UserData?.PlayCount || 0,
|
||||||
recordLabels: [],
|
recordLabels: [],
|
||||||
releaseDate: item.PremiereDate?.split('T')[0] || null,
|
releaseDate: item.PremiereDate || null,
|
||||||
releaseTypes: [],
|
releaseTypes: [],
|
||||||
releaseYear: item.ProductionYear || null,
|
releaseYear: item.ProductionYear || null,
|
||||||
size: null,
|
size: null,
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ const normalizeSong = (
|
|||||||
comment: item.comment ? item.comment : null,
|
comment: item.comment ? item.comment : null,
|
||||||
compilation: item.compilation,
|
compilation: item.compilation,
|
||||||
container: item.suffix,
|
container: item.suffix,
|
||||||
createdAt: item.createdAt.split('T')[0],
|
createdAt: item.createdAt,
|
||||||
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,
|
||||||
@@ -287,7 +287,7 @@ const normalizeAlbum = (
|
|||||||
albumArtist: item.albumArtist,
|
albumArtist: item.albumArtist,
|
||||||
backdropImageUrl: imageBackdropUrl,
|
backdropImageUrl: imageBackdropUrl,
|
||||||
comment: item.comment || null,
|
comment: item.comment || null,
|
||||||
createdAt: item.createdAt.split('T')[0],
|
createdAt: item.createdAt,
|
||||||
duration: item.duration !== undefined ? item.duration * 1000 : null,
|
duration: item.duration !== undefined ? item.duration * 1000 : null,
|
||||||
explicitStatus:
|
explicitStatus:
|
||||||
item.explicitStatus === 'e'
|
item.explicitStatus === 'e'
|
||||||
@@ -308,21 +308,13 @@ const normalizeAlbum = (
|
|||||||
id: item.id,
|
id: item.id,
|
||||||
imagePlaceholderUrl,
|
imagePlaceholderUrl,
|
||||||
imageUrl,
|
imageUrl,
|
||||||
|
|
||||||
isCompilation: item.compilation,
|
isCompilation: item.compilation,
|
||||||
lastPlayedAt: normalizePlayDate(item),
|
lastPlayedAt: normalizePlayDate(item),
|
||||||
mbzId: item.mbzAlbumId || null,
|
mbzId: item.mbzAlbumId || null,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
originalDate: item.originalDate
|
originalDate: item.originalDate ? new Date(item.originalDate).toISOString() : null,
|
||||||
? new Date(item.originalDate).toISOString()
|
|
||||||
: item.originalYear
|
|
||||||
? new Date(Date.UTC(item.originalYear, 0, 1)).toISOString()
|
|
||||||
: null,
|
|
||||||
playCount: item.playCount || 0,
|
playCount: item.playCount || 0,
|
||||||
releaseDate: (item.releaseDate
|
releaseDate: item.releaseDate ? new Date(item.releaseDate).toISOString() : null,
|
||||||
? new Date(item.releaseDate)
|
|
||||||
: new Date(Date.UTC(item.minYear, 0, 1))
|
|
||||||
).toISOString(),
|
|
||||||
releaseYear: item.minYear || null,
|
releaseYear: item.minYear || null,
|
||||||
size: item.size,
|
size: item.size,
|
||||||
songCount: item.songCount,
|
songCount: item.songCount,
|
||||||
|
|||||||
@@ -280,7 +280,13 @@ const normalizeAlbum = (
|
|||||||
participants: getParticipants(item),
|
participants: getParticipants(item),
|
||||||
playCount: null,
|
playCount: null,
|
||||||
recordLabels: item.recordLabels?.map((item) => item.name) || [],
|
recordLabels: item.recordLabels?.map((item) => item.name) || [],
|
||||||
releaseDate: item.year ? new Date(Date.UTC(item.year, 0, 1)).toISOString() : null,
|
releaseDate: item.releaseDate
|
||||||
|
? new Date(
|
||||||
|
item.releaseDate.year,
|
||||||
|
item.releaseDate.month - 1,
|
||||||
|
item.releaseDate.day,
|
||||||
|
).toISOString()
|
||||||
|
: null,
|
||||||
releaseTypes: item.releaseTypes || [],
|
releaseTypes: item.releaseTypes || [],
|
||||||
releaseYear: item.year || null,
|
releaseYear: item.year || null,
|
||||||
size: null,
|
size: null,
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ const album = z.object({
|
|||||||
name: z.string(),
|
name: z.string(),
|
||||||
parent: z.string(),
|
parent: z.string(),
|
||||||
recordLabels: z.array(recordLabel).optional(),
|
recordLabels: z.array(recordLabel).optional(),
|
||||||
|
releaseDate: z.object({ day: z.number(), month: z.number(), year: z.number() }).optional(),
|
||||||
releaseTypes: z.array(z.string()).optional(),
|
releaseTypes: z.array(z.string()).optional(),
|
||||||
song: z.array(song),
|
song: z.array(song),
|
||||||
songCount: z.number(),
|
songCount: z.number(),
|
||||||
|
|||||||
@@ -232,7 +232,6 @@ export type Artist = {
|
|||||||
createdAt: string;
|
createdAt: string;
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
remoteCreatedAt: null | string;
|
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user