From 129e8ae14a04e44faecd1a3841e5c45555fae1f3 Mon Sep 17 00:00:00 2001 From: Gmer4Lfe Date: Thu, 11 Jun 2026 19:22:51 -0400 Subject: [PATCH] =?UTF-8?q?Fix=20Emby=20HTTP=20500=20on=20PlayedItems=20?= =?UTF-8?q?=E2=80=94=20convert=20DatePlayed=20to=20yyyyMMddHHmmss?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Emby's API spec requires DatePlayed as yyyyMMddHHmmss; sending ISO 8601 caused 500 on every mark-played call. --- Media/play_state_sync.sh | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Media/play_state_sync.sh b/Media/play_state_sync.sh index 158d0d6..d8e2b58 100755 --- a/Media/play_state_sync.sh +++ b/Media/play_state_sync.sh @@ -450,7 +450,7 @@ for lname in "${!USER_MAP[@]}"; do if [[ -n "$_search_field" ]]; then _iid=$(_api_get "${SRV_URL[$_si]}" "${SRV_KEY[$_si]}" \ - "Items?AnyProviderIdEquals=${_search_field}&Recursive=true&Fields=ProviderIds&Limit=1" 2>/dev/null \ + "Items?AnyProviderIdEquals=${_search_field}&Recursive=true&Fields=ProviderIds&ExcludeLocationTypes=Virtual&Limit=1" 2>/dev/null \ | jq -r '.Items[0].Id // empty' 2>/dev/null) fi [[ -z "$_iid" ]] && log " SKIP $_pkey → ${SRV_NAME[$_si]} item not found on server" && continue @@ -469,15 +469,10 @@ for lname in "${!USER_MAP[@]}"; do # Mark as played with date _date_param="" if [[ "$_auth_lplayed" != "null" && -n "$_auth_lplayed" ]]; then - # Emby's PlayedItems endpoint rejects 7-digit fractional seconds (.0000000) - # with HTTP 500; strip to whole seconds before encoding - if [[ "$_auth_lplayed" == *.* ]]; then - _lp="${_auth_lplayed%.*}" - [[ "$_auth_lplayed" == *Z ]] && _lp+="Z" - else - _lp="$_auth_lplayed" - fi - _date_param="?DatePlayed=${_lp//[: ]/%3A}" + # PlayedItems expects DatePlayed in yyyyMMddHHmmss (no separators, no timezone) + _lp="${_auth_lplayed%.*}" + _lp="${_lp%Z}" + _date_param="?DatePlayed=${_lp//[-T:]/}" fi _http=$(_api_post "${SRV_URL[$_si]}" "${SRV_KEY[$_si]}" \ "Users/${_uid}/PlayedItems/${_iid}${_date_param}")