From 354e68bc327bc6d17108eccb54e53f7d6e98cdf7 Mon Sep 17 00:00:00 2001 From: Geomitron <22552797+Geomitron@users.noreply.github.com> Date: Sun, 5 Nov 2023 22:14:33 -0600 Subject: [PATCH] Add folder issues for audio --- .changeset/long-queens-join.md | 5 +++++ src/audio/audio-scanner.ts | 18 +++++++++--------- src/index.ts | 7 ++++--- 3 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 .changeset/long-queens-join.md diff --git a/.changeset/long-queens-join.md b/.changeset/long-queens-join.md new file mode 100644 index 0000000..840ac61 --- /dev/null +++ b/.changeset/long-queens-join.md @@ -0,0 +1,5 @@ +--- +"scan-chart": patch +--- + +Add folder issues for audio diff --git a/src/audio/audio-scanner.ts b/src/audio/audio-scanner.ts index e51d58a..a201362 100644 --- a/src/audio/audio-scanner.ts +++ b/src/audio/audio-scanner.ts @@ -4,7 +4,6 @@ import { parse } from 'path' import { CachedFile } from 'src/cached-file' import { FolderIssueType } from '../interfaces' import { hasAudioExtension, hasAudioName } from '../utils' -import { AudioParser } from './audio-parser' class AudioScanner { @@ -20,15 +19,16 @@ class AudioScanner { const audioFiles = this.getAudioFiles(chartFolder) if (audioFiles.length === 0) { return } - const audioParser = new AudioParser(max_threads) - const { audioHash, audioLength, errors } = await audioParser.getAudioFingerprint(audioFiles) + // TODO: Implement this when determining the best audio fingerprint algorithm + // const audioParser = new AudioParser(max_threads) + // const { audioHash, audioLength, errors } = await audioParser.getAudioFingerprint(audioFiles) - if (errors.length) { - this.addFolderIssue('badAudio', `This chart's audio couldn't be parsed:\n${errors.join('\n')}`) - } else { - this.audioHash = audioHash - this.audioLength = audioLength - } + // if (errors.length) { + // this.addFolderIssue('badAudio', `This chart's audio couldn't be parsed:\n${errors.join('\n')}`) + // } else { + // this.audioHash = audioHash + // this.audioLength = audioLength + // } } /** diff --git a/src/index.ts b/src/index.ts index 56d1ebf..8644170 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,8 +4,10 @@ import EventEmitter from 'events' import { Dirent } from 'fs' import { readdir } from 'fs/promises' import * as _ from 'lodash' +import { cpus } from 'os' import { join, parse, relative } from 'path' +import { scanAudio } from './audio' import { CachedFile } from './cached-file' import { scanChart } from './chart' import { scanImage } from './image' @@ -223,9 +225,8 @@ class ChartsScanner { } } - // TODO: Implement this when determining the best audio fingerprint algorithm - // const audioData = await scanAudio(chartFolder, cpus().length - 1) - // chart.folderIssues.push(...audioData.folderIssues) + const audioData = await scanAudio(chartFolder, cpus().length - 1) + chart.folderIssues.push(...audioData.folderIssues) if (!chartData.notesData /* TODO: || !audioData.audioHash */) { chart.playable = false