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
|
||||
# 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 "pkill -f 'weston --shell=kiosk-shell.so'"
|
||||
ssh kiosk weston --shell=kiosk-shell.so -- firefox --kiosk localhost:8000
|
||||
#ssh kiosk "pkill -f 'weston --shell=kiosk-shell.so' || true"
|
||||
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 { MusicBrainzApi, type ITrack } from 'musicbrainz-api';
|
||||
import { MusicBrainzApi, type IRelease, type IReleaseMatch, type ITrack } from 'musicbrainz-api';
|
||||
import Album from "./components/Album/Album";
|
||||
import AlbumArt from "./components/AlbumArt/AlbumArt";
|
||||
import NowPlaying from "./components/NowPlaying/NowPlaying";
|
||||
|
|
@ -104,11 +104,13 @@ function App() {
|
|||
lookupBarcode("075021370814"); // Breakfast in America; owned
|
||||
} else if (ev.key === "F2") {
|
||||
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") {
|
||||
const code = buffer.join("").trim();
|
||||
setBuffer([]); // Reset the buffer
|
||||
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]);
|
||||
}
|
||||
};
|
||||
|
|
@ -127,20 +129,26 @@ function App() {
|
|||
}
|
||||
setSearching(true);
|
||||
console.log("Scanned barcode:", barcode);
|
||||
|
||||
// # Lookup the barcode in MusicBrainz
|
||||
// TODO: tweak this query to return a single album, with tracks, a release
|
||||
// date, genre, artist info, and link to coverartdb.
|
||||
const searchResponse = await mbApi.search('release', {
|
||||
query: { barcode },
|
||||
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;
|
||||
var mbRelease: IRelease | IReleaseMatch;
|
||||
if (barcode.startsWith("mbid:")) {
|
||||
// # We already have a musicbrainz ID; get its data
|
||||
const releaseId = barcode.slice(5);
|
||||
mbRelease = await mbApi.lookup('release', releaseId, ['artist-credits', 'release-groups']);
|
||||
} else {
|
||||
// # Lookup the barcode in MusicBrainz
|
||||
// TODO: tweak this query to return a single album, with tracks, a release
|
||||
// date, genre, artist info, and link to coverartdb.
|
||||
const searchResponse = await mbApi.search('release', {
|
||||
query: { barcode },
|
||||
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
|
||||
// https://opensubsonic.netlify.app/docs/endpoints/search3/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue