move video file extension to along with the livePhoto util
This commit is contained in:
parent
e2676fd76f
commit
3e0b5f5863
|
@ -16,31 +16,3 @@ export enum FILE_TYPE {
|
|||
LIVE_PHOTO,
|
||||
OTHERS,
|
||||
}
|
||||
|
||||
export const IMAGE_EXTENSIONS = [
|
||||
'heic',
|
||||
'heif',
|
||||
'jpeg',
|
||||
'jpg',
|
||||
'png',
|
||||
'gif',
|
||||
'bmp',
|
||||
'tiff',
|
||||
'webp',
|
||||
];
|
||||
|
||||
export const VIDEO_EXTENSIONS = [
|
||||
'mov',
|
||||
'mp4',
|
||||
'm4v',
|
||||
'avi',
|
||||
'wmv',
|
||||
'flv',
|
||||
'mkv',
|
||||
'webm',
|
||||
'3gp',
|
||||
'3g2',
|
||||
'avi',
|
||||
'ogv',
|
||||
'mpg',
|
||||
];
|
||||
|
|
|
@ -10,11 +10,8 @@ import {
|
|||
ParsedMetadataJSONMap,
|
||||
} from 'types/upload';
|
||||
import { CustomError } from 'utils/error';
|
||||
import {
|
||||
getFileTypeFromExtension,
|
||||
isImageOrVideo,
|
||||
splitFilenameAndExtension,
|
||||
} from 'utils/file';
|
||||
import { getFileTypeFromExtensionForLivePhotoClustering } from 'utils/file/livePhoto';
|
||||
import { splitFilenameAndExtension, isImageOrVideo } from 'utils/file';
|
||||
import { logError } from 'utils/sentry';
|
||||
import { getUint8ArrayView } from '../readerService';
|
||||
import { extractFileMetadata } from './fileService';
|
||||
|
@ -137,12 +134,14 @@ export async function clusterLivePhotoFiles(mediaFiles: FileWithCollection[]) {
|
|||
}
|
||||
const firstMediaFile = mediaFiles[index];
|
||||
const secondMediaFile = mediaFiles[index + 1];
|
||||
const firstFileType = getFileTypeFromExtension(
|
||||
firstMediaFile.file.name
|
||||
);
|
||||
const secondFileType = getFileTypeFromExtension(
|
||||
secondMediaFile.file.name
|
||||
);
|
||||
const firstFileType =
|
||||
getFileTypeFromExtensionForLivePhotoClustering(
|
||||
firstMediaFile.file.name
|
||||
);
|
||||
const secondFileType =
|
||||
getFileTypeFromExtensionForLivePhotoClustering(
|
||||
secondMediaFile.file.name
|
||||
);
|
||||
const firstFileIdentifier: LivePhotoIdentifier = {
|
||||
collectionID: firstMediaFile.collectionID,
|
||||
fileType: firstFileType,
|
||||
|
|
|
@ -19,8 +19,6 @@ import {
|
|||
TYPE_HEIC,
|
||||
TYPE_HEIF,
|
||||
FILE_TYPE,
|
||||
IMAGE_EXTENSIONS,
|
||||
VIDEO_EXTENSIONS,
|
||||
} from 'constants/file';
|
||||
import PublicCollectionDownloadManager from 'services/publicCollectionDownloadManager';
|
||||
import heicConversionService from 'services/heicConversionService';
|
||||
|
@ -273,15 +271,6 @@ export function getFileExtension(filename: string) {
|
|||
return splitFilenameAndExtension(filename)[1]?.toLocaleLowerCase();
|
||||
}
|
||||
|
||||
export function getFileTypeFromExtension(filename: string) {
|
||||
const extension = getFileExtension(filename);
|
||||
if (IMAGE_EXTENSIONS.includes(extension)) {
|
||||
return FILE_TYPE.IMAGE;
|
||||
} else if (VIDEO_EXTENSIONS.includes(extension)) {
|
||||
return FILE_TYPE.VIDEO;
|
||||
}
|
||||
}
|
||||
|
||||
export function generateStreamFromArrayBuffer(data: Uint8Array) {
|
||||
return new ReadableStream({
|
||||
async start(controller: ReadableStreamDefaultController) {
|
||||
|
|
41
src/utils/file/livePhoto.ts
Normal file
41
src/utils/file/livePhoto.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { FILE_TYPE } from 'constants/file';
|
||||
import { getFileExtension } from 'utils/file';
|
||||
|
||||
const IMAGE_EXTENSIONS = [
|
||||
'heic',
|
||||
'heif',
|
||||
'jpeg',
|
||||
'jpg',
|
||||
'png',
|
||||
'gif',
|
||||
'bmp',
|
||||
'tiff',
|
||||
'webp',
|
||||
];
|
||||
|
||||
const VIDEO_EXTENSIONS = [
|
||||
'mov',
|
||||
'mp4',
|
||||
'm4v',
|
||||
'avi',
|
||||
'wmv',
|
||||
'flv',
|
||||
'mkv',
|
||||
'webm',
|
||||
'3gp',
|
||||
'3g2',
|
||||
'avi',
|
||||
'ogv',
|
||||
'mpg',
|
||||
];
|
||||
|
||||
export function getFileTypeFromExtensionForLivePhotoClustering(
|
||||
filename: string
|
||||
) {
|
||||
const extension = getFileExtension(filename);
|
||||
if (IMAGE_EXTENSIONS.includes(extension)) {
|
||||
return FILE_TYPE.IMAGE;
|
||||
} else if (VIDEO_EXTENSIONS.includes(extension)) {
|
||||
return FILE_TYPE.VIDEO;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue