Fix Emby HTTP 500 on PlayedItems — convert DatePlayed to yyyyMMddHHmmss

Emby's API spec requires DatePlayed as yyyyMMddHHmmss; sending ISO 8601 caused 500 on every mark-played call.
This commit is contained in:
Gmer4Lfe
2026-06-11 19:22:51 -04:00
parent ca0d17ec2a
commit 129e8ae14a
+5 -10
View File
@@ -450,7 +450,7 @@ for lname in "${!USER_MAP[@]}"; do
if [[ -n "$_search_field" ]]; then if [[ -n "$_search_field" ]]; then
_iid=$(_api_get "${SRV_URL[$_si]}" "${SRV_KEY[$_si]}" \ _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) | jq -r '.Items[0].Id // empty' 2>/dev/null)
fi fi
[[ -z "$_iid" ]] && log " SKIP $_pkey${SRV_NAME[$_si]} item not found on server" && continue [[ -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 # Mark as played with date
_date_param="" _date_param=""
if [[ "$_auth_lplayed" != "null" && -n "$_auth_lplayed" ]]; then if [[ "$_auth_lplayed" != "null" && -n "$_auth_lplayed" ]]; then
# Emby's PlayedItems endpoint rejects 7-digit fractional seconds (.0000000) # PlayedItems expects DatePlayed in yyyyMMddHHmmss (no separators, no timezone)
# with HTTP 500; strip to whole seconds before encoding _lp="${_auth_lplayed%.*}"
if [[ "$_auth_lplayed" == *.* ]]; then _lp="${_lp%Z}"
_lp="${_auth_lplayed%.*}" _date_param="?DatePlayed=${_lp//[-T:]/}"
[[ "$_auth_lplayed" == *Z ]] && _lp+="Z"
else
_lp="$_auth_lplayed"
fi
_date_param="?DatePlayed=${_lp//[: ]/%3A}"
fi fi
_http=$(_api_post "${SRV_URL[$_si]}" "${SRV_KEY[$_si]}" \ _http=$(_api_post "${SRV_URL[$_si]}" "${SRV_KEY[$_si]}" \
"Users/${_uid}/PlayedItems/${_iid}${_date_param}") "Users/${_uid}/PlayedItems/${_iid}${_date_param}")