npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

shua

v3.1.1

Published

A lovely downloader

Downloads

139

Readme

Shua

Shua is a common file downloader implemented by Node.js. Inspired by Minyami download core.

The target of Shua is to provide a way to download thousands of small files in a short time.

Installation

npm install -g shua

Note: Shua needs Node.js 12.0.0+.

Expressions

Shua supports generating urls from a url expression.

Integer Expressions

Syntax: {{%d(start: integer, end: integer, step?: integer, leftPad?: integer)}}

For example, to download

https://example.com/segment1.ts
https://example.com/segment2.ts
https://example.com/segment3.ts
...
https://example.com/segment100.ts

Just use the following command

shua -e "https://example.com/segment{{%d(1, 100)}}.ts"

Multi expressions is also supported.

To download

https://example.com/segment1_1.ts
https://example.com/segment1_2.ts
...
https://example.com/segment1_10.ts
https://example.com/segment2_1.ts
https://example.com/segment2_2.ts
...
https://example.com/segment2_10.ts
...
https://example.com/segment5_10.ts

Use the following expression

shua -e "https://example.com/segment{{%d(1, 5)}}_{{%d(1, 10)}}.ts"

To download

https://example.com/segment001.ts
https://example.com/segment002.ts
https://example.com/segment003.ts
...
https://example.com/segment100.ts

Use

shua -e "https://example.com/segment{{%d(1, 100, 1, 3)}}.ts"

Example

Download all urls from a.txt with 16 threads

shua -f a.txt --threads 16

Options

--file, -f <path>

Download all URLs containing in a file. Both local path and remote URLs are supported as import. Lines couldn't be parsed as an valid URL will be ignored by default.

Examples

shua -f "files.txt"
shua -f "https://example.com/file_list.txt"

--expression, -e <expression>

Download all URLs generated from a expression. See Expressions section above.

--json, -j <path>

Download tasks defined in a json file. JSON files should contain a DownloadTask array.

interface DownloadTask {
    /** URL */
    url: string;
    /** retry count */
    retryCount: number;
    /** output filename */
    filename?: string;
    /** custom HTTP headers */
    headers?: Record<string, string>;
}
type Tasks = DownloadTask[];

--threads <limit>

Threads limit.

--retries, -r <limit>

Max attempts for download tasks.

--timeout <threshold>

Timeout threshold for download tasks in milliseconds.

--concat, -c (3.0.0+)

Concatenate all downloaded files into a single output file.

--output, -o <name>

Output folder name.

Nested paths are not supported now.

if --concat is provided, --output will be used for concentration.

--ascending, -a

Rename output files in numerical ascending order.

--debug, --verbose

Enable debug log output.

Use as a library

Getting Started

import { Downloader } from 'shua';
const downloader = new Downloader();
downloader.addUrlsFromFile('urls.txt');
downloader.on('finish', () => {
   console.log('All files downloaded!');
});
downloader.start();

Events

| Event Name | Parameters | | ------------- | ------------------------------------------- | | progress | finishedCount: number, totalCount: number | | task-finish | task: Task | | task-error | err: Error, task: Task | | finish | |