From 96340164cb3ea6070773602727b307c45eb03397 Mon Sep 17 00:00:00 2001 From: philmcmahon Date: Mon, 6 Jan 2025 15:41:22 +0000 Subject: [PATCH] Use media-download directory everywhere in media-download service --- packages/media-download/src/index.ts | 4 ++-- packages/media-download/src/yt-dlp.ts | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/media-download/src/index.ts b/packages/media-download/src/index.ts index db3fc5e4..0e103024 100644 --- a/packages/media-download/src/index.ts +++ b/packages/media-download/src/index.ts @@ -19,7 +19,7 @@ import { MediaDownloadJob, } from '@guardian/transcription-service-common'; -const DOWNLOAD_DIRECTORY = '/media-download'; +export const MEDIA_DOWNLOAD_WORKING_DIRECTORY = '/media-download'; const uploadToS3 = async ( s3Client: S3Client, @@ -143,7 +143,7 @@ const main = async () => { const metadata = await downloadMedia( job.url, - DOWNLOAD_DIRECTORY, + MEDIA_DOWNLOAD_WORKING_DIRECTORY, job.id, proxyUrl, ); diff --git a/packages/media-download/src/yt-dlp.ts b/packages/media-download/src/yt-dlp.ts index dc1455c6..e7486c12 100644 --- a/packages/media-download/src/yt-dlp.ts +++ b/packages/media-download/src/yt-dlp.ts @@ -1,6 +1,7 @@ import fs from 'node:fs'; import { runSpawnCommand } from '@guardian/transcription-service-backend-common/src/process'; import { logger } from '@guardian/transcription-service-backend-common'; +import { MEDIA_DOWNLOAD_WORKING_DIRECTORY } from './index'; export type MediaMetadata = { title: string; @@ -26,7 +27,11 @@ export const startProxyTunnel = async ( port: number, ): Promise => { try { - fs.writeFileSync('/tmp/media_download', key + '\n', { mode: 0o600 }); + fs.writeFileSync( + `${MEDIA_DOWNLOAD_WORKING_DIRECTORY}/media_download`, + key + '\n', + { mode: 0o600 }, + ); const result = await runSpawnCommand( 'startProxyTunnel', 'ssh', @@ -42,7 +47,7 @@ export const startProxyTunnel = async ( '-N', '-f', '-i', - '/tmp/media_download', + `${MEDIA_DOWNLOAD_WORKING_DIRECTORY}/media_download`, `media_download@${ip}`, ], true,