Customize Jellyfin Scan Frequencies
Introduction
In a previous article, I mentioned that ‘Jellyfin’s scheduled task “Scan Media Library” does not consume resources and can run frequently without issues’. In fact, this statement is not entirely correct. The resource consumption of the task depends on the number of media/files.
Recently, I developed a project to scrape videos while automatically generating NFO files and video posters. In this new video directory, there are up to 2000 files (mostly NFO and poster images, with videos not yet downloaded), organized into four-level subdirectories. However, the CPU usage of the scheduled task has increased significantly, indicating an issue.
After some research, I found that using crontab to periodically call the Jellyfin API is currently the only solution to customize scan frequencies for different media libraries.
Steps
Disable Scheduled Task
Navigate to ‘Dashboard | Scheduled Tasks | Scan Media Library’ and delete the existing task:
Obtain an API Key
Navigate to ‘Dashboard | API Keys’ and create a new one:
Get the API Endpoint
I recommend using F12 to capture the request:
Press F12 before clicking ‘Refresh’ and find the corresponding request:
/Items/LibraryID/Refresh?ScanParameters
– we can directly use this URL.
crontab
1 | Edit |
curl format:
1 | curl -k -X POST "https://IPAddress:Port/Items/LibraryID/Refresh?Recursive=true&ImageRefreshMode=Default&MetadataRefreshMode=Default&ReplaceAllImages=false&ReplaceAllMetadata=false" -H "Authorization: MediaBrowser Token=APIKey" |
crontab format:
1 | New Episodes: every ten minutes |
Other frequency configurations:
- Every hour:
0 * * * *
; - Weekly: e.g.,
0 17 * * 0
, every Sunday at 5 PM; - Bi-weekly: e.g.,
0 11 1,15 * *
, 11 AM on the 1st and 15th of every month;
View crontab logs:
1 | 1. Use journalctl |
Results
This software is NetData, and I will write a blog post about it later.
The red one represents scanning the media library of scraped videos, while the blue one is for scanning the anime of the latest season.
Observations:
-
The average value of the blue does not exceed 5%, so executing it every ten minutes is feasible — this frequency also ensures that Jellyfin scrapes newly downloaded anime promptly.
-
Compared to Jellyfin’s scheduled tasks, scanning all media libraries every hour would clearly impose a heavier CPU load.