1
0
Fork 0

download bsky support

This commit is contained in:
lightling 2025-01-21 20:30:04 -05:00
parent a0f7e16fc3
commit 394370fb55
2 changed files with 38 additions and 10 deletions

View file

@ -1,6 +1,6 @@
import { readFile, writeFile } from 'fs/promises'; import { readFile, writeFile } from 'fs/promises';
import { getArg } from './lib/args.js'; import { getArg, validateSiteArg, SITES } from './lib/args.js';
import { getMany } from './lib/dl.js'; import { getMany } from './lib/dl.js';
import { error, log } from './lib/log.js'; import { error, log } from './lib/log.js';
import { createDb, userSchema } from './lib/schema.js'; import { createDb, userSchema } from './lib/schema.js';
@ -19,9 +19,10 @@ const ctx = 'downloadDb.js';
*/ */
const downloadDb = async () => { const downloadDb = async () => {
log(ctx, 'Grabbing db'); log(ctx, 'Grabbing db');
let directory = '', threadMax = 1, db, usersPerBatch, waitTime; let directory = '', threadMax = 1, db, usersPerBatch, waitTime, site;
try { try {
directory = getArg('path'); directory = getArg('path');
site = validateSiteArg(getArg('site'));
} catch (err) { } catch (err) {
error(ctx, err); error(ctx, err);
return; return;
@ -77,7 +78,13 @@ const downloadDb = async () => {
const errorReadout = []; const errorReadout = [];
const executeDl = async (arr) => { const executeDl = async (arr) => {
log(ctx, `Downloading media using /<user>/media for ${arr.length} users`); log(ctx, `Downloading media using /<user>/media for ${arr.length} users`);
await getMany(arr, threadMax, directory, 'media'); await getMany({
userDb: arr,
threadMax,
directory,
mode: 'media',
site,
});
arr.forEach(entry => { arr.forEach(entry => {
entry.logs.forEach(log => { entry.logs.forEach(log => {
@ -93,8 +100,16 @@ const downloadDb = async () => {
}); });
}); });
log(ctx, 'Downloading media using /search'); if (site === SITES.TWITTER) {
await getMany(arr, threadMax, directory, 'search'); log(ctx, 'Downloading media using /search');
await getMany({
userDb: arr,
threadMax,
directory,
mode: 'search',
site,
});
}
} }
if (!!usersPerBatch) { if (!!usersPerBatch) {

View file

@ -1,6 +1,6 @@
import { readFile, writeFile } from 'fs/promises'; import { readFile, writeFile } from 'fs/promises';
import { getArg } from './lib/args.js'; import { getArg, validateSiteArg, SITES } from './lib/args.js';
import { getMany } from './lib/dl.js'; import { getMany } from './lib/dl.js';
import { error, log } from './lib/log.js'; import { error, log } from './lib/log.js';
import { createDb, userSchema } from './lib/schema.js'; import { createDb, userSchema } from './lib/schema.js';
@ -15,10 +15,11 @@ const ctx = 'downloadUser.js';
*/ */
const downloadUsers = async () => { const downloadUsers = async () => {
log(ctx, 'Grabbing db'); log(ctx, 'Grabbing db');
let directory, threadMax = 1, users, db; let directory, threadMax = 1, users, db, site;
try { try {
directory = getArg('path'); directory = getArg('path');
users = getArg('users').split(','); users = getArg('users').split(',');
site = validateSiteArg(getArg('site'));
} catch (err) { } catch (err) {
error(ctx, err); error(ctx, err);
return; return;
@ -59,10 +60,22 @@ const downloadUsers = async () => {
})); }));
log(ctx, `Downloading media using /<user>/media for ${processes.length} users`); log(ctx, `Downloading media using /<user>/media for ${processes.length} users`);
await getMany(processes, threadMax, directory, 'media'); await getMany({
userDb: processes,
threadMax,
directory,
mode: 'media',
});
log(ctx, 'Downloading media using /search'); if (site === SITES.TWITTER) {
await getMany(processes, threadMax, directory, 'search'); log(ctx, 'Downloading media using /search');
await getMany({
userDb: processes,
threadMax,
directory,
mode: 'search',
});
}
processes.forEach(entry => { processes.forEach(entry => {
entry.logs.forEach(log => { entry.logs.forEach(log => {