Import public photos from samuraijkm (NSID resolve + Flickr REST), tag Photography, with admin UI re-run and CLI support.
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
/**
|
|
* Flickr photostream importer CLI.
|
|
*
|
|
* npm run import:flickr -- --user samuraijkm
|
|
* npm run import:flickr -- --user samuraijkm --publish
|
|
* npm run import:flickr -- --user samuraijkm --dry-run
|
|
*/
|
|
import "dotenv/config";
|
|
import { runFlickrImport } from "../src/services/flickr-import.js";
|
|
import { prisma } from "../src/lib/prisma.js";
|
|
|
|
function arg(name: string, fallback?: string): string | undefined {
|
|
const idx = process.argv.indexOf(`--${name}`);
|
|
if (idx >= 0 && process.argv[idx + 1]) return process.argv[idx + 1];
|
|
return fallback;
|
|
}
|
|
|
|
function hasFlag(name: string): boolean {
|
|
return process.argv.includes(`--${name}`);
|
|
}
|
|
|
|
async function main() {
|
|
const result = await runFlickrImport({
|
|
username: arg("user", "samuraijkm"),
|
|
dryRun: hasFlag("dry-run"),
|
|
publish: hasFlag("publish"),
|
|
});
|
|
console.log(
|
|
`Summary: found=${result.found} imported=${result.imported} skipped=${result.skipped} errors=${result.errors}`
|
|
);
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
})
|
|
.finally(() => prisma.$disconnect());
|