Fix video asset processing detection
All checks were successful
Validate / Hassfest (push) Successful in 3s
All checks were successful
Validate / Hassfest (push) Successful in 3s
- Use thumbhash for all assets instead of encodedVideoPath for videos (encodedVideoPath is not exposed in Immich API response) - Add isTrashed check to exclude trashed assets from events - Simplify processing status logic for both photos and videos Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -190,43 +190,33 @@ class AssetInfo:
|
|||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _check_processing_status(data: dict[str, Any], asset_type: str) -> bool:
|
def _check_processing_status(data: dict[str, Any], _asset_type: str) -> bool:
|
||||||
"""Check if asset has been fully processed by Immich.
|
"""Check if asset has been fully processed by Immich.
|
||||||
|
|
||||||
For photos: Check if thumbnails/previews have been generated
|
For all assets: Check if thumbnails have been generated (thumbhash exists).
|
||||||
For videos: Check if video transcoding is complete
|
Immich generates thumbnails for both photos and videos regardless of
|
||||||
|
whether video transcoding is needed.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
data: Asset data from API response
|
data: Asset data from API response
|
||||||
asset_type: Asset type (IMAGE or VIDEO)
|
_asset_type: Asset type (IMAGE or VIDEO) - unused but kept for API stability
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
True if asset is fully processed, False otherwise
|
True if asset is fully processed and not trashed/offline, False otherwise
|
||||||
"""
|
"""
|
||||||
if asset_type == ASSET_TYPE_VIDEO:
|
# Exclude offline assets
|
||||||
# For videos, check if transcoding is complete
|
if data.get("isOffline", False):
|
||||||
# Video is processed if it has an encoded video path or if isOffline is False
|
return False
|
||||||
is_offline = data.get("isOffline", False)
|
|
||||||
if is_offline:
|
|
||||||
return False
|
|
||||||
|
|
||||||
# Check if video has been transcoded (has encoded video path)
|
# Exclude trashed assets
|
||||||
# Immich uses "encodedVideoPath" or similar field when transcoding is done
|
if data.get("isTrashed", False):
|
||||||
has_encoded_video = bool(data.get("encodedVideoPath"))
|
return False
|
||||||
return has_encoded_video
|
|
||||||
|
|
||||||
else: # ASSET_TYPE_IMAGE
|
# Check if thumbnails have been generated
|
||||||
# For photos, check if thumbnails have been generated
|
# This works for both photos and videos - Immich always generates thumbnails
|
||||||
# Photos are processed if they have thumbnail/preview paths
|
# Note: The API doesn't expose video transcoding status (encodedVideoPath),
|
||||||
is_offline = data.get("isOffline", False)
|
# but thumbhash is sufficient since Immich generates thumbnails for all assets
|
||||||
if is_offline:
|
return bool(data.get("thumbhash"))
|
||||||
return False
|
|
||||||
|
|
||||||
# Check if thumbnails exist
|
|
||||||
has_thumbhash = bool(data.get("thumbhash"))
|
|
||||||
has_thumbnail = has_thumbhash # If thumbhash exists, thumbnails should exist
|
|
||||||
|
|
||||||
return has_thumbnail
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
Reference in New Issue
Block a user