Jump to content

Scan of library after media added


Recommended Posts

Posted

Hi There.

I have a issue/question on scanning the library.

When a piece of content is imported by Radarr/Sonarr, you can set up a "notification" so Emby will update its library. This is standard option in Radarr/Sonarr. You can choose "EMBY" in notifications, set it up and it's suppose to trigger a Library update.

However this never happens for me, for what I can tell from the logging, the trigger happens but the library does not update.

 

What I did was write the script below. Now I also set a "Notification" in Raddar(or Sonarr), choose for a custom script. And choose the run the script when a movie is import. Now the library is updated

Key here is that I call "curl --data '' http://$EMBY_HOST:$EMBY_PORT/Emby/Library/Refresh?api_key=$EMBY_RADARR_APIKEY", this will trigger a library scan.

Question: 

1. Is the default trigger from Radarr/Sonarr broken?

2. Is some wrong of the Emby site?

3. Why will "curl --data '' http://$EMBY_HOST:$EMBY_PORT/Emby/Library/Refresh?api_key=$EMBY_RADARR_APIKEY" given the desired result, and the default trigger doesn't?

 

If you need more info, let me know.

 

#!/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"
EMBY_HOST="192.168.xxx.xxx"
EMBY_PORT="8097"
EMBY_RADARR_APIKEY="xxyyzz"

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
  elif [ "${radarr_eventtype}" == "MovieDelete" ]; then
    echo "${radarr_movie_title} (${radarr_movie_year})" >> $DEL_FILE
  fi
  
  curl --data '' http://$EMBY_HOST:$EMBY_PORT/Emby/Library/Refresh?api_key=$EMBY_RADARR_APIKEY
    
else
  (echo "$NOW - [Emby Library Scan] Radarr Event Type is empty for ${radarr_movie_title}."; 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

 

Eigeplackter
Posted

Why don‘t you use the „Watch library“ Real-Time-Surveillance option in Emby ?

 

Option is in libraries- edit 3rd from top I think.

  • Thanks 1
Posted
1 hour ago, Eigeplackter said:

Why don‘t you use the „Watch library“ Real-Time-Surveillance option in Emby ?

 

Option is in libraries- edit 3rd from top I think.

998478991_CleanShot2022-12-29at10_49.08@2x.thumb.png.ace1a79e7cf72a75643790d0e7c3facb.png

Eigeplackter
Posted

Are you sure ?

Maybe it‘s working for me as it‘s actually a path on my Synology where Emby is running top. But it is a shared folder.

 

F26AD029-CB18-4B03-ACDB-C5D47567CB83.jpeg.e4b5761e9bfa5f13432298a9ae85f9e5.jpeg

Posted
Just now, Eigeplackter said:

Are you sure ?

Maybe it‘s working for me as it‘s actually a path on my Synology where Emby is running top. But it is a shared folder.

 

F26AD029-CB18-4B03-ACDB-C5D47567CB83.jpeg.e4b5761e9bfa5f13432298a9ae85f9e5.jpeg

Yes! That is way it is working for you. From the perspective of Emby , The Synology is not a share but a "local" drive.

I have an Intel NUC running with EMBY, which is connect through shares to a Synology. That's a different set up.

But thanks anyway... you help is appreciated !

Posted
6 hours ago, Marc0 said:

998478991_CleanShot2022-12-29at10_49.08@2x.thumb.png.ace1a79e7cf72a75643790d0e7c3facb.png

It's not supported on all file systems. It will be more likely to work if you mount the network share to a local folder on the Synology and then import that path into emby server.

  • 2 weeks later...
Posted
On 12/29/2022 at 5:43 PM, Luke said:

It's not supported on all file systems. It will be more likely to work if you mount the network share to a local folder on the Synology and then import that path into emby server.

Luke can you explain this is bit more?

Posted

It's limited to file systems supported by both INotify and the .Net runtime, which SMB on linux is not. That's why you need to mount it to a local share to give the realtime monitor a better chance of working. 

Posted
41 minutes ago, Luke said:

It's limited to file systems supported by both INotify and the .Net runtime, which SMB on linux is not. That's why you need to mount it to a local share to give the realtime monitor a better chance of working. 

But what do you exactly mean "mount to a local share"?

I mount the the remote CIFS path at a mount point on the node that runs Emby... Is there another way?

Posted
On 1/12/2023 at 2:13 PM, Marc0 said:

But what do you exactly mean "mount to a local share"?

I mount the the remote CIFS path at a mount point on the node that runs Emby... Is there another way?

And then it gets a local path, right? What path did you import into Emby library setup?

Posted
6 hours ago, Luke said:

And then it gets a local path, right? What path did you import into Emby library setup?

I browsed in Emby to that path in library settings. 

Posted
19 minutes ago, Marc0 said:

I browsed in Emby to that path in library settings. 

What path?

Posted (edited)

In the fstab file:

//192.168.xxx.xxx/video  /mnt/video

Then in docker-compose

/mnt/video  to /video

The /video is picked up by Emby

Does this help?

 

 

Edited by Marc0
Posted

It doesn't work with network file systems (remote storage) regardless of how they're mounted or accessed.

 

  • Agree 1
Posted

I need to add that this isn't a problem with Emby but a limitation of the inotify API which is kernel based and does not detect changes made on network shares. In those cases it's the host exporting those shares that detects the change on storage local to itself. It's a limitation of the kernel/OS.

 

  • Agree 1
Posted
1 minute ago, Q-Droid said:

I need to add that this isn't a problem with Emby but a limitation of the inotify API which is kernel based and does not detect changes made on network shares. In those cases it's the host exporting those shares that detects the change on storage local to itself. It's a limitation of the kernel/OS.

 

Agreed Q-Droid, I do understand all of this, and knew this.

 

Going back to the original question of this thread:

- Why is the built-in radarr/sonarr trigger for Emby not working? But When I trigger my own script (see above), the library is scanned.

To me it seems a sonarr/radarr problem with the built in trigger. But I was verifying here if it's just me.

Posted
4 hours ago, Marc0 said:

Agreed Q-Droid, I do understand all of this, and knew this.

 

Going back to the original question of this thread:

- Why is the built-in radarr/sonarr trigger for Emby not working? But When I trigger my own script (see above), the library is scanned.

To me it seems a sonarr/radarr problem with the built in trigger. But I was verifying here if it's just me.

Don't know. We'd have to look at an example.

Thanks.

Posted
10 hours ago, Marc0 said:

Agreed Q-Droid, I do understand all of this, and knew this.

 

Going back to the original question of this thread:

- Why is the built-in radarr/sonarr trigger for Emby not working? But When I trigger my own script (see above), the library is scanned.

To me it seems a sonarr/radarr problem with the built in trigger. But I was verifying here if it's just me.

Have you been able to check what the *arrs are using for the trigger? Perhaps they haven't kept up with changes in the Emby API, that is if it has changed over time. 

Happy2Play
Posted

Do not know code but isn't the curl above missing POST?

curl -X POST "http://$EMBY_HOST:$EMBY_PORT/emby/Library/Refresh?api_key=$EMBY_RADARR_APIKEY"

Posted

With curl it is a POST.

 -d, --data <data>     HTTP POST data (H)
 

  • Thanks 1
Posted

I see this API which appears to be more granular but no documentation on the expected input values. My guess is this would be preferable to a full library scan/refresh.

/Library/Media/Updated
{
  "Updates": [
    {
      "Path": "string",
      "UpdateType": "string"
    }
  ]
}

Posted

Hmmmm seems so. But we need so docs to make it work properly. 

  • 2 weeks later...
Posted
On 1/21/2023 at 2:25 PM, Q-Droid said:

I see this API which appears to be more granular but no documentation on the expected input values. My guess is this would be preferable to a full library scan/refresh.

/Library/Media/Updated
{
  "Updates": [
    {
      "Path": "string",
      "UpdateType": "string"
    }
  ]
}

Complete not clear what "UpdateType" is...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...