From 847ec251941a7f0d0e699c37ee45cacedb8839bf Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 26 Aug 2026 06:55:56 -0400 Subject: litterbox: convert usage to POD, add --man option. --- litterbox | 200 +++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 140 insertions(+), 60 deletions(-) diff --git a/litterbox b/litterbox index cf2b209..a5e3c1d 100755 --- a/litterbox +++ b/litterbox @@ -1,13 +1,8 @@ #!/bin/bash -# API spec: https://litterbox.catbox.moe/tools.php -# curl -F "reqtype=fileupload" -F "time=1h" -F "fileToUpload=@filename" \ -# https://litterbox.catbox.moe/resources/internals/api.php -# time can be 1h, 12h, 24h, or 72h -# The following file types are currently not allowed: -# .exe, .scr, .cpl, .doc*, .jar -# ...so this script will gzip those automatically. +# based on the API spec: https://litterbox.catbox.moe/tools.php +VERSION="0.0.1" SELF="$( basename $0 )" APIURL="https://litterbox.catbox.moe/resources/internals/api.php" URLS="" @@ -29,61 +24,16 @@ info() { } usage() { - cat < - $SELF -d [-o output] url /dev/null; then + echo "$SELF: can't find perldoc on PATH, printing raw POD." 1>&2 + exec sed -n '/^=pod/,/^=cut/p' $0 + fi -Note: With the -c and -d option, you will be prompted interactively -for the encryption key (password), on the process's controlling tty. + exec perldoc "$0" +} -Author: B. Watson -License: WTFPL (Do WTF you want with this) -EOF +manpage() { + exec pod2man --stderr -s1 -c"UrchlaysStuff" -r$VERSION "$0" } set_expiration() { @@ -222,6 +172,10 @@ download_and_decrypt() { } # main() +if [ "$1" = "--man" ]; then + manpage ; exit 0 +fi + if [ "$1" = "--help" ]; then usage ; exit 0 fi @@ -298,3 +252,129 @@ copy_urls info "$UPLOAD_COUNT file(s) uploaded" exit 0 + +# Rest of the file is perldoc. +: < - upload files to litterbox.catbox.moe + +=head1 SYNOPSIS + +B [-e I] [-g] [-z] [-c] [-v] I > + +B -d [-o I] I > + +=head1 DESCRIPTION + +B uploads files to (or downloads files from) the temporary +file storage site B. The site is +similar to a "pastebin" site, except that it allows any type of +file (not just text), and uploads can be up to 1GB in size. + +=head2 Uploading + +Each I can be a filename, a directory name, or "-" for standard +input. If no files are given, litterbox reads from standard input. +Directories are uploaded as B<.tar.gz> archives, by default. Files +can be optionally encrypted with AES-256. + +Once a file is uploaded, its URL is printed on stdout. If B(1) +is installed, URLs are also copied to the X paste buffer (separated +by spaces). + +When uploading multiple files, a delay of 2 seconds is added between +uploads, to avoid hammering the site. + +=head2 Downloading + +Download mode is only for downloading AES-256 encrypted files that +were previously uploaded with B. Non-encrypted files can +simply be downloaded with B(1), B(1), a web browser, etc. +You will, of course, have to provide the correct decryption key +(password). + +=head1 OPTIONS + +=head2 Upload Options + +=over 4 + +=item B<-e> I + +Set expiration time in hours. Allowed values are B<1>, B<12>, +B<24>, or B<72>. Default is B<1>. + +=item B<-g> + +Upload gzipped files. This is automatically enabled +when uploading files whose names end in .exe, .scr, +.cpl, .doc*, .jar (unless B<-z> is given). Also, directories +are automatically tarred/gzipped (unless B<-z> is given). + +=item B<-z> + +Upload zipped files or dirs, rather than .tar.gz. + +=item B<-c> + +Upload encrypted file. Currently this means the file +is encrypted with 'openssl enc -pbkdf2 -aes-256-cbc', and +you're prompted for an encryption key. Whoever downloads +the encrypted file will have to decrypt it with the B<-d> +option, or else do it manually. + +=back + +=head2 Download Options + +=over 4 + +=item B<-d> + +Download and decrypt previously uploaded file(s) from URL(s). +Equivalent to downloading the file normally, then piping it +through: + + openssl enc -d -pbkdf2 -aes-256-cbc + +...which means the file will be printed to your terminal, unless you +use shell redirection or the -o option. The upload options above (-e +B<-g> B<-z> B<-t> B<-c>) are ignored in download mode. + +=item B<-o> I + +Set output file for B<-d> option. Note that giving multiple URLs +will result in all the data being written to the same file. If you need +separate files, run B multiple times. + +The B<-o> option is ignored in upload mode (when B<-d> is not used). + +=back + +=head2 General Options + +=over 4 + +=item B<-v> + +Verbose operation. + +=back + +Note: With the -c and -d option, you will be prompted interactively +for the encryption key (password), on the process's controlling tty. + +=head1 AUTHOR + +B. Watson + +=head1 COPYRIGHT + +B is licensed under the WTFPL: do WTF you want to with this. +See http://www.wtfpl.net/txt/copying/ for details. + +=cut +EOF -- cgit v1.2.3