cochize1 55 Posted 1 hour ago Posted 1 hour ago To chip in: with some help from AI, I'm testing a script that automates this, as @Lukesuggested above (fetching the Upcoming API URL on a schedule). It runs every hour from Synology Task Scheduler. So far it works well, and the Upcoming tab loads quickly in my two TV libraries (TV Shows, about 740 series, and Cartoons). Setup: Emby 4.10.0.40 in Docker on Synology. Both libraries have TheTVDB and TheMovieDb enabled for Series, Season and Episode. Log from last night and this morning: 2026-09-22 05:00:10 TVShows http=200 took=6s 2026-09-22 06:00:09 TVShows http=200 took=7s 2026-09-22 07:00:06 TVShows http=200 took=5s 2026-09-22 08:00:07 TVShows http=200 took=6s 2026-09-22 09:04:13 TVShows http=200 took=252s 2026-09-22 10:00:40 TVShows http=200 took=39s 2026-09-22 11:01:29 TVShows http=200 took=88s 2026-09-22 11:01:59 Cartoons http=200 took=30s 2026-09-22 11:10:02 TVShows http=200 took=5s The slow runs were all TheTVDB episode-list requests (/v4/series/{id}/episodes/official plus /eng), about 870 fetched from the network and 630 served from cache. Most of the cached responses had been fetched the previous evening between about 20:20 and 22:20, and they seem to have expired roughly 12 hours later, in the same order. The fast hourly runs in between didn't seem to renew them, since they were pure cache hits. My questions: How long are provider responses (TheTVDB/TMDB) kept in the HTTP cache before they're refetched, and does a cache hit extend that? Is there a setting for that lifetime, or a way to refresh the whole Upcoming data at a chosen time (for example at night), so the refetch wave doesn't hit users during the day? Which provider does Upcoming use when both are enabled? My TV Shows library lists TheMovieDb first, but all the lookups went to TheTVDB. A built-in scheduled task for this would make the script unnecessary. Many people in this thread seem to have asked for one. Here is the script (it needs jq, which DSM includes and you need to replace LIBRARIES, USERNAME, the port, DIR and api file with your own data): Here is the script: #!/bin/bash # Requests Emby's Upcoming list for each library in LIBRARIES (the same query the # web client sends) and logs how long it took. Run from Synology Task Scheduler as root. # Fast times = Emby answered from its cached provider data; slow times = it had to # fetch episode lists from TheTVDB/TMDB again because the cached data had expired. DIR="/path/to/script" LOG="$DIR/emby-upcoming.log" EMBY="http://127.0.0.1:8096/emby" # library id = the parentId in the library's web URL; name is only for the log LIBRARIES="15884189:TVShows 748:Cartoons" USERNAME=username # api key string stored in the same directory as script in file named .emby-api-key KEY=$(cat "$DIR/.emby-api-key" 2>/dev/null) [ -n "$KEY" ] || { echo "$(date '+%F %T') no api key" >> "$LOG"; exit 0; } U=$(curl -s --max-time 10 -H "X-Emby-Token: $KEY" "$EMBY/Users" | jq -r --arg n "$USERNAME" '.[] | select(.Name == $n) | .Id') [ -n "$U" ] || { echo "$(date '+%F %T') user lookup failed" >> "$LOG"; exit 0; } for lib in $LIBRARIES; do id=${lib%%:*}; name=${lib#*:} start=$(date +%s) code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 600 -H "X-Emby-Token: $KEY" \ "$EMBY/Shows/Upcoming?Limit=100&UserId=$U&ImageTypeLimit=1&EnableImageTypes=Primary,Backdrop,Thumb&EnableTotalRecordCount=false&parentId=$id&Fields=Overview") echo "$(date '+%F %T') $name http=$code took=$(( $(date +%s) - start ))s" >> "$LOG" done # keep the last 7 days (at most 1400 lines) tail -n 1400 "$LOG" > "$LOG.tmp" && mv "$LOG.tmp" "$LOG" exit 0
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now