Skip to content

Commit

Permalink
Merge pull request #276 from vitalygashkov/next
Browse files Browse the repository at this point in the history
Switched from `curl` to `molnia` for shaka-packager download, fixed MPD decryption with given keys
  • Loading branch information
vitalygashkov authored Dec 12, 2024
2 parents 3563a8c + 05e1398 commit 9a8aa88
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 22 deletions.
2 changes: 1 addition & 1 deletion apps/cli
Submodule cli updated from ce8929 to b34b02
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 10 additions & 20 deletions packages/core/lib/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ChildProcessWithoutNullStreams, spawn } from 'node:child_process';
import { chmodSync } from 'node:fs';
import { delimiter } from 'node:path';
import { stat } from 'node:fs/promises';
import { download } from 'molnia';
import { logger } from './log';
import { fs } from './fs';
import { getSettings } from './settings';
Expand Down Expand Up @@ -93,25 +94,6 @@ const getGitHubAssetUrl = ({ repo, version, asset }: GitHubUrlOptions) => {
return `https://github.com/${repo}/releases/download/${version}/${asset}`;
};

export const download = async (url: string, outputPath: string) => {
// Curl args:
const args = [
'-L', // follow redirects
'-f', // fail if the request fails
// output destination:
'-o',
outputPath,
'--show-error', // show errors
'--silent', // but no progress bar
url,
];
// Now fetch the binary and fail the script if that fails:
logger.debug(`Downloading ${url} to ${outputPath}`);
const process = spawn('curl', args, { stdio: 'inherit' });
const code = await new Promise<number | null>((resolve) => process.on('exit', resolve));
if (code != 0) throw new Error('Download of ' + url + ' failed: ' + code);
};

interface DownloadBinaryOptions extends Omit<GitHubUrlOptions, 'asset'> {
id: string;
assets: BinaryNamesByPlatform;
Expand All @@ -136,7 +118,15 @@ export const fetchGitHubAsset = async ({ id, assets, repo, version }: DownloadBi
const output = fs.join(getSettings().binariesDir, name);
downloads.state.set(id, 'downloading');
const url = getGitHubAssetUrl({ repo, version, asset: name });
await download(url, output);
logger.debug(`Downloading ${url} to ${output}`);
await download(url, {
output,
onError: (e) => logger.error(e.message),
onProgress: (progress) => {
logger.debug(progress.toString());
},
});
logger.debug(`Downloaded: ${output}`);
chmodSync(output, 0o755);
downloads.paths.set(id, output);
downloads.state.set(id, 'finished');
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@streamyx/logger": "^0.0.2",
"dasha": "^3.1.1",
"got-scraping": "^3.2.15",
"molnia": "^0.0.15",
"undici": "^6.21.0"
},
"devDependencies": {
Expand Down

0 comments on commit 9a8aa88

Please sign in to comment.