Jump to content

Changes to library directories not causing a library scan


Recommended Posts

Posted

The server is running on windows 11, the media is on a Synology NAS via SMB

If I manually scan the libraries, all is good.

Enable real time monitoring is on the library settings

However, adding media or changing the directory structure, or even doing a "touch" on a filename to create a new file does nothing.

Any ideas on how to track this down?

Posted

Step 1: ssh into NAS
Step 2: cd to root of TV video
Step 3: Inside Emby, rotate the log
Step 4: in the shell at the root of TV
 

# touch fubar.mkv

Step 5: Send log showing nothing.

2024-02-06 18:08:42.267 Info App: Emby Server Version: 4.8.0.80
2024-02-06 18:08:42.267 Info App: Emby
    Command line: C:\Emby-Server\system\EmbyServer.dll -service
    Operating system: Microsoft Windows 10.0.22631
    Framework: .NET 6.0.26
    OS/Process: x64/x64
    Runtime: C:/Emby-Server/system/System.Private.CoreLib.dll
    Processor count: 20
    Data path: C:\Emby-Server\programdata
    Application path: C:\Emby-Server\system
2024-02-06 18:08:42.267 Info App: Logs path: C:\Emby-Server\programdata\logs
2024-02-06 18:08:42.267 Info App: Cache path: C:\Emby-Server\programdata\cache
2024-02-06 18:08:42.267 Info App: Internal metadata path: C:\Emby-Server\programdata\metadata
2024-02-06 18:08:42.267 Info App: Transcoding temporary files path: c:\EmbyTemp\transcoding-temp
2024-02-06 18:08:42.267 Info App: Plugins:
    Auto Movie Version Collections 1.0.0.0
    Backup & Restore 1.6.1.0
    Bluray Folder Support 1.0.2.0
    Cinema Intros 1.0.47.0
    Diagnostics PlugIn 4.8.0.58
    Disk Space 1.0.6.1
    DLNA 1.3.7.0
    Dvd Folder Support 1.0.0.0
    Emby Guide Data 1.0.12.0
    Fanart.tv 1.0.16.0
    Folder Sync 3.2.6.0
    M3U TV Tuner 1.0.20.0
    Movie Theme Songs 1.7.5.0
    Movie Theme Videos 1.7.5.0
    MovieDb 1.7.4.0
    MusicBrainz 1.0.22.0
    Nfo Metadata 1.0.79.0
    OMDb 1.0.21.0
    Open Subtitles 1.0.51.0
    Playback Reporting 2.1.0.5
    Port Mapper 1.2.4.0
    Reports 1.0.50.0
    Statistics 3.1.1.0
    Studio Images 1.0.3.0
    TheAudioDb 1.0.18.0
    Theme Songs 1.6.6.7
    TheTVDB 1.4.5.0
    TV Theme Videos 1.7.5.0
    Webhooks 1.0.35.0
    XmlTV 1.1.6.0
2024-02-06 18:08:42.267 Info TaskManager: Rotate log file Completed after 0 minute(s) and 0 seconds
2024-02-06 18:10:01.050 Info LibraryMonitor: TV (\\mediabox\videos\TV) will be refreshed.
2024-02-06 18:10:03.416 Info Server: http/1.1 POST http://emby_remote_ip/emby/Sessions/Capabilities/Full?X-Emby-Client=Emby Web&X-Emby-Device-Name=Google Chrome Windows&X-Emby-Device-Id=2f0cac4c-6191-457d-af2b-2b6c53c55b35&X-Emby-Client-Version=4.8.0.80&X-Emby-Token=x_secret5_x&X-Emby-Language=en-us&reqformat=json. UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
2024-02-06 18:10:03.416 Info Server: http/1.1 Response 204 to host7. Time: 0ms. POST http://emby_remote_ip/emby/Sessions/Capabilities/Full?X-Emby-Client=Emby Web&X-Emby-Device-Name=Google Chrome Windows&X-Emby-Device-Id=2f0cac4c-6191-457d-af2b-2b6c53c55b35&X-Emby-Client-Version=4.8.0.80&X-Emby-Token=x_secret5_x&X-Emby-Language=en-us&reqformat=json
 

Posted

Looks like you added an smb share directly to Emby. Emby's built-in smb support doesn't support the realtime monitor.
What you should do is instead use Synology's support by mounting the smb share to a local path in Synology, then add the local path into Emby Server instead of the SMB share.

That still doesn't guarantee it will be supported because it needs to be something that INotify supports, but it at least gives you a better shot.

Posted
59 minutes ago, Luke said:

Looks like you added an smb share directly to Emby. Emby's built-in smb support doesn't support the realtime monitor.
What you should do is instead use Synology's support by mounting the smb share to a local path in Synology, then add the local path into Emby Server instead of the SMB share.

That still doesn't guarantee it will be supported because it needs to be something that INotify supports, but it at least gives you a better shot.

The Server is running on windows, and has a SMB path to a linux synology box.

Im not sure what you mean by "use Synology's support by mounting the smb share to the local path in Synology, then add the local path into emby server"

Thanks 

Posted

I can a mount from the windows emby server onto the synology box, I get.


But how would that create a local path on the emby server?

Posted

Sorry, my mistake. Server on windows. So forget everything I said. So from my experience, there is very limited realtime monitor support for network paths when the server is running on windows. At minimum I think both machines need to be running windows, but I generally wouldn't expect it to work.

Posted
Just now, Luke said:

Sorry, my mistake. Server on windows. So forget everything I said. So from my experience, there is very limited realtime monitor support for network paths when the server is running on windows. At minimum I think both machines need to be running windows, but I generally wouldn't expect it to work.

OK. thanks.  For work, I have worked on a number of solutions for this, for cross platform file monitoring.

One solution that worked, is on a per directory basis, storing the last timestamp in a file, then checking the directory against that timestamp on the half hour or so.  Expensive but could be done in a background thread
 

Posted

Sounds expensive indeed.

Posted

I had also written a mini server at one point, where you gave it a list of directories to monitor, and it ran in the background.  It could be queried to see if any file or dir had changed. 

Essentially it worked using rpc or network calls.  But it wouldn't be any better than a multithreaded solution.  

  • Thanks 1
adminExitium
Posted

You may want to try using this: https://github.com/Cloudbox/autoscan/

Run it on the NAS (may need to be run on the host rather than via docker) and specify the connection details of the Windows Emby Server.

Posted
On 2/7/2024 at 12:38 AM, adminExitium said:

You may want to try using this: https://github.com/Cloudbox/autoscan/

Run it on the NAS (may need to be run on the host rather than via docker) and specify the connection details of the Windows Emby Server.

Thanks.  very interesting.  

 

Posted (edited)

@Lukeand others who might need this. here is my solution.

I created a triggered task that runs the following script

MONITORDIR=/volume1/videos
inotifywait -m -r -e create,modify --format '%w%f' /volume1/videos /volume1/photos /volume1/music | while read NEWFILE; do
    curl -X 'POST' \
	  "http://server:serverport/emby/Library/Refresh?api_key=myapikey" \
      -H 'accept: */*' \
      -d ''
    sleep 10m
done

Essentially anytime any file into any of my library directories, it posts a refresh call to the server.  Works like a charm, the sleep just prevents it from happening too often when multiple files are copied/modified at once

It may not need modified, but it doesnt hurt.

I wish there was a way to get the name of the process (or even the process ID) that did the mod/creation.  I would then filter out emby/ffmpeg etc.
 

Edited by HawkXP71
  • Like 1
  • Thanks 1
  • 3 months later...
Posted (edited)

@HawkXP71

(First of all sorry for my English)
 

Thanks for the script.
With some modifications it worked on my synology nas. But I have another media library with thousands of  home photos and videos and this script also starts scanning them.

I would like to exclude this particular library from being scanned

Is there a way to modify the script to avoid scanning this specific library?

Edited by reyist
HawkXP71
Posted
1 hour ago, reyist said:

@HawkXP71

(First of all sorry for my English)
 

Thanks for the script.
With some modifications it worked on my synology nas. But I have another media library with thousands of  home photos and videos and this script also starts scanning them.

I would like to exclude this particular library from being scanned

Is there a way to modify the script to avoid scanning this specific library?

I think using the /items/{id}/refresh  API you should be able to create individual inotifiywait commands 

  • 3 weeks later...
Posted

With chat gpt did this:
 

#!/bin/bash

EMBY_SERVER="http://192.168.1.3:8096"
API_KEY="1234567890"
MOVIES_LIBRARY_ID="6153"
TV_LIBRARY_ID="7245"
LAST_UPDATE_FILE="/tmp/emby_last_update"

# Function to send an update request
update_library() {
    local ITEM_ID=$1
    local LIBRARY_PATH=$2
    local CURRENT_TIME=$(date +%s)
    local LAST_UPDATE=0

    # Check the last update time
    if [ -f "$LAST_UPDATE_FILE" ]; then
        LAST_UPDATE=$(cat "$LAST_UPDATE_FILE")
    if

    # If enough time has passed since the last update, update the library
    if [ $((CURRENT_TIME - LAST_UPDATE) -gt 300 ]; then # 300 seconds (5 minutes) delay.
        echo $CURRENT_TIME > "$LAST_UPDATE_FILE
        curl -X 'POST' \.
        "$EMBY_SERVER/emby/Items/$ITEM_ID/Refresh?Recursive=true&ImageRefreshMode=Default&MetadataRefreshMode=Default&ReplaceAllImages=false&ReplaceAllMetadata=false&api_key=$API_KEY"" \
        -H 'Accept: */*' \
        -d ''
    else
        echo "The last update was too recent. Skip the update."
    fi
}

# Main intercept loop
/opt/bin/inotifywait -m -r -e create,modify,delete --format '%w%f' /volume1/data/media/movies /volume1/data/media/tv | while reading NEWFILE; do
    if [[ "$NEWFILE" == /volume1/data/media/movies/* ]]]; then
        update_library "$MOVIES_LIBRARY_ID" "/volume1/data/media/movies"
    elif [[ "$NEWFILE" == /volume1/data/media/tv/* ]]; then
        update_library "$TV_LIBRARY_ID" "/volume1/data/media/tv"
    if
done


 

 

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...