Add lookup-by-mbid functionality
MBID is a MusicBrainz ID: https://musicbrainz.org/doc/MusicBrainz_Identifier
This commit is contained in:
parent
26fac96b14
commit
aea55b5aec
2 changed files with 30 additions and 17 deletions
9
Makefile
9
Makefile
|
|
@ -14,5 +14,10 @@ clean:
|
||||||
start: deploy
|
start: deploy
|
||||||
# TODO: This doesn't kill weston nicely; I should handle that? Or background or something
|
# TODO: This doesn't kill weston nicely; I should handle that? Or background or something
|
||||||
ssh kiosk "pgrep -f 'python3 -m http.server' || python3 -m http.server --directory /home/chandler/dist 127.0.0.1:8000 &"
|
ssh kiosk "pgrep -f 'python3 -m http.server' || python3 -m http.server --directory /home/chandler/dist 127.0.0.1:8000 &"
|
||||||
ssh kiosk "pkill -f 'weston --shell=kiosk-shell.so'"
|
#ssh kiosk "pkill -f 'weston --shell=kiosk-shell.so' || true"
|
||||||
ssh kiosk weston --shell=kiosk-shell.so -- firefox --kiosk localhost:8000
|
ssh kiosk weston --shell=kiosk-shell.so -- firefox --kiosk localhost:8000 --remote-debugging-port=9222
|
||||||
|
|
||||||
|
debug: deploy
|
||||||
|
ssh kiosk "pgrep -f 'python3 -m http.server' || python3 -m http.server --directory /home/chandler/dist 127.0.0.1:8000 &"
|
||||||
|
#ssh kiosk "pkill -f 'weston --shell=kiosk-shell.so' || true"
|
||||||
|
ssh -L 6000:localhost:6000 kiosk weston --shell=kiosk-shell.so -- firefox --kiosk localhost:8000 --start-debugger-server 6000
|
||||||
|
|
|
||||||
38
src/App.tsx
38
src/App.tsx
|
|
@ -1,5 +1,5 @@
|
||||||
import { useEffect, useRef, useState } from 'react'
|
import { useEffect, useRef, useState } from 'react'
|
||||||
import { MusicBrainzApi, type ITrack } from 'musicbrainz-api';
|
import { MusicBrainzApi, type IRelease, type IReleaseMatch, type ITrack } from 'musicbrainz-api';
|
||||||
import Album from "./components/Album/Album";
|
import Album from "./components/Album/Album";
|
||||||
import AlbumArt from "./components/AlbumArt/AlbumArt";
|
import AlbumArt from "./components/AlbumArt/AlbumArt";
|
||||||
import NowPlaying from "./components/NowPlaying/NowPlaying";
|
import NowPlaying from "./components/NowPlaying/NowPlaying";
|
||||||
|
|
@ -104,11 +104,13 @@ function App() {
|
||||||
lookupBarcode("075021370814"); // Breakfast in America; owned
|
lookupBarcode("075021370814"); // Breakfast in America; owned
|
||||||
} else if (ev.key === "F2") {
|
} else if (ev.key === "F2") {
|
||||||
lookupBarcode("015775150522"); // Crime of the Century; not owned
|
lookupBarcode("015775150522"); // Crime of the Century; not owned
|
||||||
|
} else if (ev.key === "F3") {
|
||||||
|
lookupBarcode("mbid:439e9e8e-931a-431f-8ed0-ef00303bbad0"); // Feinberg's Well-Tempered Clavier (long!)
|
||||||
} else if (ev.key === "Enter") {
|
} else if (ev.key === "Enter") {
|
||||||
const code = buffer.join("").trim();
|
const code = buffer.join("").trim();
|
||||||
setBuffer([]); // Reset the buffer
|
setBuffer([]); // Reset the buffer
|
||||||
lookupBarcode(code);
|
lookupBarcode(code);
|
||||||
} else if (/^[0-9A-Za-z:]$/.test(ev.key)) {
|
} else if (/^[0-9A-Za-z:-]$/.test(ev.key)) {
|
||||||
setBuffer((prevBuffer) => [...prevBuffer, ev.key]);
|
setBuffer((prevBuffer) => [...prevBuffer, ev.key]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -127,20 +129,26 @@ function App() {
|
||||||
}
|
}
|
||||||
setSearching(true);
|
setSearching(true);
|
||||||
console.log("Scanned barcode:", barcode);
|
console.log("Scanned barcode:", barcode);
|
||||||
|
var mbRelease: IRelease | IReleaseMatch;
|
||||||
// # Lookup the barcode in MusicBrainz
|
if (barcode.startsWith("mbid:")) {
|
||||||
// TODO: tweak this query to return a single album, with tracks, a release
|
// # We already have a musicbrainz ID; get its data
|
||||||
// date, genre, artist info, and link to coverartdb.
|
const releaseId = barcode.slice(5);
|
||||||
const searchResponse = await mbApi.search('release', {
|
mbRelease = await mbApi.lookup('release', releaseId, ['artist-credits', 'release-groups']);
|
||||||
query: { barcode },
|
} else {
|
||||||
inc: ['artist-credits', 'release-groups', 'genres'], // TODO
|
// # Lookup the barcode in MusicBrainz
|
||||||
});
|
// TODO: tweak this query to return a single album, with tracks, a release
|
||||||
if (searchResponse.count === 0) {
|
// date, genre, artist info, and link to coverartdb.
|
||||||
console.log("No album found for barcode:", barcode); // TODO: some kind of toast?
|
const searchResponse = await mbApi.search('release', {
|
||||||
setSearching(false);
|
query: { barcode },
|
||||||
return;
|
inc: ['artist-credits', 'release-groups', 'genres'], // TODO
|
||||||
|
});
|
||||||
|
if (searchResponse.count === 0) {
|
||||||
|
console.log("No album found for barcode:", barcode); // TODO: some kind of toast?
|
||||||
|
setSearching(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mbRelease = searchResponse.releases[0];
|
||||||
}
|
}
|
||||||
const mbRelease = searchResponse.releases[0];
|
|
||||||
|
|
||||||
// # Check Navidrome for this album
|
// # Check Navidrome for this album
|
||||||
// https://opensubsonic.netlify.app/docs/endpoints/search3/
|
// https://opensubsonic.netlify.app/docs/endpoints/search3/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue