Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
b983da8
refactor: use ask
DTrombett Apr 12, 2025
64d7fcb
feat: implement video overlay
DTrombett Apr 12, 2025
c483b43
fix: support smaller res
DTrombett Apr 12, 2025
4c065cf
fix: better handle max bitrate
DTrombett Apr 12, 2025
2e331fc
feat: add image resolution
DTrombett Apr 12, 2025
4b4359f
fix: change default resolution
DTrombett Apr 13, 2025
f5d1e63
refactor: reorder options
DTrombett Apr 13, 2025
4351c62
fix: correct replies regex
DTrombett Apr 13, 2025
d470a58
fix: account for missing duration
DTrombett Apr 13, 2025
6695271
refactor: ask before
DTrombett Apr 14, 2025
45ba771
feat: change format based on bitrate
DTrombett Apr 14, 2025
c7abf04
refactor: remove threads
DTrombett Apr 14, 2025
1ae991b
feat: add preset choice
DTrombett Apr 14, 2025
f591286
feat: add more ffmpeg options
DTrombett Apr 14, 2025
8452998
Merge branch 'main' into feat/tweetVideo
DTrombett Apr 14, 2025
be4eea9
feat: add -g option
DTrombett Apr 14, 2025
a4dad42
Merge branch 'feat/tweetVideo' of https://github.com/DTrombett/useful…
DTrombett Apr 14, 2025
7d78515
feat: add original preset
DTrombett Apr 16, 2025
74726bf
refactor: start working on tests
DTrombett Apr 17, 2025
03e05eb
feat: inspect rawvideo instead
DTrombett Apr 17, 2025
18e431a
feat: continue working on tests
DTrombett Apr 18, 2025
975ab7d
feat: add tests
DTrombett May 16, 2025
6ab7feb
feat: remove follow button
DTrombett May 16, 2025
86581de
feat: add more tests
DTrombett May 17, 2025
0ed91eb
feat: add shared browser
DTrombett May 19, 2025
883d9e0
ci: add playwright and ffmpeg
DTrombett May 19, 2025
0d03095
fix: use latest release
DTrombett May 19, 2025
4ea3f41
feat: add artifacts
DTrombett May 19, 2025
38835d6
ci: resolve failed screenshot path
DTrombett May 19, 2025
e33c677
ci: actually upload failed files
DTrombett May 19, 2025
441cffa
ci: try with another directory
DTrombett May 19, 2025
7c24af9
ci: idk try this
DTrombett May 21, 2025
d929669
ci: i'm completely lost
DTrombett May 21, 2025
e1e67b1
fix: ts error
DTrombett May 21, 2025
67682ff
ci: try with cwd
DTrombett May 21, 2025
1c4ca83
fix: use correct rootDirectory
DTrombett May 21, 2025
ffa857a
ci: remove @actions/artifact
DTrombett May 21, 2025
65c6069
ci: run on failure
DTrombett May 21, 2025
65f1d5c
ci: try on windows
DTrombett May 22, 2025
3cd1d0b
ci: run on all systems
DTrombett May 22, 2025
a19e21e
ci: change ffmpeg provider
DTrombett May 22, 2025
ae75ef9
ci: fix artifact name
DTrombett May 22, 2025
3fdfa85
test: update macos screenshots
DTrombett May 22, 2025
ce37133
test: check if it actually fails
DTrombett May 22, 2025
4e459dd
ci: let's go! add back correct one
DTrombett May 22, 2025
e09a878
feat: adapt stockHeatmap too
DTrombett May 23, 2025
689d66a
test: mark flaky test as todo
DTrombett May 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@ name: Run tests
on: [push]
jobs:
Test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: AnimMouse/setup-ffmpeg@v1
- uses: actions/setup-node@v4
with:
node-version: "22.x"
cache: "npm"
- run: npm ci
- run: npx playwright install --with-deps
- run: npm test
- uses: actions/upload-artifact@v4
if: failure()
with:
name: "Failed tests (${{ matrix.os }})"
path: test/tmp/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.vscode/
dist/
node_modules/
test/tmp
47 changes: 31 additions & 16 deletions package-lock.json

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

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@
"url": "https://github.com/DTrombett/useful-scripts/issues"
},
"dependencies": {
"playwright": "^1.51.1",
"undici": "^7.8.0"
"playwright": "^1.52.0",
"undici": "^7.9.0"
},
"devDependencies": {
"@tsconfig/node22": "^22.0.1",
"@tsconfig/recommended": "^1.0.8",
"@tsconfig/strictest": "^2.0.5",
"@types/node": "^22.14.1"
"@types/node": "^22.15.19",
"typescript": "^5.8.3"
},
"repository": {
"type": "git",
"url": "git+https://github.com/DTrombett/useful-scripts.git"
},
"scripts": {
"start": "node --experimental-strip-types --experimental-transform-types .",
"test": "tsc"
"start": "node --experimental-transform-types .",
"test": "tsc && node --test --experimental-transform-types --experimental-test-module-mocks"
}
}
45 changes: 45 additions & 0 deletions src/hashMedia.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { spawn } from "child_process";
import { createHash } from "crypto";
import { ok } from "node:assert/strict";
import { stdout } from "node:process";
import { pipeline } from "stream/promises";
import { ask } from "./utils/options.ts";

const hashMedia = async ({
input,
algorithm,
encoding,
silent,
}: Partial<{
input: string;
algorithm: string;
encoding: BufferEncoding;
silent: boolean;
}> = {}) => {
input ??= await ask("Input file: ", { silent });
ok(input, "Input file is required");
algorithm ??= await ask("Hash algorithm (sha512): ", {
silent,
default: "sha512",
});
const args: string[] = ["-v", "error", "-i", input, "-f", "rawvideo", "-"];
if (!silent) args.push("-stats");
const hash = await pipeline(
spawn("ffmpeg", args, { stdio: ["ignore", "pipe", "inherit"] }).stdout,
createHash(algorithm),
async (hash: AsyncIterable<Buffer, Buffer>) =>
(
await hash[Symbol.asyncIterator]().next()
).value,
{ signal: AbortSignal.timeout(10_000) }
);
encoding ??= (await ask("Hash encoding (base64url): ", {
silent,
default: "base64url",
})) as BufferEncoding;
const result = hash.toString(encoding);
if (!silent) stdout.write(`${result}\n`);
return result;
};

export default hashMedia;
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { mkdir } from "node:fs/promises";
import { argv, stdin, stdout } from "node:process";
import { argv, exit, stdin, stdout } from "node:process";
import { emitKeypressEvents } from "node:readline";

const file = argv[2];

stdin.setDefaultEncoding("utf-8");
mkdir(".cache", { recursive: true }).catch(() => {});
process.argv.splice(0, 3);
stdin.setRawMode(true);
emitKeypressEvents(stdin);
stdin.on("keypress", (_, key: { name?: string; ctrl?: boolean }) => {
if (key.ctrl && key.name === "c") {
stdout.write("\x1b[?25h");
process.exit(0);
exit(0);
}
});
import(`./${file?.endsWith(".ts") ? file.slice(0, -3) : file}.ts`);
const { default: fn } = await import(`./${file?.replace(/\.ts$/, "")}.ts`);
await fn();
stdin.unref();
3 changes: 1 addition & 2 deletions src/mergeImages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { homedir } from "node:os";
import { join, parse, type ParsedPath } from "node:path";
import { exit, stderr, stdout } from "node:process";
import { promisify } from "node:util";
import { ask } from "./utils/ask.ts";
import { getUserChoice } from "./utils/getUserChoice.ts";
import { ask, getUserChoice } from "./utils/options.ts";

// Initialize the readline interface
const images: ({ width: number; height: number; path: string } & ParsedPath)[] =
Expand Down
Loading