Add track listings to lookupMap

This commit is contained in:
RandyTheSilly committed 2026-10-10 18:42:36 -04:00
1 parent 198f18e5a2
commit ba4edccb15
2 files changed
+16 -21

No files matched your search

+2
View File
@@ -9,6 +9,8 @@ Control Jellyfin music playback from your Pebble with an iPod-like interface.
- ⛔ = unsupported (does not work well or at all with `jellyPod`)
## iOS
- ✅ [Finamp Beta/Redesign](https://github.com/finamp-app/finamp/tree/redesign) (last tested release: 1.0.1)
## MacOS
- ✅ [Finamp Beta/Redesign](https://github.com/finamp-app/finamp/tree/redesign) (last tested release: 1.0.1)
# Opinionated Design Philosophy
I made `jellyPod` to suite my tastes. Everything listed below is non-negotiable and will not be changed.
+14 -21
View File
@@ -25,8 +25,7 @@ Pebble.addEventListener("ready", function () {
const libObj = JSON.parse(libResp);
// format response for jellyPod
//// build tracks array and lookupMap (currently just binds alpha to artists)
let jpTracksArr = [];
//// build lookupMap
const lookupMap = new Map();
let lastAlbumInfo = {AlbumArtist: "", AlbumName: "", AlbumYear: 0};
for (const track of libObj.Items) {
@@ -40,23 +39,25 @@ Pebble.addEventListener("ready", function () {
}
const albumName = track.Album ? track.Album : "unknown album";
// register album in lookupMap whenever the album changes (new artist OR new album)
if (lastAlbumInfo.AlbumArtist !== albumArtist || lastAlbumInfo.AlbumName !== albumName) {
// insert every track into lookupMap
const firstChar = Array.from(albumArtist)[0].toUpperCase();
if (!lookupMap.has(firstChar)) {
lookupMap.set(firstChar, new Map());
}
const artistMap = lookupMap.get(firstChar);
if (!artistMap.has(albumArtist)) {
artistMap.set(albumArtist, []);
}
const albums = artistMap.get(albumArtist);
if (!albums.includes(albumName)) {
albums.push(albumName);
const artistToAlbumsMap = lookupMap.get(firstChar);
if (!artistToAlbumsMap.has(albumArtist)) {
artistToAlbumsMap.set(albumArtist, new Map());
}
const albumToTracksMap = artistToAlbumsMap.get(albumArtist);
if (!albumToTracksMap.has(albumName)) {
albumToTracksMap.set(albumName, []);
}
albumToTracksMap.get(albumName).push({
TrackName: track.Name,
JfId: track.Id
});
// keep lastAlbumInfo in sync for every album change
// consider the album to have changed if the album name OR artist changed
if (lastAlbumInfo.AlbumArtist !== albumArtist || lastAlbumInfo.AlbumName !== albumName) {
lastAlbumInfo = {
AlbumArtist: albumArtist,
@@ -64,17 +65,9 @@ Pebble.addEventListener("ready", function () {
AlbumYear: track.ProductionYear ? track.ProductionYear : 1970
};
}
jpTracksArr.push({
TrackName: track.Name,
JfId: track.Id,
AlbumInfo: lastAlbumInfo
});
}
//console.log(jpTracksArr);
//console.log("Items:", libObj.Items.length, "Tracks:", jpTracksArr.length);
console.log(JSON.stringify([...lookupMap].map(([ch, m]) => [ch, [...m]])));
//console.log(JSON.stringify(lookupMap, (k, v) => v instanceof Map ? Object.fromEntries(v) : v));
Pebble.sendAppMessage({ PKJS_READY: 1 });
});