Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
tags: ["v*.*.*"]
pull_request:
branches: ["main"]
workflow_dispatch:

env:
REGISTRY: ghcr.io
Expand All @@ -17,9 +18,9 @@ jobs:
fail-fast: false
matrix:
include:
- image: lklynet/aurral-backend
- image: aurral-backend
context: ./backend
- image: lklynet/aurral-frontend
- image: aurral-frontend
context: ./frontend

permissions:
Expand All @@ -45,7 +46,7 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ matrix.image }}
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.image }}
tags: |
type=ref,event=branch
type=ref,event=pr
Expand Down
97 changes: 95 additions & 2 deletions backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,7 @@ app.post("/api/lidarr/artists", async (req, res) => {
monitored,
searchForMissingAlbums,
albumFolders,
selectedAlbums, // Array of MusicBrainz release group IDs to monitor
} = req.body;

if (!foreignArtistId || !artistName) {
Expand Down Expand Up @@ -921,6 +922,11 @@ app.post("/api/lidarr/artists", async (req, res) => {
metadataProfile = metadataProfiles[0].id;
}

// If selectedAlbums is provided, use "none" as monitor option initially
// Then we'll update individual albums after
const hasGranularSelection = Array.isArray(selectedAlbums) && selectedAlbums.length > 0;
const monitorOption = hasGranularSelection ? "none" : (req.body.monitor || "all");

const artistData = {
foreignArtistId,
artistName,
Expand All @@ -930,13 +936,48 @@ app.post("/api/lidarr/artists", async (req, res) => {
monitored: isMonitored,
albumFolder: useAlbumFolders,
addOptions: {
searchForMissingAlbums: searchMissing,
monitor: req.body.monitor || "all",
searchForMissingAlbums: hasGranularSelection ? false : searchMissing,
monitor: monitorOption,
},
};

const result = await lidarrRequest("/artist", "POST", artistData);

// If granular album selection is requested, update individual albums
if (hasGranularSelection && result.id) {
// Wait for Lidarr to process the artist and create albums
await new Promise(resolve => setTimeout(resolve, 2000));

try {
// Get all albums for this artist from Lidarr
const albums = await lidarrRequest(`/album?artistId=${result.id}`);
const selectedSet = new Set(selectedAlbums);
const albumsToSearch = [];

// Update each selected album to be monitored
for (const album of albums) {
if (selectedSet.has(album.foreignAlbumId)) {
await lidarrRequest(`/album/${album.id}`, "PUT", {
...album,
monitored: true,
});
albumsToSearch.push(album.id);
}
}

// Trigger search for selected albums if requested
if (searchMissing && albumsToSearch.length > 0) {
await lidarrRequest("/command", "POST", {
name: "AlbumSearch",
albumIds: albumsToSearch,
});
}
} catch (albumError) {
console.error("Error updating album monitoring:", albumError.message);
// Continue - artist was added successfully, album updates may need manual retry
}
}

const newRequest = {
mbid: foreignArtistId,
name: artistName,
Expand Down Expand Up @@ -1130,6 +1171,58 @@ app.post("/api/lidarr/command/albumsearch", async (req, res) => {
}
});

// Bulk update album monitoring status
app.post("/api/lidarr/albums/bulk-monitor", async (req, res) => {
try {
const { artistId, albumIds, monitored, searchAfter } = req.body;

if (!artistId) {
return res.status(400).json({ error: "artistId is required" });
}
if (!Array.isArray(albumIds)) {
return res.status(400).json({ error: "albumIds must be an array" });
}
if (typeof monitored !== "boolean") {
return res.status(400).json({ error: "monitored must be a boolean" });
}

// Get all albums for this artist
const albums = await lidarrRequest(`/album?artistId=${artistId}`);
const albumIdSet = new Set(albumIds);
const updatedAlbums = [];

// Update each specified album
for (const album of albums) {
if (albumIdSet.has(album.id)) {
const updatedAlbum = await lidarrRequest(`/album/${album.id}`, "PUT", {
...album,
monitored,
});
updatedAlbums.push(updatedAlbum);
}
}

// Trigger search for newly monitored albums if requested
if (searchAfter && monitored && albumIds.length > 0) {
await lidarrRequest("/command", "POST", {
name: "AlbumSearch",
albumIds,
});
}

res.json({
success: true,
updated: updatedAlbums.length,
albums: updatedAlbums
});
} catch (error) {
res.status(500).json({
error: "Failed to bulk update album monitoring",
message: error.message,
});
}
});

app.delete("/api/lidarr/artists/:id", async (req, res) => {
try {
const { id } = req.params;
Expand Down
Loading