Nyuu

repository·master·Indexed 43 days ago

https://github.com/animetosho/nyuu

A high-performance, command-line binary Usenet poster built on Node.js. Version 0.4.2 features a compiled yencode module for efficient encoding, support for NZB generation, dynamic token evaluation for filenames and headers, and flexible server connection options including SSL/TLS and custom HTTP posting methods.

Tokens
9.2K
Snippets
28
Records
43
Agent score
55%

What's inside Nyuu

  1. Use Subject and Filename Placeholders

    master

    Nyuu provides several placeholders for use in --subject, --filename, --message-id, and --yenc-name.

    Subject Placeholders:

    • {filenum}: Current file number in collection
    • {0filenum}: Padded file number (e.g., 01, 02)
    • {files}: Total number of files in collection
    • {filename}: File's name
    • {fnamebase}: File's name without extension
    • {filesize}: File's size in bytes
    • {fileksize}: File's size in KiB (use {filemsize}, {filegsize}, etc., for MiB, GiB, TiB)
    • {fileasize}: Friendly size (e.g., '4.85 MiB')
    • {part}: Article part number (starts at 1)
    • {0part}: Padded article part number
    • {parts}: Total number of articles for the file
    • {size}: Article chunk size (before yEnc)
    • {comment}: Value from --comment
    • {comment2}: Value from --comment2
    • {timestamp}: Unix timestamp (Note: not intended for --subject)
    • ${rand(N)}: Random text, N characters long

    Filename Placeholders:

    • {filename}: Full file name and path
    • {basename}: Base file name without path
    • {pathname}: Path component of file name
  2. Handle Input Files and Directories

    master

    Nyuu accepts files directly as arguments or via specific input options:

    Directory Handling:

    • -r, --subdirs: Control recursion. Options: skip (ignore nested), include (non-recursive, default), or keep (recursive).
    • -L, --skip-symlinks: Ignore all symbolic links (flag).
    • --include-empty: Include 0-byte files (flag).

    Input Methods:

    • -i, --input-file: Read file list from a text file. Use - for stdin or proc:// for command output. Supports multiple uses.
    • -0, --input-file0: Same as --input-file but uses null characters as separators.
    • --input-file-enc: Encoding for input files (default utf8).

    Process Input (Piping): To pipe from a command while satisfying yEnc's requirement for known file sizes, use the procjson:// syntax: procjson://"[name]",[size_in_bytes],"[command]"

    Example: procjson://"myfile.dat",1048576,"cat /dev/urandom"

    nyuu --input-file list.txt my_dir/
  3. Nyuu CLI Usage Overview

    master

    Nyuu is a flexible binary Usenet poster. The basic command-line syntax is:

    nyuu [options] file1 file2 ...

    All options accept one parameter except for flag options. You can also use a custom configuration file via the --config option. If using a config file, you can explicitly disable a flag option by prefixing its name with no- (e.g., --no-ssl).

    nyuu [options] file1 file2 ...
  4. Install Nyuu via NPM

    master

    If you have NPM installed, you can install Nyuu globally using the following command. This allows you to run Nyuu directly via the nyuu command.

    If you encounter a gyp ERR! stack Error: EACCES: permission denied error during installation, use the --unsafe-perm flag to ensure the yencode module installs correctly. This is also recommended if you encounter the error Error: Cannot find module './build/Release/yencode.node' when running Nyuu.

    # Standard installation
    npm install -g nyuu --production
    
    # Installation if permission errors occur
    npm install -g nyuu --production --unsafe-perm
  5. Use Nyuu to upload files to a Usenet server

    master

    Nyuu is a flexible binary Usenet poster. You can upload individual files or entire directories to an NNTP/NNTPS server.

    Basic usage follows the pattern: nyuu [options] file1 file2 ...

    If you provide a directory as an argument, Nyuu will process the files within it. Use the --subdirs option to control recursive behavior.

    nyuu -h example.com some_file
  6. Copy input files to a file or process (Experimental)

    master

    Nyuu can copy input files to a specified file or the stdin of a process while uploading. This avoids additional disk reads. Use the -I or --copy-input flag followed by a destination string using the same syntax as --out.

    Placeholders

    • {filename}: The upload name of the file (no path).
    • {size}: The size of the file in bytes.

    WARNING: {filename} is not sanitized. Use extreme caution when using it within shell commands.

    Copying Options

    OptionDescription
    -I, --copy-inputCopy each input into specified file or stdin of specified process.
    --copy-includeRegex filter for files to copy. Default: .* (all files).
    --copy-excludeRegex filter to exclude files from being copied. Default: .^ (no files).
    --copy-queue-sizeMax unconsumed buffer size for copied inputs. If full, processing slows down. Set to 0 for no limit. Default: 4.
    # Example: Generate MD5 hashes of input files without re-reading from disk
    nyuu -I 'proc://echo `md5sum|sed s/-//` {filename} >>md5list' <files>
  7. Run Nyuu as an executable

    master

    Once dependencies are installed, you can run Nyuu using the Node.js runtime:

    node bin/nyuu
    # or
    nodejs bin/nyuu

    Creating a system-wide nyuu command (Linux/macOS)

    To use the nyuu command directly without specifying the path to the script, create a symbolic link in your PATH:

    ln -s "`pwd`/bin/nyuu.js" /usr/bin/nyuu
    chmod a+x bin/nyuu.js

    Creating a nyuu command (Windows)

    Create a file named nyuu.cmd in your system directory with the following content (adjusting paths to your actual installation):

    @"C:\node\node.exe" "C:\path\to\nyuu\bin\nyuu.js" %*
    node bin/nyuu
  8. Install Nyuu from source

    master

    To set up Nyuu from source, navigate to the Nyuu directory and install the production dependencies using NPM:

    npm install --production

    Manual Dependency Management: If you do not wish to use NPM, you must manually create a node_modules directory in the Nyuu root and place the async and yencode packages inside it. The structure should look like this:

    Nyuu/
    - bin/
    - lib/
    - node_modules/
      - async/
        - package.json
      - yencode/
        - index.js
    package.json

    Note: yencode requires following its own specific installation instructions.

  9. Use a custom configuration file

    master

    Instead of long CLI commands, you can use a custom configuration file.

    • Use the --config (-C) option to specify the path to your config file.
    • The configuration file should be a JSON file (see config-sample.json for an example).
    • The keys in the JSON file correspond to the full command-line option names (e.g., host, ssl, user).
    • Disabling flags in config: If a flag option is set in the config file, you can explicitly disable it by prefixing the name with no- (e.g., --no-ssl).
  10. Use procjson:// protocol for process input

    master

    Nyuu supports a special URI scheme procjson:// to stream data directly from an external command instead of reading from a physical file. This is useful for piping output from other tools into Nyuu.

    Syntax: procjson://[name],[size],[command]

    • name: The name assigned to the input.
    • size: The expected size in bytes (integer).
    • command: The shell command to execute. The output of this command's stdout will be used as the file stream.

    If the command is provided but the size is 0, and no command is given, the stream is treated as null.

    procjson://my-stream,1024,cat /tmp/data.txt
  11. Use token evaluation for dynamic filenames and headers

    master

    Nyuu supports dynamic string evaluation using tokens or JavaScript expressions. This is useful for generating unique filenames, headers, or comments based on file metadata.

    Token Evaluation Mode

    Enable this mode using the --token-eval or -E flag. When enabled, you can use template literals (backticks `) and standard JavaScript logic within your strings.

    Available Tokens

    Tokens are used within ${...} or $... syntax. Common tokens include:

    • ${filenum} / ${0filenum}: Current file number (with optional zero-padding).
    • ${files}: Total number of files.
    • ${filename}: The filename.
    • ${fnamebase}: Filename without the extension/part suffix.
    • ${filesize}: File size in bytes.
    • ${fileksize} / ${filemsize} / ${filegsize} / ${filetsize}: File size in KB, MB, GB, or TB.
    • ${fileasize}: Human-readable file size.
    • ${part} / ${0part}: Current part number (with optional zero-padding).
    • ${parts}: Total number of parts.
    • ${comment} / ${comment2}: Values from --comment or --comment2 flags.
    • ${timestamp}: Generation time.
    • ${rand(n)}: Generates a random string of length n.

    Example Usage

    # Using tokens to create a patterned filename
    nyuu --filename "${fnamebase}_${0part}of${parts}.yenc" file1.yenc file2.yenc
    
    # Using token-eval for complex logic
    nyuu -E --filename "upload_${filesize}_${rand(5)}.dat" file.dat
  12. Configure Nyuu with a configuration file

    master

    To avoid long command-line arguments, you can use a JSON configuration file. Use the --config or -C flag to specify the file path.

    Nyuu will also automatically check the NYUU_CONFIG environment variable for a default configuration file if no config is explicitly provided via flags.

    nyuu --config path/to/config.json
    # or
    nyuu -C path/to/config.json