mirror of
https://github.com/cstaelen/shazarr.git
synced 2026-10-19 01:31:11 -05:00
fix: reset state to retry
This commit is contained in:
1 parent
e4e0e62af3
commit
65f4016b29
4 files changed
+23
-13
No files matched your search
@@ -30,6 +30,7 @@ app.post('/recognize', async (req: Request, res: Response) => {
|
||||
console.log("err", err);
|
||||
} else {
|
||||
const command = `python ${ROOT_PATH}/api/scripts/shazarr.py ${filePath}`;
|
||||
// const command = `python ${ROOT_PATH}/api/scripts/shazarr.py /home/app/standalone/api/scripts/test.m4a`;
|
||||
console.log(`Executing: ${command}`);
|
||||
|
||||
const response = await execSync(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import asyncio
|
||||
import sys
|
||||
import json
|
||||
from shazamio import Shazam
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
@@ -10,7 +11,8 @@ file = sys.argv[1]
|
||||
async def main():
|
||||
shazam = Shazam()
|
||||
out = await shazam.recognize_song(file)
|
||||
print(out)
|
||||
info = json.dumps(out)
|
||||
print(info)
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(main())
|
||||
@@ -81,6 +81,7 @@ export default function ShazarrButton() {
|
||||
<IconButton
|
||||
disabled={recordingStatus === "recording" || shazarrLoading}
|
||||
onClick={() => {
|
||||
resetSearch();
|
||||
setRecordingStatus("start");
|
||||
}}
|
||||
>
|
||||
@@ -105,6 +106,13 @@ export default function ShazarrButton() {
|
||||
>
|
||||
Download with Tidarr
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
startIcon={<Album />}
|
||||
onClick={() => openTidar()}
|
||||
>
|
||||
Download with Lidarr
|
||||
</Button>
|
||||
<Divider />
|
||||
<Button onClick={() => resetSearch()} variant="outlined">
|
||||
Reset
|
||||
|
||||
@@ -75,16 +75,12 @@ export default function useShazarr() {
|
||||
const response = await recognize(base64);
|
||||
if ((response as ApiReturnType).error) {
|
||||
console.log('error', response);
|
||||
resetSearch();
|
||||
} else {
|
||||
const formatted = JSON.parse(
|
||||
response.replaceAll("False", "false").replaceAll("'", '"')
|
||||
) as ShazamioResponseType;
|
||||
const formatted = JSON.parse(response) as ShazamioResponseType;
|
||||
setShazarrResponse(formatted);
|
||||
setAudio(undefined);
|
||||
setStream(undefined);
|
||||
setAudioChunks([]);
|
||||
setShazarrLoading(false);
|
||||
}
|
||||
setShazarrLoading(false);
|
||||
setRecordingStatus("inactive");
|
||||
});
|
||||
}
|
||||
@@ -92,6 +88,9 @@ export default function useShazarr() {
|
||||
|
||||
const resetSearch = () => {
|
||||
setShazarrResponse(undefined);
|
||||
setAudio(undefined);
|
||||
setStream(undefined);
|
||||
setAudioChunks([]);
|
||||
setRecordingStatus("inactive");
|
||||
};
|
||||
|
||||
@@ -110,12 +109,12 @@ export default function useShazarr() {
|
||||
|
||||
switch (recordingStatus) {
|
||||
case "start":
|
||||
getMicrophonePermission()
|
||||
getMicrophonePermission()
|
||||
break;
|
||||
case "granted":
|
||||
startRecording();
|
||||
break;
|
||||
case "recording":
|
||||
case "granted":
|
||||
startRecording();
|
||||
break;
|
||||
case "recording":
|
||||
setTimeout(() => stopRecording(), 5000);
|
||||
break;
|
||||
case "searching":
|
||||
|
||||
Reference in new issue
Block a user