Closes #12. (Untested)
This commit is contained in:
parent
925c995302
commit
7a8f787466
|
@ -2,3 +2,4 @@ LIDARR_URL="https://lidarr.domain.tld"
|
|||
LIDARR_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
UNMONITOR="false"
|
||||
OUTPUT_UNMONITORED="false"
|
||||
DELETE="false"
|
||||
|
|
15
README.md
15
README.md
|
@ -18,6 +18,7 @@ docker run --rm \
|
|||
-e LIDARR_URL=http://localhost:8686 \
|
||||
-e LIDARR_API_KEY=your_api_key \
|
||||
-e UNMONITOR=false \
|
||||
-e DELETE=false \
|
||||
-e OUTPUT_UNMONITORED=false \
|
||||
ghcr.io/chxseh/lidarr-true-singles:latest
|
||||
```
|
||||
|
@ -27,14 +28,16 @@ docker run --rm \
|
|||
| `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` |
|
||||
| `DELETE` | Whether to delete the tracks or not | `false` |
|
||||
| `OUTPUT_UNMONITORED` | Print unmonitored singles that are downloaded. Note that this overrides the `UNMONITOR` option. | `false` |
|
||||
|
||||
| Variable | Option | Effect |
|
||||
| -------------------- | ------- | ------------------------------------------------------------------------------------------------------- |
|
||||
| `MONITOR` | `false` | Will *just* tell you what singles it finds on albums |
|
||||
| `MONITOR` | `true` | Will *just* unmonitor said singles and let you know that it unmonitored them |
|
||||
| `OUTPUT_UNMONITORED` | `false` | Will do nothing (falls back to what you have `MONITOR` set to, if any) |
|
||||
| `OUTPUT_UNMONITORED` | `true` | Will *just* tell you about **any** single that is unmonitored and downloaded, with a link to delete it. |
|
||||
| Environment Variable | Outcome |
|
||||
| ------------------------------------------ | -------------------------------------------------------- |
|
||||
| `UNMONITOR=false` | See duplicate singles |
|
||||
| `UNMONITOR=true` | Unmonitor duplicate singles |
|
||||
| `UNMONITOR=true`<br>`DELETE=true` | Delete duplicate singles |
|
||||
| `OUTPUT_UNMONITORED=true` | See duplicate unmonitored singles that are downloaded |
|
||||
| `OUTPUT_UNMONITORED=true`<br>`DELETE=true` | Delete duplicate unmonitored singles that are downloaded |
|
||||
|
||||
## Development
|
||||
```bash
|
||||
|
|
31
src/app.js
31
src/app.js
|
@ -10,6 +10,7 @@ if (lidarrUrl.endsWith(`/`))
|
|||
const apiKey = process.env.LIDARR_API_KEY;
|
||||
const unmonitor = process.env.UNMONITOR || `false`;
|
||||
const printUnmonitored = process.env.OUTPUT_UNMONITORED || `false`;
|
||||
const doDelete = process.env.DELETE || `false`;
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -67,7 +68,20 @@ for (const artistId of artistIdsObject)
|
|||
{
|
||||
const single = singles.find((album) => album.id === singleId);
|
||||
if (single.statistics.trackFileCount > 0)
|
||||
console.log(`"${ singleNames[singleIds.indexOf(singleId)] }" by ${ artistName } is downloaded but unmonitored, consider deleting it. ${ lidarrUrl }/album/${ single.foreignAlbumId }`);
|
||||
{
|
||||
if (doDelete === `true`)
|
||||
{
|
||||
await fetch(`${ lidarrUrl }/api/v1/album/${ singleId }?apikey=${ apiKey }`, {
|
||||
method: `DELETE`,
|
||||
headers: {
|
||||
"Content-Type": `application/json`
|
||||
},
|
||||
});
|
||||
console.log(`"${ singleNames[singleIds.indexOf(singleId)] }" by ${ artistName } deleted.`);
|
||||
}
|
||||
else
|
||||
console.log(`"${ singleNames[singleIds.indexOf(singleId)] }" by ${ artistName } is downloaded but unmonitored, consider deleting it. ${ lidarrUrl }/album/${ single.foreignAlbumId }`);
|
||||
}
|
||||
}
|
||||
else if (printUnmonitored === `false` && unmonitor === `true`)
|
||||
{
|
||||
|
@ -79,9 +93,20 @@ for (const artistId of artistIdsObject)
|
|||
body: JSON.stringify({
|
||||
albumIds: [singleId],
|
||||
monitored: false
|
||||
})
|
||||
}),
|
||||
});
|
||||
console.log(`Unmonitored "${ singleNames[singleIds.indexOf(singleId)] }" by ${ artistName }`);
|
||||
if (doDelete === `true`)
|
||||
{
|
||||
await fetch(`${ lidarrUrl }/api/v1/album/${ singleId }?apikey=${ apiKey }`, {
|
||||
method: `DELETE`,
|
||||
headers: {
|
||||
"Content-Type": `application/json`
|
||||
},
|
||||
});
|
||||
console.log(`"${ singleNames[singleIds.indexOf(singleId)] }" by ${ artistName } unmonitored & deleted.`);
|
||||
}
|
||||
else
|
||||
console.log(`Unmonitored "${ singleNames[singleIds.indexOf(singleId)] }" by ${ artistName }`);
|
||||
}
|
||||
else if (printUnmonitored === `false` && unmonitor === `false`)
|
||||
console.log(`"${ singleNames[singleIds.indexOf(singleId)] }" is also found on ${ album.title } by ${ artistName }`);
|
||||
|
|
Loading…
Reference in New Issue