fix(media): resolve google photos video import treating videos as images
This commit fixes a bug where videos imported from the Google Photos Picker were being downloaded as static thumbnails. Changes include: 1. Frontend (MediaManager.html): Correctly access nested 'mediaFile' properties from the Picker API response to ensure valid mimeType and filename are passed to the backend. Restored logic to force 'video/mp4' mimeType if 'mediaMetadata.video' is present. Added debug logging. 2. Backend (mediaHandlers.ts): Restored missing 'else if' block for URL handling that was causing 'No File ID' errors. Implemented logic to append '=dv' parameter for video downloads. Added safeguard to rename downloaded files to '.mp4' if the content type is video but the extension is wrong.
This commit is contained in:
@ -1173,7 +1173,23 @@
|
||||
processPhotoItems(items) {
|
||||
let done = 0;
|
||||
items.forEach(item => {
|
||||
const url = (item.mediaFile && item.mediaFile.baseUrl) ? item.mediaFile.baseUrl : item.baseUrl;
|
||||
console.log("[MediaManager] Processing Item:", JSON.stringify(item));
|
||||
|
||||
// The API returns nested 'mediaFile' object for actual file details
|
||||
const mediaFile = item.mediaFile || item;
|
||||
|
||||
const url = mediaFile.baseUrl || item.baseUrl;
|
||||
const filename = mediaFile.filename || item.filename;
|
||||
let mimeType = mediaFile.mimeType || item.mimeType;
|
||||
|
||||
console.log(`[MediaManager] Extracted: URL=${url ? 'Yes' : 'No'}, Mime=${mimeType}, Name=${filename}`);
|
||||
|
||||
// Force video mimeType if metadata indicates video (Critical for backend =dv param)
|
||||
if (item.mediaMetadata && item.mediaMetadata.video) {
|
||||
console.log("[MediaManager] Metadata indicates VIDEO. Forcing video/mp4.");
|
||||
mimeType = 'video/mp4';
|
||||
}
|
||||
|
||||
google.script.run
|
||||
.withSuccessHandler(() => {
|
||||
done++;
|
||||
@ -1183,7 +1199,7 @@
|
||||
setTimeout(() => ui.closePhotoSession(), 2000);
|
||||
}
|
||||
})
|
||||
.importFromPicker(state.sku, null, item.mimeType, item.filename, url);
|
||||
.importFromPicker(state.sku, null, mimeType, filename, url);
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user