Closes #1.
This commit is contained in:
parent
db2a8a5cd0
commit
07a26727ac
|
@ -1,2 +1,3 @@
|
|||
LIDARR_URL="https://lidarr.domain.tld"
|
||||
LIDARR_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
UNMONITOR="false"
|
||||
|
|
|
@ -15,11 +15,18 @@ Automatically unmonitor promotional singles from lidarr.
|
|||
```bash
|
||||
docker run --rm \
|
||||
--name lidarr-true-singles \
|
||||
-e LIDARR_URL=http://lidarr:8686 \
|
||||
-e LIDARR_URL=http://localhost:8686 \
|
||||
-e LIDARR_API_KEY=your_api_key \
|
||||
-e UNMONITOR=false \
|
||||
chxseh/lidarr-true-singles
|
||||
```
|
||||
|
||||
| Environment Variable | Description | Default |
|
||||
| -------------------- | -------------------------------------- | --------------------- |
|
||||
| LIDARR_URL | The url to your Lidarr instance | http://localhost:8686 |
|
||||
| LIDARR_API_KEY | Your Lidarr API Key | |
|
||||
| UNMONITOR | Whether to unmonitor the tracks or not | false |
|
||||
|
||||
## Development
|
||||
```bash
|
||||
git clone https://github.com/chxseh/lidarr-true-singles.git
|
||||
|
|
18
src/app.js
18
src/app.js
|
@ -8,6 +8,7 @@ if (lidarrUrl.endsWith(`/`))
|
|||
lidarrUrl = lidarrUrl.slice(0, -1);
|
||||
|
||||
const apiKey = process.env.LIDARR_API_KEY;
|
||||
const unmonitor = process.env.UNMONITOR || `false`;
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -57,7 +58,22 @@ for (const artistId of artistIdsObject)
|
|||
const trackName = trackList.find((track) => singleNamesLower.includes(track.title.toLowerCase())).title;
|
||||
const singleId = singleIds[singleNamesLower.indexOf(trackName.toLowerCase())];
|
||||
const artistName = artists.find((artist) => artist.id === artistId).artistName;
|
||||
console.log(`"${ singleNames[singleIds.indexOf(singleId)] }" is also found on ${ album.title } by ${ artistName }`);
|
||||
if (unmonitor === `true`)
|
||||
{
|
||||
await fetch(`${ lidarrUrl }/api/v1/album/monitor?apikey=${ apiKey }`, {
|
||||
method: `PUT`,
|
||||
headers: {
|
||||
"Content-Type": `application/json`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
albumIds: [singleId],
|
||||
monitored: false
|
||||
})
|
||||
});
|
||||
console.log(`Unmonitored "${ singleNames[singleIds.indexOf(singleId)] }" by ${ artistName }`);
|
||||
}
|
||||
else
|
||||
console.log(`"${ singleNames[singleIds.indexOf(singleId)] }" is also found on ${ album.title } by ${ artistName }`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue