From 394370fb55dabde01d98b2881f8a8359a86fb906 Mon Sep 17 00:00:00 2001 From: Lightling Date: Tue, 21 Jan 2025 20:30:04 -0500 Subject: [PATCH] download bsky support --- run-downloadDb.js | 25 ++++++++++++++++++++----- run-downloadUsers.js | 23 ++++++++++++++++++----- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/run-downloadDb.js b/run-downloadDb.js index fdb21cd..d4622e2 100644 --- a/run-downloadDb.js +++ b/run-downloadDb.js @@ -1,6 +1,6 @@ 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 { error, log } from './lib/log.js'; import { createDb, userSchema } from './lib/schema.js'; @@ -19,9 +19,10 @@ const ctx = 'downloadDb.js'; */ const downloadDb = async () => { log(ctx, 'Grabbing db'); - let directory = '', threadMax = 1, db, usersPerBatch, waitTime; + let directory = '', threadMax = 1, db, usersPerBatch, waitTime, site; try { directory = getArg('path'); + site = validateSiteArg(getArg('site')); } catch (err) { error(ctx, err); return; @@ -77,7 +78,13 @@ const downloadDb = async () => { const errorReadout = []; const executeDl = async (arr) => { log(ctx, `Downloading media using //media for ${arr.length} users`); - await getMany(arr, threadMax, directory, 'media'); + await getMany({ + userDb: arr, + threadMax, + directory, + mode: 'media', + site, + }); arr.forEach(entry => { entry.logs.forEach(log => { @@ -93,8 +100,16 @@ const downloadDb = async () => { }); }); - log(ctx, 'Downloading media using /search'); - await getMany(arr, threadMax, directory, 'search'); + if (site === SITES.TWITTER) { + log(ctx, 'Downloading media using /search'); + await getMany({ + userDb: arr, + threadMax, + directory, + mode: 'search', + site, + }); + } } if (!!usersPerBatch) { diff --git a/run-downloadUsers.js b/run-downloadUsers.js index a83288e..6b88534 100644 --- a/run-downloadUsers.js +++ b/run-downloadUsers.js @@ -1,6 +1,6 @@ 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 { error, log } from './lib/log.js'; import { createDb, userSchema } from './lib/schema.js'; @@ -15,10 +15,11 @@ const ctx = 'downloadUser.js'; */ const downloadUsers = async () => { log(ctx, 'Grabbing db'); - let directory, threadMax = 1, users, db; + let directory, threadMax = 1, users, db, site; try { directory = getArg('path'); users = getArg('users').split(','); + site = validateSiteArg(getArg('site')); } catch (err) { error(ctx, err); return; @@ -59,10 +60,22 @@ const downloadUsers = async () => { })); log(ctx, `Downloading media using //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'); - await getMany(processes, threadMax, directory, 'search'); + if (site === SITES.TWITTER) { + log(ctx, 'Downloading media using /search'); + await getMany({ + userDb: processes, + threadMax, + directory, + mode: 'search', + }); + } processes.forEach(entry => { entry.logs.forEach(log => {