download bsky support
This commit is contained in:
parent
a0f7e16fc3
commit
394370fb55
2 changed files with 38 additions and 10 deletions
|
@ -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 /<user>/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 () => {
|
|||
});
|
||||
});
|
||||
|
||||
if (site === SITES.TWITTER) {
|
||||
log(ctx, 'Downloading media using /search');
|
||||
await getMany(arr, threadMax, directory, 'search');
|
||||
await getMany({
|
||||
userDb: arr,
|
||||
threadMax,
|
||||
directory,
|
||||
mode: 'search',
|
||||
site,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!!usersPerBatch) {
|
||||
|
|
|
@ -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 /<user>/media for ${processes.length} users`);
|
||||
await getMany(processes, threadMax, directory, 'media');
|
||||
await getMany({
|
||||
userDb: processes,
|
||||
threadMax,
|
||||
directory,
|
||||
mode: 'media',
|
||||
});
|
||||
|
||||
if (site === SITES.TWITTER) {
|
||||
log(ctx, 'Downloading media using /search');
|
||||
await getMany(processes, threadMax, directory, 'search');
|
||||
await getMany({
|
||||
userDb: processes,
|
||||
threadMax,
|
||||
directory,
|
||||
mode: 'search',
|
||||
});
|
||||
}
|
||||
|
||||
processes.forEach(entry => {
|
||||
entry.logs.forEach(log => {
|
||||
|
|
Loading…
Add table
Reference in a new issue