The swiss army knife of lossless video/audio editing
fix youtube import last segment #2552
Mikael Finstad2511040f847b
diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsxindex 650bae60..24f769ed 100644--- a/src/renderer/src/App.tsx+++ b/src/renderer/src/App.tsx@@ -2245,7 +2245,7 @@ function App() {if (!checkFileOpened()) return;await withErrorHandling(async () => {- const edl = await askForEdlImport({ type, fps: detectedFps });+ const edl = await askForEdlImport({ type, fps: detectedFps, fileDuration });if (edl.length > 0) loadCutSegments({ segments: edl, append: true, clampDuration: fileDuration });}, i18n.t('Failed to import project file'));}, [checkFileOpened, detectedFps, fileDuration, loadCutSegments, withErrorHandling]);diff --git a/src/renderer/src/dialogs/index.tsx b/src/renderer/src/dialogs/index.tsxindex 1c39ed09..52537d2d 100644--- a/src/renderer/src/dialogs/index.tsx+++ b/src/renderer/src/dialogs/index.tsx@@ -28,7 +28,7 @@ export const showOpenDialog = async ({dialog.showOpenDialog({ ...props, title, ...(filters != null ? { filters } : {}) }));-export async function askForYouTubeInput() {+export async function askForYouTubeInput({ fileDuration }: { fileDuration?: number | undefined }) {const example = i18n.t('YouTube video description\n00:00 Intro\n00:01 Chapter 2\n00:00:02.123 Chapter 3');const { value } = await getSwal().Swal.fire({title: i18n.t('Import text chapters / YouTube'),@@ -47,7 +47,12 @@ export async function askForYouTubeInput() {if (value == null) return [];- return parseYouTube(value);+ const parsed = parseYouTube(value);++ // last segment shouldn't be a marker https://github.com/mifi/lossless-cut/discussions/2552+ return parsed.map((segment, i) => (+ i === parsed.length - 1 ? { ...segment, end: fileDuration } : segment+ ));}export async function askForInputDir(defaultPath?: string | undefined) {diff --git a/src/renderer/src/edlStore.ts b/src/renderer/src/edlStore.tsindex 66428774..7734d50e 100644--- a/src/renderer/src/edlStore.ts+++ b/src/renderer/src/edlStore.ts@@ -155,8 +155,8 @@ export async function readEdlFile({ type, path, fps }: {throw new Error('Invalid EDL type');}-export async function askForEdlImport({ type, fps }: { type: EdlImportType, fps?: number | undefined }) {- if (type === 'youtube') return askForYouTubeInput();+export async function askForEdlImport({ type, fps, fileDuration }: { type: EdlImportType, fps?: number | undefined, fileDuration?: number | undefined }) {+ if (type === 'youtube') return askForYouTubeInput({ fileDuration });let filters;// eslint-disable-next-line unicorn/prefer-switch