Running Emby en Radarr/Sonarr on different servers or in different container can be a pain in the ass to get your content scanned.
But it is much easier than you think if you know what’s going on inside the services. The TL;DR is keep your content path the same in EMBY and in Sonarr/Radarr. If you don’t keep them the same, you run into trouble.
First, I show two options when you can’t keep the paths the same (say you have a linux node running EMBY and a Windows (don’t mention it) node for Sonarr/Radarr. It’s obvious the paths will never be the same, as Linux will give you a PATH like below.
/home/user/video/movies/Your Old Movie (1921)/Your.Old.Movie.1921.Remux-2160p.mkv
Where Windows (sh*t have to mention it again) will give you a path
D:\data\video\movies\Your Old Movie (1921)\Your.Old.Movie.1921.Remux-2160p.mkv
The slashed only (Linux forward slash / and Windows a backslash \ ) already makes this a problem.
Then I will show you two options if you can the PATHs the same. This can be done when:
- You run all your software on one node, therefor the content PATHs in EMBY en Sonarr/Radarr will be the same (Obviously)
- When you run multiple nodes of the SAME OS and run the services (EMBY, Sonarr, Radarr) in DOCKER, and therefore you can keep the PATHs the same inside your docker containers.
- When you run multiple nodes of THE SAME OS (for EMBY, Sonarr and Radarr) and store the content on the same network share (a third node) via Radarr/Sonarr and EMBY will scan the content on that same third node.
Option 1 different paths (you can’t keep the paths the same)
This method triggers a complete library scan. This work fine but is suboptimal. When your library is large, or you frequently trigger the library scan, it will have an impact on EMBY.
curl -X POST "${EMBY_HOST}/Emby/Library/Refresh?api_key=${EMBY_APIKEY}" --data ""
Where:
EMBY_HOST = http:/192.168.1.1:0896 or https://www.yourdoamin.com:443
EMBY_APIKEY = XXXXXXYYYYYZZZZZZ
Option 2 different paths (you can’t keep the paths the same)
This method tiggers a scan for a certain library in your collection (EMBY_PARENT_ID). The advance to the pervious option is that you only trigger one collection in the library. The downside is you have to fiddle around with the EMBY_PARENT_ID. These can be obtained from the URL when you open the collection in EMBY.
curl -X POST "${EMBY_URL}/emby/Items/${EMBY_PARENT_ID}/Refresh?Recursive=true&MetadataRefreshMode=Default&ImageRefreshMode=Default&ReplaceAllMetadata=false&ReplaceAllImages=false&api_key=${EMBY_APIKEY}" -H "accept: */*" -d “”
Where:
EMBY_HOST = http:/192.168.1.1:0896 or https://www.yourdoamin.com:443
EMBY_APIKEY = XXXXXXYYYYYZZZZZZ
EMBY_PARENT_ID = 12
Option 3 Same paths (you can keep the path in *arr equal to the path in EMBY)
This is the simplest to configure the default trigger in Sonarr/Radarr
Option 4 Same paths (you can keep the path in *arr equal to the path in EMBY)
This method tiggers a scan for a certain library in your collection. The advance to the pervious option is that you add your own logic to the scan. The other advance is that you can fill-out Path and UpdateType from the environment variables in Linux (or your container)
curl -X POST "${EMBY_URL}/emby/Library/Media/Updated?api_key=${EMBY_APIKEY}" -H "accept: */*" -H "Content-Type: application/json" -d "{\"Updates\":[{\"Path\":\"${Path}\",\"UpdateType\":\"${UpdateType}\"}]}"
Where:
EMBY_HOST = http:/192.168.1.1:0896 or https://www.yourdoamin.com:443
EMBY_APIKEY = XXXXXXYYYYYZZZZZZ
Path = /movies/Old Movie, The (1921)/The.Old.Movie.1921.Bluray-2160p.mkv
UpdateType = [ Created | Modified | Deleted ] (optional)
Here is an example script I use for Radarr and Sonarr. I like separate scripts for Radarr and Sonarr, but you easily merge them and create one script for both Radarr and Sonarr.
Radarr
#!/bin/bash
NOW=$(date +"%d-%m-%Y %H:%M")
LOG_FILE="/logging/radarr/emby_scan.txt"
TMP_FILE="/tmp/tmp_emby_radarr.txt"
DL_FILE="/scripts/dl_radarr.txt"
DEL_FILE="/scripts/del_radarr.txt"
REN_FILE="/scripts/ren_radarr.txt"
EMBY_URL="https://emby.yourdomain.com"
EMBY_RADARR_APIKEY="xxxyyyyyzzz"
if [ "${radarr_eventtype}" != "" ]; then
if [ "${radarr_eventtype}" == "ApplicationUpdate" ] || [ "${radarr_eventtype}" == "MovieAdded" ] || [ "${radarr_eventtype}" == "Grab" ] || [ "${radarr_eventtype}" == "HealthIssue" ] || [ "${radarr_eventtype}" == "Test" ]; then
(echo "${NOW} - [Emby Library Scan] Radarr Event Type is ${radarr_eventtype}, exiting."; cat ${LOG_FILE}) > ${TMP_FILE}; mv ${TMP_FILE} ${LOG_FILE}
exit
fi
(echo "${NOW} - [Emby Library Scan] Radarr Event Type is ${radarr_eventtype}, updating Emby Library for ${radarr_movie_title}."; cat ${LOG_FILE}) > ${TMP_FILE}; mv ${TMP_FILE} ${LOG_FILE}
if [ "$radarr_eventtype" == "Download" ]; then
echo "${radarr_movie_title} (${radarr_movie_year})" >> ${DL_FILE}
UpdateType="Created"
Path="${radarr_movie_path}"
fi
if [ "${radarr_eventtype}" == "MovieDelete" ]; then
echo "${radarr_movie_title} (${radarr_movie_year})" >> ${DEL_FILE}
UpdateType="Deleted"
Path="${radarr_movie_path}"
fi
if [ "$radarr_eventtype" == "Rename" ]; then
echo "${radarr_movie_title} (${radarr_movie_year})" >> ${REN_FILE}
UpdateType="Modified"
Path="${radarr_movie_path}"
fi
curl -X POST "${EMBY_URL}/emby/Library/Media/Updated?api_key=${EMBY_RADARR_APIKEY}" -H "accept: */*" -H "Content-Type: application/json" -d "{\"Updates\":[{\"Path\":\"${Path}\",\"UpdateType\":\"${UpdateType}\"}]}"
else
(echo "${NOW} - [Emby Library Scan] Radarr Event Type is empty."; cat ${LOG_FILE}) > ${TMP_FILE}; mv ${TMP_FILE} ${LOG_FILE}
fi
# write a status file with date of last run. Helps troubleshoot that cron task is running.
echo "$(basename $0) last run was at $(date)" > /logging/radarr/_$(basename $0)_lastrun.txt
Sonarr
#!/bin/bash
NOW=$(date +"%d-%m-%Y %H:%M")
LOG_FILE="/logging/sonarr/emby_scan.txt"
TMP_FILE="/tmp/tmp_emby_sonarr.txt"
DL_FILE="/scripts/dl_sonarr.txt"
DEL_FILE="/scripts/del_sonarr.txt"
REN_FILE="/scripts/ren_sonarr.txt"
EMBY_URL="https://emby.yourdomain.com"
EMBY_SONARR_APIKEY="zzzzzyyyyyxxxxx"
if [ "${sonarr_eventtype}" != "" ]; then
if [ "${sonarr_eventtype}" == "ApplicationUpdate" ] || [ "${sonarr_eventtype}" == "Grab" ] || [ "${sonarr_eventtype}" == "HealthIssue" ] || [ "${sonarr_eventtype}" == "Test" ]; then
(echo "${NOW} - [Emby Library Scan] Sonarr Event Type is ${sonarr_eventtype}, exiting."; cat ${LOG_FILE}) > ${TMP_FILE}; mv ${TMP_FILE} ${LOG_FILE}
exit
fi
(echo "${NOW} - [Emby Library Scan] Sonarr Event Type is ${sonarr_eventtype}, updating Emby Library for ${sonarr_series_title} - ${sonarr_episodefile_episodetitles}."; cat ${LOG_FILE}) > ${TMP_FILE}; mv ${TMP_FILE} ${LOG_FILE}
if [ "$sonarr_eventtype" == "Download" ]; then
echo "${sonarr_series_title} - ${sonarr_episodefile_episodetitles}" >> ${DL_FILE}
UpdateType="Created"
Path="${sonarr_episodefile_path}"
fi
if [ "$sonarr_eventtype" == "EpisodeFileDelete" ]; then
echo "${sonarr_series_title} - ${sonarr_episodefile_episodetitles}" >> ${DEL_FILE}
UpdateType="Deleted"
Path="${sonarr_episodefile_path}"
fi
if [ "$sonarr_eventtype" == "SeriesDelete" ]; then
echo "${sonarr_series_title}" >> ${DEL_FILE}
UpdateType="Deleted"
Path="${sonarr_series_path}"
fi
if [ "$sonarr_eventtype" == "Rename" ]; then
echo "${sonarr_series_title}" >> ${REN_FILE}
UpdateType="Modified"
Path="${sonarr_series_path}"
fi
curl -X POST "${EMBY_URL}/emby/Library/Media/Updated?api_key=${EMBY_SONARR_APIKEY}" -H "accept: */*" -H "Content-Type: application/json" -d "{\"Updates\":[{\"Path\":\"${Path}\",\"UpdateType\":\"${UpdateType}\"}]}"
else
(echo "${NOW} - [Emby Library Scan] Sonarr Event Type is empty."; cat ${LOG_FILE}) > ${TMP_FILE}; mv ${TMP_FILE} ${LOG_FILE}
fi
# write a status file with date of last run. Helps troubleshoot that cron task is running.
echo "$(basename $0) last run was at $(date)" > /logging/sonarr/_$(basename $0)_lastrun.txt
These scripts also maintain lists of the content names, so they can be used in reporting or notification. You can, of course, strip these.
I run these scripts in the Connect section in Radarr/Sonarr.
Hello Marco,
I just sumbled upon this. I have issue for about a year now, Sonarr/Radarr not notifying Emby to scan the library. It just stopped at some point, no idea why.
Now, a bit of help if you can spare some time. I have sonarr, radarr and emby running as docker containers on Linux. All media is stored on NAS, and mounted on /opt/media, andthis path is mounted to docker containers. But, notification to scan library isn’t working.
You did mention that all paths should be same and they are, but still not working. I still have to turn debug logging to check further on.
Any other idea except what you already mentioned in this post?
Hi Marjan,
Below are my compose files for Radarr and Emby
As you can see “on the INTERNAL(!!) side” of docker my directories are “/movies” in both compose-files (Emby and Radarr).
Are you sure this is the case at your end too??
Marco
version: "2.1"
services:
radarr:
image: lscr.io/linuxserver/radarr:latest
container_name: radarr
environment:
- TZ=Europe/Amsterdam
- PUID=1031
- PGID=100
- UMASK=0
volumes:
- /volume1/docker/radarr/config/:/config
- /volume1/docker/radarr/scripts/:/scripts
- /volume1/video/movies/:/movies <<------ HERE !!!! - /volume1/downloads/:/downloads - /volume1/logging/:/logging ports: - 7878:7878 restart: unless-stopped network_mode: bridge
version: "2.1"
services:
emby:
image: emby/embyserver:beta
container_name: emby
environment:
- UID=1001
- GID=100
- GIDLIST=100
volumes:
- /etc/localtime:/etc/localtime:ro
- /home/admin/docker/emby/config:/config
- /home/admin/docker/emby/backup:/backup
- /mnt/video/series/:/series
- /mnt/video/seriesdv/:/seriesdv
- /mnt/video/movies/:/movies <<----- HERE !!!! - /mnt/video/moviesdv/:/moviesdv - /mnt/homevideo/homevideos/:/homevideos - /mnt/music/:/music - /mnt/boeken/:/books ports: - 8097:8096 - 8921:8920 restart: unless-stopped network_mode: bridge
Hi Marco,
Thanks for quick reply. Yes, after I wrote my message, I realized that this might be the thing that I should do. So, I changed the “internal” side, like you said. Hopefully, it’ll help.
Thank you again for the reply.
Cheers
The internal side it important! That’s what the applications will see. Not the external side of things.
Thank you, it help me out a lot with Radarr and Sonarr, but was wondering if you ever got it to work on Lidarr.
Hi Aben, I never tried it with Lidarr. I’m assuming you tried it, and did get it to work, correct?
Hi Marco, it looks like it does, need to test it a bit more, I can give you the script if you want to test it and improve it to post it in your page.
Hi Aben,
Post your script here : https://privatebin.mjanssen.nl
And share de URL.
Marco
The link you provided didn’t work, so I posted on this one instead https://pastebin.com/iy3FDFdw.
TrackRetag can be added to the script, I didn’t have use for it.
Hi Aben, Sorry I had the firewall blocking you from accessing my pastebin.
Thanks for your script “Lidarr”. I will take a look at it, although I don’t use lidarr myself.
Let me know if you run in any trouble using your script. I happy to help.