-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add media download service (part 1) #104
Merged
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
34117b9
Introduce media download service (and associated types) - which fetch…
philmcmahon a524c85
Add new sqs queue for media download service
philmcmahon 53c0794
Add media download api endpoint
philmcmahon c20592b
Simplify transcript sqs logic for translations
philmcmahon 1331600
After uploading the file to s3, send an SQS message requesting a tran…
philmcmahon c663acf
media-download not media-downloader
philmcmahon 99fc2db
Use a separate dead letter queue for the media download queue
philmcmahon 3d39603
Remove phantomjs/ffmpeg dependencies
philmcmahon 1a8ecf4
Log an error when failing to send sqs message.
philmcmahon 322acaf
Use runSpawnCommand rather than zx for media download service
philmcmahon 86ac652
Bump gu cdk and aws cdk versions
philmcmahon ecff3ce
Only hide stdout sometimes
philmcmahon a7f1e8e
Update package-lock
philmcmahon cc1248d
Explicitly depend on @guardian/eslint-config
philmcmahon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { spawn } from 'child_process'; | ||
import { logger } from './logging'; | ||
export interface ProcessResult { | ||
code?: number; | ||
stdout: string; | ||
stderr: string; | ||
} | ||
|
||
export const runSpawnCommand = ( | ||
processName: string, | ||
cmd: string, | ||
args: ReadonlyArray<string>, | ||
): Promise<ProcessResult> => { | ||
return new Promise((resolve, reject) => { | ||
const cp = spawn(cmd, args); | ||
const stdout: string[] = []; | ||
const stderr: string[] = []; | ||
cp.stdout.on('data', (data) => { | ||
stdout.push(data.toString()); | ||
}); | ||
|
||
cp.stderr.on('data', (data) => { | ||
stderr.push(data.toString()); | ||
}); | ||
|
||
cp.on('error', (e) => { | ||
stderr.push(e.toString()); | ||
}); | ||
|
||
cp.on('close', (code) => { | ||
const result = { | ||
stdout: stdout.join(''), | ||
stderr: stderr.join(''), | ||
code: code || undefined, | ||
}; | ||
logger.info('Ignoring stdout to avoid logging sensitive data'); | ||
logger.info(`process ${processName} stderr: ${result.stderr}`); | ||
if (code === 0) { | ||
resolve(result); | ||
} else { | ||
logger.error( | ||
`process ${processName} failed with code ${result.code} due to: ${result.stderr}`, | ||
); | ||
reject(result); | ||
} | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it important not to log stdout when running yt-dlp?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I've updated this ecff3ce