Skip to content

Commit 4aaffd8

Browse files
squadgazzzInrixia
authored andcommitted
Simplify
1 parent ddbbd50 commit 4aaffd8

2 files changed

Lines changed: 13 additions & 18 deletions

File tree

plugins/RealMax/src/index.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,14 @@ import { settings } from "./Settings";
77

88
export { errSignal, unloads } from "./index.safe";
99

10-
const getFormatString = (mediaItem: MediaItem): Promise<string> =>
11-
new Promise((resolve) => {
12-
const quality = mediaItem.bestQuality;
13-
const cleanup = mediaItem.withFormat(new Set(), quality.audioQuality, ({ sampleRate, bitDepth }) => {
14-
if (bitDepth && sampleRate) resolve(`${bitDepth}bit/${sampleRate / 1000}kHz`);
15-
else resolve(quality.name);
16-
cleanup?.();
17-
});
18-
mediaItem.updateFormat(quality.audioQuality).catch(() => {
19-
resolve(quality.name);
20-
cleanup?.();
21-
});
22-
});
10+
const getFormatString = async (mediaItem: MediaItem): Promise<string> => {
11+
const quality = mediaItem.bestQuality;
12+
try {
13+
const format = await mediaItem.updateFormat(quality.audioQuality);
14+
if (format?.bitDepth && format?.sampleRate) return `${format.bitDepth}bit/${format.sampleRate / 1000}kHz`;
15+
} catch {}
16+
return quality.name;
17+
};
2318

2419
const getMaxItem = async (mediaItem?: MediaItem) => {
2520
const maxItem = await mediaItem?.max();

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)