Importing Existing Downloads into Lidarr
Importing Existing Downloads into Lidarr
Background
I keep my qBittorrent complete directory on my NAS (data/torrents/complete). When a download finishes, I want Lidarr to pick the album up and hard-link it into the library — no re-download, no duplicate data.
Lidarr 3.1 removed the old “Import Existing” command and the import-folders configuration entirely, which made the obvious paths dead ends. But the import pipeline still accepts an explicit path, so the whole thing is doable through the REST API. Here is the process, including the gotchas I hit.
1. Find the album’s internal ID
The album URL in the web UI uses the MusicBrainz UUID (foreignAlbumId), but the API uses the internal integer ID. They’re different — don’t paste the UUID from the URL into API calls.# List artists, find the internal artist ID
curl -sk -H "X-Api-Key: $API_KEY" "$LIDARR_URL/api/v1/artist" \
| jq '.[] | select(.artistName | test("jony"; "i")) | {id, artistName}'
# List that artist's albums
curl -sk -H "X-Api-Key: $API_KEY" "$LIDARR_URL/api/v1/album?artistId=557" \
| jq '.[] | {id, title, releaseDate}'
2. Check the copy mode first
In 3.1.x the media-management settings moved out of the old /config/import endpoint (which now returns 404) into /config/mediamanagement. The hard-link setting is copyUsingHardlinks:curl -sk -H "X-Api-Key: $API_KEY" "$LIDARR_URL/api/v1/config/mediamanagement" \
| jq '{copyUsingHardlinks, skipFreeSpaceCheckWhenImporting}'
# { "copyUsingHardlinks": true, ... }
With copyUsingHardlinks: true, import transfers use hard links (falling back to a real copy only if the filesystem can’t link — i.e. source and destination are on different filesystems).
3. Run the import
The command in 3.1.x is DownloadedAlbumsScan (the old ImportExistingCommand is gone). It takes the album folder’s absolute path as seen from inside the Lidarr container:curl -sk -X POST -H "X-Api-Key: $API_KEY" -H 'Content-Type: application/json' \
-d '{
"name": "DownloadedAlbumsScan",
"path": "/mnt/unas/data/torrents/complete/Jony - Список твоих мыслей (2019) [FLAC]",
"importMode": 0
}' \
"$LIDARR_URL/api/v1/command"
importMode is 0 = auto (follows copyUsingHardlinks), 1 = move, 2 = copy. Auto is what you want for hard links.
The response is a command object with an id and status: "started".
4. Verify
Poll the command, then confirm the tracks landed in the library:# Command result
curl -sk -H "X-Api-Key: $API_KEY" "$LIDARR_URL/api/v1/command/791772" \
| jq '{status, result}'
# Album statistics
curl -sk -H "X-Api-Key: $API_KEY" "$LIDARR_URL/api/v1/album/3982" \
| jq '.statistics'
# Track file paths
curl -sk -H "X-Api-Key: $API_KEY" "$LIDARR_URL/api/v1/trackfile?albumId=3982" \
| jq '.[].path'
Finally, confirm they’re actually hard links (matching inodes, link count 2) from a shell on the NAS:ls -li '/mnt/unas/data/torrents/complete/Jony - Список твоих мыслей (2019) [FLAC]' \
'/mnt/unas/data/media/music/JONY (Russian artist)/Список твоих мыслей (2019)'
Since they’re hard links, deleting the complete/ folder afterwards is safe — the library keeps the data and nothing is freed on disk.
Gotchas
- Old endpoint names 404.
/api/v1/config/import,/api/v1/config/root, etc. no longer exist in 3.1.x. The current endpoints (per the OpenAPI spec) are things like/api/v1/config/mediamanagementand/api/v1/config/host. - Command names drop the suffix.
CommandControllermatches names viaclassName.Replace("Command", ""), so sending"name": "DownloadedAlbumsScanCommand"returns a 500 (“Sequence contains no matching element”). Send"DownloadedAlbumsScan". - UI UUIDs are not API IDs.
/album/33f8a975-…in the browser is the MusicBrainz ID; the API’s/album/{id}wants the internal integer. - The
isAdmin: falseflag in/system/statusis a red herring. Lidarr has no user roles; it just reflects that authentication is enabled. A standard API key has full access.