Refactor localStorage import and update .gitignore for localstorage.json

This commit is contained in:
wont-stream 2025-04-16 22:57:56 -04:00
parent 67dce9ddc0
commit 43667b79f0
4 changed files with 61 additions and 30 deletions

2
.gitignore vendored
View file

@ -35,5 +35,5 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
tmp
localstorage
localstorage.json
downloaded

View file

@ -1,4 +1,4 @@
import "../localstorage";
import "./localStorage";
import { init, initializeDeviceLogin, finalizeDeviceLogin, credentialsProvider } from "@tidal-music/auth";

View file

@ -0,0 +1,29 @@
const database = Bun.file('localStorage.json');
if (!await database.exists()) {
await Bun.write(database, JSON.stringify({}));
}
let data = {};
data = await database.json() || {};
globalThis.localStorage = {
getItem: (key) => {
return data[key] || null;
},
setItem: (key, value) => {
data[key] = value;
Bun.write(database, JSON.stringify(data));
},
removeItem: (key) => {
delete data[key];
Bun.write(database, JSON.stringify(data));
},
clear: () => {
data = {};
Bun.write(database, JSON.stringify(data));
}
};
export { }

View file

@ -113,12 +113,14 @@ export default class {
],
}
console.log(track)
return FlacStreamTagger.fromBuffer(Buffer.from(audioBuffer), {
tagMap: {
title: track.title,
trackNumber: track.trackNumber.toString(),
discNumber: track.volumeNumber.toString(),
bpm: track.bpm.toString(),
bpm: (track.bpm || 0).toString(),
date: track.streamStartDate,
copyright: track.copyright,
REPLAYGAIN_TRACK_GAIN: track.replayGain.toString(),