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
|
||||
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.
|
||||
|
||||
For photos: Check if thumbnails/previews have been generated
|
||||
For videos: Check if video transcoding is complete
|
||||
For all assets: Check if thumbnails have been generated (thumbhash exists).
|
||||
Immich generates thumbnails for both photos and videos regardless of
|
||||
whether video transcoding is needed.
|
||||
|
||||
Args:
|
||||
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:
|
||||
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:
|
||||
# For videos, check if transcoding is complete
|
||||
# Video is processed if it has an encoded video path or if isOffline is False
|
||||
is_offline = data.get("isOffline", False)
|
||||
if is_offline:
|
||||
return False
|
||||
# Exclude offline assets
|
||||
if data.get("isOffline", False):
|
||||
return False
|
||||
|
||||
# Check if video has been transcoded (has encoded video path)
|
||||
# Immich uses "encodedVideoPath" or similar field when transcoding is done
|
||||
has_encoded_video = bool(data.get("encodedVideoPath"))
|
||||
return has_encoded_video
|
||||
# Exclude trashed assets
|
||||
if data.get("isTrashed", False):
|
||||
return False
|
||||
|
||||
else: # ASSET_TYPE_IMAGE
|
||||
# For photos, check if thumbnails have been generated
|
||||
# Photos are processed if they have thumbnail/preview paths
|
||||
is_offline = data.get("isOffline", False)
|
||||
if is_offline:
|
||||
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
|
||||
# Check if thumbnails have been generated
|
||||
# This works for both photos and videos - Immich always generates thumbnails
|
||||
# Note: The API doesn't expose video transcoding status (encodedVideoPath),
|
||||
# but thumbhash is sufficient since Immich generates thumbnails for all assets
|
||||
return bool(data.get("thumbhash"))
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
Reference in New Issue
Block a user