chore: make 'thumbHash' camelCase
This commit is contained in:
@@ -7,4 +7,4 @@ export type MaimaiMetadataKind = (typeof maimaiMetadataKinds)[number];
|
|||||||
|
|
||||||
export const maimaiThumbKinds = ['music', 'frame', 'icon', 'plate'] as const;
|
export const maimaiThumbKinds = ['music', 'frame', 'icon', 'plate'] as const;
|
||||||
export type MaimaiThumbKind = (typeof maimaiThumbKinds)[number];
|
export type MaimaiThumbKind = (typeof maimaiThumbKinds)[number];
|
||||||
export type ThumbCache = Record<MaimaiThumbKind, Record<number, { thumbhash: string; hash: string }>>;
|
export type ThumbCache = Record<MaimaiThumbKind, Record<number, { thumbHash: string; hash: string }>>;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export interface MaimaiMusicMetadataRegionalInfo {
|
|||||||
|
|
||||||
export type MaimaiMusicLevelChangeLog = Partial<Record<MaimaiMajorVersionId, number>>[];
|
export type MaimaiMusicLevelChangeLog = Partial<Record<MaimaiMajorVersionId, number>>[];
|
||||||
export interface MaimaiMusicMetadata extends MaimaiMusicMetadataBase {
|
export interface MaimaiMusicMetadata extends MaimaiMusicMetadataBase {
|
||||||
jacket?: { thumbhash: string; hash: string };
|
jacket?: { thumbHash: string; hash: string };
|
||||||
/**
|
/**
|
||||||
* The level change log per chart (BASIC, ADVANCED, EXPERT, MASTER, Re:MASTER).
|
* The level change log per chart (BASIC, ADVANCED, EXPERT, MASTER, Re:MASTER).
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -15,6 +15,6 @@ export type BasicMetadata<TExtra = {}> = MetadataMaybeRegionalized<BasicMetadata
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type MaimaiTitleMetadataExtra = { rareType: MaimaiTitleRareType };
|
export type MaimaiTitleMetadataExtra = { rareType: MaimaiTitleRareType };
|
||||||
export type MaimaiFrameMetadataExtra = { thumbHash: string };
|
export type MaimaiFrameMetadataExtra = { image: { thumbHash: string; hash: string } };
|
||||||
export type MaimaiIconMetadataExtra = { thumbHash: string };
|
export type MaimaiIconMetadataExtra = { image: { thumbHash: string; hash: string } };
|
||||||
export type MaimaiPlateMetadataExtra = { thumbHash: string };
|
export type MaimaiPlateMetadataExtra = { image: { thumbHash: string; hash: string } };
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ const defineDataType = <TExtra = {}>(
|
|||||||
const netOpenDate = parseNetOpenDate(xmlData.netOpenName.str);
|
const netOpenDate = parseNetOpenDate(xmlData.netOpenName.str);
|
||||||
result[id] = { name, netOpenDate, ...parseExtraFields(xmlData) };
|
result[id] = { name, netOpenDate, ...parseExtraFields(xmlData) };
|
||||||
if (thumbKind) {
|
if (thumbKind) {
|
||||||
const assetImage = ctx.thumbCache[thumbKind][id];
|
const image = ctx.thumbCache[thumbKind][id];
|
||||||
if (!assetImage) logger.warn(`Asset image ${thumbKind} ${id} not found in thumb cache`);
|
if (!image) logger.warn(`Asset image ${thumbKind} ${id} not found in thumb cache`);
|
||||||
(result[id] as { assetImage?: { thumbhash: string; hash: string } }).assetImage = assetImage;
|
(result[id] as { image?: { thumbHash: string; hash: string } }).image = image;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
+2
-2
@@ -35,9 +35,9 @@ export default async (args: WorkerArguments) => {
|
|||||||
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
|
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
|
||||||
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
||||||
const rgba = new Uint8Array(imageData.data.buffer);
|
const rgba = new Uint8Array(imageData.data.buffer);
|
||||||
const thumbhash = rgbaToThumbHash(resizedWidth, resizedHeight, rgba);
|
const thumbHash = rgbaToThumbHash(resizedWidth, resizedHeight, rgba);
|
||||||
logger.log(`Generated thumbhash for ${filePath}`);
|
logger.log(`Generated thumbhash for ${filePath}`);
|
||||||
result[kind][id] = { thumbhash: Buffer.from(thumbhash).toString('base64url'), hash };
|
result[kind][id] = { thumbHash: Buffer.from(thumbHash).toString('base64url'), hash };
|
||||||
}));
|
}));
|
||||||
await fs.promises.writeFile(args.outputFile, JSON.stringify(result, null, 2));
|
await fs.promises.writeFile(args.outputFile, JSON.stringify(result, null, 2));
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user