mirror of
https://github.com/xtrll/MusicMetaFinder.git
synced 2026-04-23 17:29:55 +02:00
refactor: apply eslint fixes and minor clean up
This commit is contained in:
@@ -15,7 +15,7 @@ export default async function getMetadata(trackIds) {
|
||||
|
||||
const accessToken = await getSpotifyAccessToken();
|
||||
|
||||
const metadataPromises = trackIds.map(trackId => requestMetadata(trackId, accessToken));
|
||||
const metadataPromises = trackIds.map((trackId) => requestMetadata(trackId, accessToken));
|
||||
|
||||
// Resolves to an array of metadata objects corresponding to the track IDs.
|
||||
return await Promise.all(metadataPromises);
|
||||
@@ -24,4 +24,3 @@ export default async function getMetadata(trackIds) {
|
||||
throw e; // Rethrowing the error to handle it at a higher level
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ export default async function recognizeAudioFiles(audioFiles) {
|
||||
return { filePath, id };
|
||||
} catch (error) {
|
||||
// Log the error, return an object with filePath and null id
|
||||
// This prevents one failed recognition from stopping the whole process
|
||||
console.error(`Recognition failed for file ${filePath}:`, error);
|
||||
return { filePath, id: null };
|
||||
}
|
||||
|
||||
@@ -7,15 +7,13 @@ import recognizeAudio from '../../api/recognition/auddApi.js';
|
||||
* @return {Promise<(Object|null)[]>} A promise that resolves to an array of recognition result objects or null values for each file.
|
||||
*/
|
||||
export default async function recognizeAudioFiles(audioFiles) {
|
||||
const recognitionPromises = audioFiles.map(filePath =>
|
||||
recognizeAudio(filePath)
|
||||
.catch(error => {
|
||||
// Log the error and return null for this file.
|
||||
// This prevents one failed recognition from stopping the whole process
|
||||
console.error(`Recognition failed for file ${filePath}:`, error);
|
||||
return null;
|
||||
})
|
||||
);
|
||||
const recognitionPromises = audioFiles.map((filePath) => recognizeAudio(filePath)
|
||||
.catch((error) => {
|
||||
// Log the error and return null for this file.
|
||||
// This prevents one failed recognition from stopping the whole process
|
||||
console.error(`Recognition failed for file ${filePath}:`, error);
|
||||
return null;
|
||||
}));
|
||||
|
||||
// Wait for all recognitions to resolve. This will be an array of results or null values for each audio file.
|
||||
return Promise.all(recognitionPromises);
|
||||
|
||||
Reference in New Issue
Block a user