pax_global_header00006660000000000000000000000064131421000240014475gustar00rootroot0000000000000052 comment=5d812d8040235b4100053b1331404aee9a58bbfa plowshare-2.1.7/000077500000000000000000000000001314210002400135105ustar00rootroot00000000000000plowshare-2.1.7/.gitignore000066400000000000000000000001221314210002400154730ustar00rootroot00000000000000*.orig *.rej *~ *.*.swp debian/*.log debian/*.substvars debian/*/*/* debian/files plowshare-2.1.7/AUTHORS000066400000000000000000000003511314210002400145570ustar00rootroot00000000000000Current Developers ------------------ Matthieu Crapet Former Developers ----------------- Arnau Sanchez Jan Jason Mon, 07 Aug 2017 16:45:55 +0200 plowshare (2.1.6) stable; urgency=low * API function delete_filter_line: eat lines until regexp is met. Bump PLOWSHARE_API_VERSION to 6. * [core] Handle CONT signal (wait time will be updated on ^Z) (#56) * [core] Introduce PLOWSHARE_CURL and PLOWSHARE_JS environment variables to override default curl and js commands. -- Matthieu Crapet Sun, 30 Oct 2016 10:45:08 +0100 plowshare (2.1.5) stable; urgency=low * Various documentation and help improvements * [plowlist] Add -t/--timeout command-line switch (useful for mirroring/multiupload hosters) * API function delete_last_line: add second optional argument (number of lines). Bump PLOWSHARE_API_VERSION to 5. * [core] Consider $XDG_CONFIG_HOME (default is ~/.config) -- Matthieu Crapet Fri, 10 Jun 2016 18:19:57 +0200 plowshare (2.1.4) stable; urgency=low * [plowup] allow local/remote filename having , or ; characters. This is a workaround to curl limitation. (#37) * New API for modules: sha1_file(). Bump PLOWSHARE_API_VERSION to 4. (#43) * [plowup] Add %T --printf token to get (current) time (#45) * [core] update imgur API to 3 (#42) -- Matthieu Crapet Sun, 24 Apr 2016 10:58:53 +0200 plowshare (2.1.3) stable; urgency=low * [core] update reCAPTCHA behavior (PR #36) * [plowup] Add --run-before switch * New internal error code (for modules): $ERR_EXPIRED_SESSION. Bump PLOWSHARE_API_VERSION to 3. -- Matthieu Crapet Thu, 24 Mar 2016 13:34:41 +0100 plowshare (2.1.2) stable; urgency=low * [core] Minor fixes. More cygwin/bsd friendly. -- Matthieu Crapet Sat, 15 Aug 2015 12:17:36 +0200 plowshare (2.1.1) stable; urgency=medium * [plowmod] Fixes with git (requires git v1.8.5+) * [plowmod] Add --status command-line switch -- Matthieu Crapet Sun, 03 May 2015 08:42:43 +0200 plowshare (2.1.0) stable; urgency=medium * Documentation refactor. Add plowshare.conf.sample file. * Support user modules ~/.config/plowshare/modules.d/* scheme * [plowmod] Add tool to ease modules repositories management -- Matthieu Crapet Thu, 09 Apr 2015 08:43:05 +0200 plowshare (2.0.1) stable; urgency=low * bash completion (plowdown, plowup): add missing --cache support * Enhance documentation concerning split of modules and core -- Matthieu Crapet Tue, Feb 24 17:36:17 2015 +0100 plowshare (2.0.0) stable; urgency=low * First version shipped without any module. Only core here. Module sources have been committed in a new GIT repository. -- Matthieu Crapet Wed, Feb 18 00:29:16 2015 +0100 plowshare (1.3.0) stable; urgency=low * Add user modules support (~/.config/plowshare/modules) * This is the last version shipped with modules -- Matthieu Crapet Wed, Feb 18 00:03:13 2015 +0100 plowshare (1.2.0) stable; urgency=low * Add colors for log_notice (yellow) and log_error (red) * [plowprobe] Add %v and %V --printf tokens. Idea here is to get primary url. Hosters usually provide several links (with or without filename or using short hostname). * API function list_submit: allow single name as second argument. Bump PLOWSHARE_API_VERSION to 2. -- Matthieu Crapet Sun, Jan 11 14:52:51 2015 +0100 plowshare (1.1.0) stable; urgency=low * Add some --printf tokens for JSON processing (%U, %D, %A) Important change for plowup, the two aliases change: %D => %L and %A => %M * Add --curlrc= command-line option * [plowlist, plowdel] Add --no-curlrc command line option * [core] Define PATH only when required (process_core_options) -- Matthieu Crapet Sun, Nov 23 18:20:20 2014 +0100 plowshare (1.0.6) stable; urgency=low * [plowdown] Clean all files when --cache=session * [plowdown] Ignore -O/-J switches in MODULE_xxx_DOWNLOAD_FINAL_LINK_NEEDS_EXTRA (requires cURL 7.25.1+) * [plowdown, plowup, plowprobe] Fix --no-curlrc option * [core] Add JSON unicode string support (parse_json). For Bash 4.2+ users. -- Matthieu Crapet Fri, Oct 24 18:57:49 2014 +0200 plowshare (1.0.5) stable; urgency=low * [plowdown] Drop --cookies switch * [plowdown, plowup] Add --cache switch * Introduce storage API functions. Bump PLOWSHARE_API_VERSION to 1. * [core] Add 'c' & 'C' types for argument parsing (process_options) * [plowdown] Fix MODULE_xxx_DOWNLOAD_FINAL_LINK_NEEDS_EXTRA with bash 4.3 * [plowprobe] Add %T token (file timestamp) to --printf switch * Deleted modules: anonymousdelivers.us, extabit, thefilebay -- Matthieu Crapet Thu, Aug 28 22:07:21 2014 +0200 plowshare (1.0.4) stable; urgency=low * Add captchacoin captcha recognition system support * [plowdown, plowup, plowdel] --captchaprogram considers ~/.config/plowshare/exec/ directory -- Matthieu Crapet Sun, Jul 20 11:56:24 2014 +0200 plowshare (1.0.3) stable; urgency=low * [plowdown, plowup] Test for POSIX mode * [plowprobe] Fix unwanted debug message -- Matthieu Crapet Sat, May 31 10:09:41 2014 +0200 plowshare (1.0.2) stable; urgency=low * [core] Add 't' type for argument parsing (process_options) * [core] Prefer command xxx over $(type -P xxx) -- Matthieu Crapet Fri, May 2 13:35:04 2014 +0200 plowshare (1.0.1) stable; urgency=low * [plowdown] Add --min-space command-line option * Add support for fbi (framebuffer image viewer), consider FRAMEBUFFER environment variable (/dev/fb0 is the default) * Deleted modules: cloudzer.net, filebox -- Matthieu Crapet Fri, Mar 28 20:35:17 2014 +0100 plowshare (1.0.0) stable; urgency=low * Resume strict versioning. Plowshare is now packaged officially in several Linux distributions (fedora, archlinux, gentoo). * Changes/Fixes to modules (hosters) are numerous, they will not be listed here * Introduce PLOWSHARE_API_VERSION variable to track carefully API changes * [plowup] Introduce --name command line option (replaces --name-suffix & --name-prefix) * [plowdown] Allow direct FTP download (enable it with --fallback * Deleted modules: hotfiles, putlocker -- Matthieu Crapet Sat, Mar 1 10:31:01 2014 +0100 plowshare (GIT-snapshot) stable; urgency=medium * Migrating to GIT repository. SVN revision number is replaced with short commit hash + date. -- Matthieu Crapet Tue, 16 Aug 2011 20:03:33 +0200 plowshare (SVN-snapshot) stable; urgency=medium * As e-storage websites are continuously updated, I suspend versioning policy and now rely on SVN revision number. No version can be considered as stable as long as websites keep being updated all the time. See googlecode SVN log history for recent news. -- Matthieu Crapet Sat, 18 Dec 2010 15:44:39 +0100 plowshare (0.9.4) stable; urgency=high * [download] Fix broken modules: badongo, divshare.com, mediafire, rapidshare, 2shared * [download] Add -v4 verbosity message level (very noisy, for bug report) * [2shared] Add delete function * [mediafire] Add upload function * [4shared] Add list function * [depositfiles] Add list function * [rapidshare] upload/delete functions disabled * Deleted modules: filefactory, letitbit, storage.to, uploaded.to -- Arnau Sanchez Tue, 27 Oct 2010 20:47:09 +0200 plowshare (0.9.3) stable; urgency=high * Add 1 new module (free download): 115.com * Add list support: megaupload, sendspace * [plowdown] New fancy countdown * [plowup] Show curl upload progress * [download] Fix broken modules: badongo, divshare.com, filefactory, mediafire * [zshare] Fix missing description field (upload) -- Arnau Sanchez Fri, 04 Jun 2010 10:52:08 +0200 plowshare (0.9.2) unstable; urgency=medium * Add 3 new modules (free download): filefactory, humyo, data.hu * Deleted 2 modules (now use recaptcha): loadfiles.in, freakshare.net * [rapidshare] Add premium-zone upload * [zshare] Add delete function * [mediafire] Fix free download (website keeps changing obfuscated javascript code) * [download] Add --temp-directory option (saves partial download here before mv) * [download] Add -x/--no-overwrite option (do not overwrite existing files) * [download] Add -v1/-v2/-v3 verbosity message level * Add plowlist: Download a list of links inside folder/containers -- Arnau Sanchez Sun, 21 Feb 2010 10:45:52 +0100 plowshare (0.9.1) stable; urgency=medium * Add 4 new modules (anonymous download): divshare.com, freakshare.net, loadfiles.in, dl.free.fr * [zshare] Add anonymous upload * [download] Add --get-module option (aimed for wrappers to manage parallel download) * [download] Add -t/--timeout option (restrict time for download a link) * [download] Add --max-retries option (restrict attempts for loop, mostly captchas) * [rapidshare] add Premium-Zone download -- Arnau Sanchez Tue, 09 Feb 2010 12:43:07 +0100 plowshare (0.9) stable; urgency=medium * Add 7 new modules (anonymous download): netload.in, storage.to, uploaded.to, uploading.com, sendspace, usershare, x7.to * [lib] Fallback to img2txt (libcaca) if aview is not found. * [download] replace -l for -r. * [download] Add -i network_interface option -- Arnau Sanchez Thu, 10 Dec 2009 20:23:20 +0100 plowshare (0.8.1) stable; urgency=medium * Add plowdel executable * [plowdown] Add new -r RATE/--limit-rate=RATE option * [megaupload] Add delete support -- Arnau Sanchez Wed, 07 Oct 2009 22:45:53 +0200 plowshare (0.8) stable; urgency=low * Added module for depositfiles (download only) * [download] New option -o DIR, --output-directory=DIR * [megaupload] Use tesseract as OCR for the new simpler captcha * [megaupload] Support for multifetch uploads * [rapidshare] More tolerant wait messages parsing -- Arnau Sanchez Sat, 16 May 2009 11:52:51 +0200 plowshare (0.7.1) unstable; urgency=low * Improve download/upload loops (retry on non-fatal network problems) * Fix test library * [mediafire] update module to website changed in HTML -- Arnau Sanchez Sun, 03 May 2009 22:49:31 +0200 plowshare (0.7) unstable; urgency=low * [zshared] add module (download) * [megaupload] refactor catpcha decoder -- Arnau Sanchez Wed, 15 Apr 2009 18:23:05 +0200 plowshare (0.6) unstable; urgency=low * [4shared] add module and download support for 4shared * [megaupload] increase slightly the OCR rate (~ 40%) * [download] add check-link support for all existing modules -- Arnau Sanchez Sat, 28 Mar 2009 15:51:48 +0100 plowshare (0.5.3) unstable; urgency=low * [megaupload] Support new 4-rotated-highly-overlapped captcha -- Arnau Sanchez Sat, 21 Mar 2009 00:09:22 +0100 plowshare (0.5.2) unstable; urgency=low * Fix setup.sh bugs -- Arnau Sanchez Sun, 15 Mar 2009 01:08:57 +0100 plowshare (0.5.1) unstable; urgency=low * Add support for the new 4-rotated-bold-character megaupload captcha * Change arguments order for plowup -- Arnau Sanchez Sat, 14 Mar 2009 23:38:31 +0100 plowshare (0.5) unstable; urgency=low * Support new megaupload captcha (4 non-rotated chars) * Add support for mediafire download * Add GNU GPL notices to all sources -- Arnau Sanchez Mon, 09 Mar 2009 17:34:04 +0100 plowshare (0.4.5) unstable; urgency=low * Improved speed of Megaupload catpcha OCR * Removed JDownloader database * Refactored input-captcha option (now uses aview) -- Arnau Sanchez Fri, 06 Mar 2009 00:36:34 +0100 plowshare (0.4.4) unstable; urgency=low * Fix some setup.sh bugs (thanks to karkoma) * Add input-captcha option to megaupload download allowing user input (suggested by pwang07) -- Arnau Sanchez Wed, 04 Mar 2009 00:10:42 +0100 plowshare (0.4.3) unstable; urgency=low * Add badongo module (download implemented) * Fix bug in process_options loop -- Arnau Sanchez Tue, 03 Mar 2009 12:45:21 +0100 plowshare (0.4.2) unstable; urgency=low * Update megaupload captchas is now manual (plowdown -u) -- Arnau Sanchez Sat, 28 Feb 2009 21:36:30 +0100 plowshare (0.4.1) unstable; urgency=low * Use JDownloader database for megaupload captchas (OCR can also be used) -- Arnau Sanchez Sat, 28 Feb 2009 15:52:43 +0100 plowshare (0.4) unstable; urgency=low * Decode (slow and low accuracy code) new Megaupload captcha (4-chars with rotation). -- Arnau Sanchez Fri, 27 Feb 2009 21:23:10 +0100 plowshare (0.3.5) unstable; urgency=low * Fix long options bug * Add continuation option for download * Add mark option for download (comment downloaded links in FILE arguments) * Megaupload captcha still broken -- Arnau Sanchez Thu, 26 Feb 2009 13:36:17 +0100 plowshare (0.3.4) unstable; urgency=low * Premium account support for megaupload (thanks to Eric Soukenka) * More options to megaupload upload (email-from, email-to, multiemail, trafficurl, password) * Option to download only the output link (without downloading the file) * Option to download password-protected files * Module options changed -- Arnau Sanchez Sat, 21 Feb 2009 22:58:24 +0100 plowshare (0.3.3) unstable; urgency=low * Use recode to allow filenames with unicode chars. -- Arnau Sanchez Thu, 19 Feb 2009 10:24:45 +0100 plowshare (0.3.2) unstable; urgency=low * Fix time-wait get in megaupload free-membership * Create our own tempfile function -- Arnau Sanchez Wed, 18 Feb 2009 10:32:44 +0100 plowshare (0.3) unstable; urgency=high * Update megaupload module to the new 4-char captcha * Update login to megaupload -- Arnau Sanchez Wed, 18 Feb 2009 01:27:16 +0100 plowshare (0.2.1) unstable; urgency=low * Fix rapidshare freezone upload -- Arnau Sanchez Sat, 14 Feb 2009 18:52:25 +0100 plowshare (0.2) unstable; urgency=low * Simplify captcha decoding in megaupload (thanks to George Averill) * Use js or smjs (idem) * Disable glob in curl file download (idem) * Restructure code directories * Add -q,--quiet global option * 2Shared upload * Add independent options to module's functions * Rapidshare upload (anonymous and free-zone) -- Arnau Sanchez Tue, 27 Jan 2009 23:05:02 +0100 plowshare (0.1.4) unstable; urgency=low * Correct upload process -- Arnau Sanchez Sat, 24 Jan 2009 19:40:38 +0100 plowshare (0.1.3) unstable; urgency=low * Minor correction for 2shared -- Arnau Sanchez Sat, 24 Jan 2009 19:36:35 +0100 plowshare (0.1.2) unstable; urgency=high * Upload script was missing -- Arnau Sanchez Sat, 24 Jan 2009 18:55:16 +0100 plowshare (0.1.1) unstable; urgency=high * Add tests -- Arnau Sanchez Sat, 24 Jan 2009 18:54:17 +0100 plowshare (0.1) unstable; urgency=high * First release -- Arnau Sanchez Sat, 24 Jan 2009 12:17:21 +0200 plowshare-2.1.7/COPYING000066400000000000000000001045131314210002400145470ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . plowshare-2.1.7/INSTALL000066400000000000000000000067111314210002400145460ustar00rootroot00000000000000Plowshare installation notes. Runtime dependencies ==================== To run plowshare you will need: * GNU/Linux basic operating system: coreutils (chmod, date, ...), sed, util-linux (kill), grep. Note for BSD/Mac OSX: requires gnu-sed. * Bash (version 4.1 or better). It will NOT work using Busybox or Dash (POSIX) shell. * cURL (version 7.24 or better). Compiled with SSL support. * Character encoding converter (to get proper filenames). This is optional. - recode or - perl and HTML::Entities module * Javascript interpreter. Used by few modules (mostly plowdown). - spidermonkey or - rhino (JavaScript engine written in Java) Some websites are using captchas. If you're not using an automatic solving service, you'll need a (X11, FB or ascii) picture viewer. * X11 viewers - display (imagemagick, X11) or - sxiv (imlib2, X11, very fast) or - feh (imlib2, X11) or - qiv (imlib2, X11) * Framebuffer viewers - fbi (frame buffer image viewer) or - fim (frame buffer and ascii art image viewer) * Ascii text viewers - aview (libaa) or - img2txt (libcaca) or - tiv (perl script using Image::Magick, color output) Installation (core) ============ This is the instructions to install plowshare. Plowshare modules installation is described in the next section. No compiler is required, it's only Bash scripts! 1) Automatic method: distro packages This is the easiest method, Plowshare is available for several Linux distribution: # Archlinux (https://www.archlinux.org/packages/community/any/plowshare/) $ pacman -Syu plowshare # Gentoo (http://packages.gentoo.org/package/net-misc/plowshare) $ emerge -av plowshare # Debian (https://packages.debian.org/sid/plowshare) # Note: For Debian 8 "Jessie", the package is called plowshare4. Recent versions are included in jessie-backports. $ apt-get install plowshare # Fedora & CentOS (https://admin.fedoraproject.org/updates/plowshare) $ yum install plowshare Note: You'll probably need to be root to install the plowshare package. # Mac OS X (with Homebrew) $ brew install plowshare 2) Manual method: from git sources $ git clone https://github.com/mcrapet/plowshare.git # If you have root privileges (like Ubuntu) $ sudo make install # For non root users, you can override default prefix (/usr) # (make sure you have $HOME/local/bin in you PATH) $ make install PREFIX=$HOME/local Note for FreeBSD users ---------------------- You must manually install from sources. You'll need GNU make (not bmake) and gnu-sed (or gsed) installed. Don't forget to properly define GNU_SED variable. # For example $ make install patch_gnused GNU_SED=/opt/bin/gnu-sed PREFIX=/usr Advanced users and maintainers ------------------------------ # If you are on a cross-compilation environment: # (default prefix is /usr) $ make install DESTDIR=/media/rootfs or $ make install PREFIX=/opt DESTDIR=/media/rootfs Installation (external modules) ============ 1) Automatic method: using plowmod $ plowmod --install plowmod is a simple tool for managing your modules directory (~/.config/plowshare/modules.d). If git (>1.8.5) is installed on your system, you can use later: $ plowmod --update Plowmod can handle 3rd part repositories. See man page for more information. 2) Manual method: from sources $ mkdir -p ~/.config/plowshare/modules.d $ cd ~/.config/plowshare/modules.d $ curl -L -k https://github.com/mcrapet/plowshare-modules-legacy/archive/master.tar.gz | tar zxf - $ mv plowshare-modules-legacy-master legacy # vim:fileencoding=utf-8 plowshare-2.1.7/Makefile000066400000000000000000000074311314210002400151550ustar00rootroot00000000000000## # Plowshare Makefile # Usage: # - make PREFIX=/usr/local install # - make PREFIX=/usr/local DESTDIR=/tmp/packaging install # # Important notes for OpenBSD, NetBSD and Mac OS X users: # - GNU make is required (for installation only), bmake does not support "addprefix" and "wildcard". # - GNU sed is required, be sure to properly define GNU_SED variable (gsed or gnu-sed) ## # Tools INSTALL = install LN_S = ln -sf RM = rm -f GNU_SED ?= sed # Files MODULE_FILES = $(wildcard src/modules/*.sh) src/modules/config SRCS = download.sh upload.sh delete.sh list.sh probe.sh core.sh mod.sh MANPAGES1 = plowdown.1 plowup.1 plowdel.1 plowlist.1 plowprobe.1 plowmod.1 MANPAGES5 = plowshare.conf.5 DOCS = README.md docs/plowshare.conf.sample BASH_COMPL = scripts/plowshare.completion GIT_VERSION = scripts/version # Target path # DESTDIR is for package creation only PREFIX ?= /usr BINDIR = $(PREFIX)/bin DATADIR = $(PREFIX)/share/plowshare DOCDIR = $(PREFIX)/share/doc/plowshare MANDIR = $(PREFIX)/share/man/man # Rules install: install_files patch_git_version patch_bash_completion install_files: @! test -d $(DESTDIR)$(DATADIR) || echo "===[Plowshare update]===" $(INSTALL) -d $(DESTDIR)$(BINDIR) $(INSTALL) -d $(DESTDIR)$(DATADIR) $(INSTALL) -d $(DESTDIR)$(DATADIR)/modules $(INSTALL) -d $(DESTDIR)$(DOCDIR) $(INSTALL) -d $(DESTDIR)$(MANDIR)1 $(INSTALL) -d $(DESTDIR)$(MANDIR)5 $(INSTALL) -m 644 $(MODULE_FILES) $(DESTDIR)$(DATADIR)/modules $(INSTALL) -m 755 $(addprefix src/,$(SRCS)) $(DESTDIR)$(DATADIR) $(INSTALL) -m 644 $(addprefix docs/,$(MANPAGES1)) $(DESTDIR)$(MANDIR)1 $(INSTALL) -m 644 $(addprefix docs/,$(MANPAGES5)) $(DESTDIR)$(MANDIR)5 $(INSTALL) -m 644 $(DOCS) $(DESTDIR)$(DOCDIR) $(LN_S) $(DATADIR)/download.sh $(DESTDIR)$(BINDIR)/plowdown $(LN_S) $(DATADIR)/upload.sh $(DESTDIR)$(BINDIR)/plowup $(LN_S) $(DATADIR)/delete.sh $(DESTDIR)$(BINDIR)/plowdel $(LN_S) $(DATADIR)/list.sh $(DESTDIR)$(BINDIR)/plowlist $(LN_S) $(DATADIR)/probe.sh $(DESTDIR)$(BINDIR)/plowprobe $(LN_S) $(DATADIR)/mod.sh $(DESTDIR)$(BINDIR)/plowmod uninstall: @$(RM) $(DESTDIR)$(BINDIR)/plowdown @$(RM) $(DESTDIR)$(BINDIR)/plowup @$(RM) $(DESTDIR)$(BINDIR)/plowdel @$(RM) $(DESTDIR)$(BINDIR)/plowlist @$(RM) $(DESTDIR)$(BINDIR)/plowprobe @$(RM) $(DESTDIR)$(BINDIR)/plowmod @rm -rf $(DESTDIR)$(DATADIR) $(DESTDIR)$(DOCDIR) @$(RM) $(addprefix $(DESTDIR)$(MANDIR)1/, $(MANPAGES1)) @$(RM) $(addprefix $(DESTDIR)$(MANDIR)5/, $(MANPAGES5)) @$(RM) $(addprefix $(DESTDIR)$(PREFIX)/share/bash-completion/completions/, $(MANPAGES1:%.1=%)) patch_git_version: install_files @v=`$(GIT_VERSION)` && \ for file in $(SRCS); do \ $(GNU_SED) -i -e 's/^\(declare -r VERSION=\).*/\1'"'$$v'"'/' $(DESTDIR)$(DATADIR)/$$file; \ done patch_bash_completion: install_files @$(INSTALL) -d $(DESTDIR)$(PREFIX)/share/bash-completion/completions @$(GNU_SED) -e '/cut/s,/usr/local/share/plowshare,$(DATADIR),' $(BASH_COMPL) > $(DESTDIR)$(PREFIX)/share/bash-completion/completions/plowdown @cd $(DESTDIR)$(PREFIX)/share/bash-completion/completions && $(LN_S) plowdown plowup @cd $(DESTDIR)$(PREFIX)/share/bash-completion/completions && $(LN_S) plowdown plowdel @cd $(DESTDIR)$(PREFIX)/share/bash-completion/completions && $(LN_S) plowdown plowlist @cd $(DESTDIR)$(PREFIX)/share/bash-completion/completions && $(LN_S) plowdown plowprobe # Note: sed append syntax is not BSD friendly! patch_gnused: install_files @for file in $(SRCS); do \ $(GNU_SED) -i -e '/\/licenses\/>/ashopt -s expand_aliases; alias sed='\''$(GNU_SED)'\' "$(DESTDIR)$(DATADIR)/$$file"; \ done # Shrink scripts by ~30% minify: install_files @for file in $(SRCS); do \ $(GNU_SED) -nf scripts/minify.sed -i "$(DESTDIR)$(DATADIR)/$$file"; \ done .PHONY: install uninstall install_files patch_git_version patch_bash_completion patch_gnused minify plowshare-2.1.7/README.md000066400000000000000000000412221314210002400147700ustar00rootroot00000000000000# Plowshare ## Introduction Plowshare is a set of command-line tools (written entirely in Bash shell script) designed for managing file-sharing websites (aka Hosters). Plowshare is divided into 6 scripts: - *plowdown*, for downloading URLs - *plowup*, for uploading files - *plowdel*, for deleting remote files - *plowlist*, for listing remote shared folders - *plowprobe*, for retrieving information of downloading URLs - *plowmod*, easy management (installation or update) of Plowshare modules Plowshare itself doesn't support any websites (named *module*). It's just the core engine. Concerning modules, few are available separately and must be installed in user directory (see [below](#install)). ### Features - Small footprint (few shell scripts). No java, no python. Run fast on embedded devices. - Few dependencies and portable. [Bash](https://www.gnu.org/software/bash/) and [cURL](http://curl.haxx.se/) are enough for most hosters. - Modules (hoster plugins) are simple to write using [Plowshare API](#implement-your-own-modules). - Support for automatic online captcha solver services. - Cache mechanism: hoster session or cookie reuse (to avoid relogin). ## Install See `INSTALL` file for details. ## Usage examples All scripts share the same verbose options: - `-v0` (be quiet, alias: `-q`) - `-v1` (errors only) - `-v2` (infos message; default) - `-v3` (show all messages) - `-v4` (show all messages, HTML pages and cookies, use this for bug report) Getting help: - `--help` - `--longhelp` (additionally prints modules command-line options) Exhaustive documentation is available in manpages. All examples below are using fake links. ### Plowdown Download a file from Rapidshare: ```sh $ plowdown http://www.rapidshare.com/files/86545320/Tux-Trainer.rar ``` Download a file from Rapidgator using an account (free or premium): ```sh $ plowdown -a 'myuser:mypassword' http://rapidgator.net/file/49b1b874 ``` **Note**: `:` is the separator character for login and password. Enclosing string using single quotes ensure against shell expansion. Download a list of links (one link per line): ```sh $ cat file_with_links.txt # This is a comment http://depositfiles.com/files/abcdefghi http://www.rapidshare.com/files/86545320/Tux-Trainer_25-01-2008.rar $ plowdown file_with_links.txt ``` Download a list of links (one link per line) commenting out (with `#`) those successfully downloaded: ```sh $ plowdown -m file_with_links.txt ``` **Note**: Files are consecutively downloaded in the order read from input text file. Download a file from Oron with Death by Captcha service: ```sh $ plowdown --deathbycaptcha='user:pass' http://oron.com/dw726z0ohky5 ``` Download a file from Rapidshare with a proxy (cURL supports `http_proxy` and `https_proxy` environment variables, default port is `3128`): ```sh $ export http_proxy=http://xxx.xxx.xxx.xxx:80 $ plowdown http://www.rapidshare.com/files/86545320/Tux-Trainer.rar ``` Download a file with limiting the download speed (in bytes per second): ```sh $ plowdown --max-rate 900K http://www.rapidshare.com/files/86545320/Tux-Trainer.rar ``` **Note**: Accepted prefixes are: `k`, `K`, `Ki`, `M`, `m`, `Mi`. Download a file from Rapidshare (like firefox: append `.part` suffix to filename while file is being downloaded): ```sh $ plowdown --temp-rename http://www.rapidshare.com/files/86545320/Tux-Trainer.rar ``` Download a password-protected file from Mediafire: ```sh $ plowdown -p 'somepassword' http://www.mediafire.com/?mt0egmhietj60iy ``` **Note**: If you don't specify password and link requests it, you'll be prompted (stdin) for one. Avoid never-ending downloads: limit the number of tries (for captchas) and wait delays for each link: ```sh $ plowdown --max-retries=4 --timeout=3600 my_big_list_file.txt ``` Retrieve final url (don't use *plowdown* for download): ```sh $ plowdown -q --skip-final --printf %d http://oron.com/dw726z0ohky5 | xargs wget ``` **Note**: This will not work if final url (remote host) requires a cookie. For anonynous users, generated link has limited access in time and you can usually download file only once. ### Plowup Upload a single file anonymously to BayFiles: ```sh $ plowup bayfiles /tmp/foo.bar ``` Upload a bunch of files anonymously to 2Shared (doesn't recurse subdirectories): ```sh $ plowup 2shared /path/myphotos/* ``` **Note**: `*` is a [wildcard character](http://en.wikipedia.org/wiki/Glob_%28programming%29) expanded by Bash interpreter. Upload a file to Rapidshare with an account (premium or free) ```sh $ plowup -a 'myuser:mypassword' rapidshare /path/xxx ``` Upload a file to Mirrorcreator changing remote filename: ```sh $ plowup mirrorcreator /path/myfile.txt:anothername.txt ``` **Note**: `:` is the separator character for local filename and remote filename. Upload a file to MegaShares (anonymously) and set description: ```sh $ plowup -d "Important document" megashares /path/myfile.tex ``` Upload a file to Oron anonymously with a proxy: ```sh $ export http_proxy=http://xxx.xxx.xxx.xxx:80 $ export https_proxy=http://xxx.xxx.xxx.xxx:80 $ plowup oron /path/myfile.txt ``` Abort slow upload (if rate is below limit during 30 seconds): ```sh $ plowup --min-rate 100k mediafire /path/bigfile.zip ``` Modify remote filenames (example: `foobar.rar` gives `foobar-PLOW.rar`): ```sh $ plowup --name='%g-PLOW.%x' mirrorcreator *.rar ``` **Remark**: cURL is not capable of uploading files containing a comma `,` in their filename, but *plowup* will temporarily create a symlink for you. Use cache over sessions to avoid multiple logins: ```sh $ plowup --cache=shared -a 'user:pasword' 1fichier file1.zip $ plowup --cache=shared 1fichier file2.zip ``` On first command line, login stage will be performed and session (token or cookie) will be saved in `~/.config/plowshare/storage/module-name.txt`. On second command line, *plowup* will reuse the data stored to bypass login step. You don't have to specify credentials. **Note**: Only few hosters currently support cache mechanism. Have a look to [Plowshare legacy modules matrix](https://github.com/mcrapet/plowshare-modules-legacy) for more information. Custom results, print upload time, link and filename in HTML format: ```sh $ plowup 1fichier -v0 --printf '
  • %T: %f%n' 5MiB.bin 10MB.bin
  • 11:12:42: 5MiB.bin
  • 11:12:46: 10MB.bin ``` ### Plowdel Delete a file from MegaShares (*delete link* required): ```sh $ plowdel http://d01.megashares.com/?dl=6EUeDtS ``` Delete files (deletes are successive, not parallel): ```sh $ plowdel http://d01.megashares.com/?dl=6EUeDtS http://depositfiles.com/rmv/1643181821669253 ``` Delete a file from Rapidshare (account is required): ```sh $ plowdel -a myuser:mypassword http://rapidshare.com/files/293672730/foo.rar ``` ### Plowlist List links contained in a shared folder link and download them all: ```sh $ plowlist http://www.mediafire.com/?qouncpzfe74s9 > links.txt $ plowdown -m links.txt ``` List two shared folders (first link is processed, then the second one, this is not parallel): ```sh $ plowlist http://www.mediafire.com/?qouncpzfe74s9 http://www.sendspace.com/folder/5njdw7 ``` **Remark**: Some hosters are handling tree folders, you must specify `-R`/`--recursive` command-line switch to *plowlist* for enabing recursive lisiting. List some Sendspace web folder. Render results for vBulletin *BB* syntax: ```sh $ plowlist --printf '[url=%u]%f[/url]%n' http://www.sendspace.com/folder/5njdw7 ``` List links contained in a dummy web page. Render results as HTML list: ```sh $ plowlist --fallback --printf '
  • %u
  • %n' \ http://en.wikipedia.org/wiki/SI_prefix ``` ### Plowprobe Gather public information (filename, file size, file hash, ...) about a link. No captcha solving is requested. Filter alive links in a text file: ```sh $ plowprobe file_with_links.txt > file_with_active_links.txt ``` Custom results as shell format, print links information (filename and size): ```sh $ plowprobe --printf '#%f (%s)%n%u%n' http://myhoster.com/files/5njdw7 #foo-bar.rar (134217728) http://myhoster.com/files/5njdw7 ``` Custom results as [JSON](http://json.org/) format, print links information (filename and size): ```sh $ plowprobe --printf '{"url":"%U","size":%s}%n' http://myhoster.com/files/5njdw7 {"url":"http:\/\/myhoster.com\/files\/5njdw7","size":134217728} ``` Custom results: print *primary* url (if supported by hosters and implemented by module): ```sh $ plowprobe --printf='%v%n' http://a5ts8yt25l.1fichier.com/ https://1fichier.com/?a5ts8yt25l ``` Use `-` argument to read from stdin: ```sh $ plowlist http://pastebin.com/1d82F5sd | plowprobe - > filtered_list.txt ``` ## Configuration file Plowshare looks for `~/.config/plowshare/plowshare.conf` or `/etc/plowshare.conf` files. Options given at command line can be stored in the file. Example: ```ini ### ### Plowshare configuration file ### Line syntax: token = value ### [General] interface = eth1 captchabhood=cbhuser:cbhpass rapidshare/a = matt:4deadbeef mediafire/a = "matt:4 dead beef " freakshare/b=plowshare:xxxxx [Plowdown] timeout=3600 #antigate=49b1b8740e4b51cf51838975de9e1c31 [Plowup] max-retries=2 mirrorcreator/auth-free = foo:bar mirrorcreator/count = 5 [Plowlist] verbose = 3 #[Plowprobe] ``` Notes: - Blank lines are ignored, and whitespace before and after a token or value is ignored, although a value can contain whitespace within. - Lines which begin with a `#` are considered comments and ignored. - Double quoting value is optional. - Valid configuration token names are long-option command-line arguments of Plowshare. Tokens are always lowercase. For modules options, tokens are prepended by module name and a slash character. For example: `rapidshare/auth` is equivalent to `rapidshare/a` (short-option are also possible here). Another example: `freakshare/b` is equivalent to `freakshare/auth-free`. - Options in general section prevail over `PlowXXX` section. Options given on the command line prevail over configuration file options. You can disable usage of Plowshare config file by providing `--no-plowsharerc` command-line switch. You can also specify a custom config file using `--plowsharerc` switch. ## Use your own captcha solver It is possible providing *plowdown* or *plowup* with `--captchaprogram` command-line switch followed by a path to a script or executable. ### Script exit status - `0`: solving success. Captcha Word(s) must be echo'ed (on stdout). - `$ERR_NOMODULE`: external solver is not able to solve requested captcha. Let *plowdown* continue solving it normally (will consider `--captchamethod` if specified). - `$ERR_FATAL`: external solver failed. - `$ERR_CAPTCHA`: external solver failed. Note: this exit code is eligible with retry policy (`-r`/`--max-retries`). ### Examples Understanding example: ```sh #!/bin/bash # $1: module name # $2: path to image # $3: captcha type. For example: "recaptcha", "solvemedia", "digit-4". declare -r ERR_NOMODULE=2 declare -r ERR_CAPTCHA=7 # We only support uploadhero, otherwise tell Plowshare to solve on its own if [ "$1" != 'uploadhero' ]; then exit $ERR_NOMODULE fi # You can print message to stderr echo "Module name: $1" >&2 echo "Image: $2" >&2 # Use stdout to send decoding result echo "5ed1" exit 0 ``` Captcha emailing example: ```sh #!/bin/bash # # Sends an email with image as attachment. # Requires heirloom-mailx and not bsd-mailx. # # Here is my ~/.mailrc: # # account gmail { # set from="My Name " # set smtp-use-starttls # ssl-verify=ignore # set smtp=smtp://smtp.gmail.com:587 # set smtp-auth=login # set smtp-auth-user=xyz@gmail.com # set smtp-auth-password="xxx" # } declare -r ERR_FATAL=1 declare -r MAILTO='xyz@gmail.com' # Image file expected if [ ! -f "$2" ]; then exit $ERR_FATAL fi BODY="Hi! Here is a captcha to solve; it comes from $1." mailx -A gmail -s 'Plowshare sends you an image!' \ -a "$2" "$MAILTO" >/dev/null <<< "$BODY" || { echo 'mailx fatal error, abort' >&2; exit $ERR_FATAL; } echo 'Please check your email account and enter captcha solution here:' >&2 IFS= read -r echo "$REPLY" exit 0 ``` Captcha FTP example: ```sh #!/bin/bash # # Uploads the image to an FTP server in the LAN. If the server is not available # (i.e. my computer is not running) or no CAPTCHA solution is entered for # 15 minutes (i.e. I am occupied), let Plowshare try to handle the CAPTCHA. declare -r MODULE=$1 declare -r FILE=$2 declare -r HINT=$3 declare -r DEST='192.168.1.3' declare -r ERR_NOMODULE=2 # Prepend the used module to the image file name curl --connect-timeout 30 -T "$FILE" --silent "ftp://$DEST/${MODULE}__${FILE##*/}" || \ exit $ERR_NOMODULE echo "Captcha from module '$MODULE' with hint '$HINT'" >&2 read -r -t 900 -p 'Enter code: ' RESPONSE || exit $ERR_NOMODULE echo "$RESPONSE" exit 0 ``` Database using image hash as key: ```sh #!/bin/sh # # Back to February 2009, Megaupload was using 4-character rotation captchas. # For example: # $ sqlite3 captchas.db # sqlite> CREATE TABLE mu (md5sum text unique not null, captcha text not null); # sqlite> INSERT INTO mu VALUES('fd3b2381269d702eccc509b8849e5b0d', 'RHD8'); # sqlite> INSERT INTO mu VALUES('04761dbbe2a45ca6720755bc324dd19c', 'EFC8'); # sqlite> .exit if [ "$1" = megaupload ]; then DB="$HOME/captchas.db" MD5=$(md5sum -b "$1" | cut -c-32) if VAL=$(sqlite3 "$DB" "SELECT captcha FROM mu WHERE md5sum=\"$MD5\""); then echo "$VAL" exit 0 fi fi exit 2 ``` ## Plowdown advanced use ### Hooks It is possible to execute your own script before and after call to module download function. Related command-line switches are `--run-before` and `--run-after`. Possible usage: - (before) Check (with *plowprobe*) if a file has already been downloaded (same filename, same file size/hash) - (before) Inject your own cookie - (after) Unrar archives - (after) Add `--skip-final` command-line switch and do your custom final link download Example 1: Skip all links coming from HotFile hoster ```sh $ cat drophf.sh #!/bin/bash # $1: module name # $2: download URL # $3: cookie (empty) file given to download module function # You can print messages to stderr. stdout will be trashed declare -r ERR_NOMODULE=2 if [ "$1" = 'hotfile' ]; then echo "===[Pre-processing script skipping $2]===" >&2 exit $ERR_NOMODULE fi exit 0 $ plowdown --run-before ./drophf.sh -m list_of_links.txt ``` Example 2: Use `wget` for final download (with possible required cookie file for last download) ```sh $ cat finalwget.sh #!/bin/bash # $1: module name # $2: download URL # $3: cookie file fulfilled by download module function # $4: final download URL # $5: final filename (no path: --output-directory is ignored) # You can print messages to stderr. stdout will be trashed echo "===[Post-processing script for $1]===" >&2 echo "Temporary cookie file: $3" >&2 wget --no-verbose --load-cookies $3 -O $5 $4 $ plowdown --skip-final --run-after ./finalwget.sh \ http://www.mediafire.com/?k10t0egmhi23f ``` Example 3: Use multiple connections for final download (usually only for premium account users) ```sh $ cat finalaria.sh #!/bin/bash aria2c -x2 $4 >/dev/tty $ plowdown -a user:password --skip-final --run-after ./finalaria.sh \ http://depositfiles.com/files/fv2u9xqya ``` ## Miscellaneous ### Additional cURL settings For all network operations, Plowshare is relying on cURL. You can tweak some advanced settings if necessary. For example (enforce IPv6): ```sh $ echo 'ipv6' >>~/.curlrc ``` Use Plowshare with a SOCKS proxy: ```sh $ ssh -f -N -D localhost:3128 user@my.proxy.machine.org $ echo 'socks5=localhost:3128' >>~/.curlrc ``` **Note**: As Plowshare is dealing with verbose, be sure (if present) to have these cURL's options commented: ``` #verbose #silent #show-error ``` ### Known limitations For historical reasons or design choices, there are several known limitations to Plowshare. 1. You cannot enter through command-line several credentials for different hosts. It's because the modules option `-a`, `--auth`, `-b` or `--auth-free` have the same switch name. But you can do it with the configuration file. 2. Same restriction for passwords (also a module option). Only one password can be defined with `-p`, `--link-password` switch name. ### Implement your own modules Plowshare exports a set of API to help text and HTML processing. It is designed to be as simple as possible to develop new modules. A module must be written in shell with portability in mind; one module matches one website. - [New module documentation](https://github.com/mcrapet/plowshare/wiki/Modules) - [API list](https://github.com/mcrapet/plowshare/wiki/API) A common approach is to read existing modules source code. ## License Plowshare is made available publicly under the GNU GPLv3 License. Full license text is available in COPYING file. plowshare-2.1.7/docs/000077500000000000000000000000001314210002400144405ustar00rootroot00000000000000plowshare-2.1.7/docs/plowdel.1000066400000000000000000000220471314210002400161750ustar00rootroot00000000000000.\" Copyright (c) 2010\-2016 Plowshare Team .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 3 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, see .\" . .TH "plowdel" "1" "July 13, 2016" "GPL" "Plowshare for Bash 4" .SH NAME plowdel \- Delete files from file sharing websites links .SH SYNOPSIS .B plowdel [\fIOPTIONS\fP]... [\fIMODULE_OPTIONS\fP]... \fIURL\fP... .SH DESCRIPTION .B plowdel is a command-line tool designed for deleting files on file-sharing websites. It acts like a web browser, retrieving pages and filling HTML forms. Some sites may require authentication (login) for deleting files. See specific module options below. Login process may sometimes require captcha solving. .\" **************************************************************************** .\" * Options * .\" **************************************************************************** .SH OPTIONS .SS Common options .TP .BI -i, " " --interface= IFACE If your machine has several network interfaces, force using \fIIFACE\fR interface. .SS Captcha options .TP .BI " " " " --9kweu= KEY Use 9kw.eu service to solve captchas. .TP .BI " " " " --antigate= KEY Use Antigate.com service to solve captchas. .TP .BI " " " " --captchabhood= USER:PASSWORD Use Captcha Brotherhood service to solve captchas. .TP .BI " " " " --captchacoin= KEY Use CaptchaCoin service to solve captchas. .TP .BI " " " " --deathbycaptcha= USER:PASSWORD Use Death by Captcha service to solve captchas. .TP .BI " " " " --captchamethod= METHOD Force specific captcha solving method (if unspecified it is autodetected). Available values: .RS \fBimgur\fR: upload image to Imgur.com service, print image url in console and prompt for manual entering. Useful for NAS and embedded devices. .RE .RS \fBnone\fR: abort if captcha solving is requested (even if automatic solving service is available). .RE .RS \fBonline\fR: use captcha solving website only (9kweu, Antigate, CaptchaBrotherhood, CaptchaCoin or DeathByCaptcha account required). .RE .RS \fBfb\fR: display image in framebuffer console and prompt for manual entering. Looks for framebuffer viewers: fbi, fim. \fIFRAMEBUFFER\fR environment variable can contain device file. Default is \fI/dev/fb0\fR. .RE .RS \fBnox\fR: display image in console (text) and prompt for manual entering. Looks for ascii viewers: img2txt, aview, tiv. .RE .RS \fBx11\fR: display image in an X11 window and prompt for manual entering. Looks for viewers: display, feh, sxiv, qiv. \fIDISPLAY\fR environment variable must not be empty. .RE .TP .BI " " " " --captchaprogram= PROGRAM Call external program or script for solving captchas. Provided executable can be located in \fIPATH\fR environment variable. Three arguments are given: .RS \fB$1\fR module name (lowercase). For example: \fImediafire\fR. .RE .RS \fB$2\fR image filename (with full path). .RE .RS \fB$3\fR hint or captcha type (string). For example: \fIrecaptcha\fR, \fIsolvemedia\fR or \fIdigits-4\fR. Return value (on stdout) and exit status: .RE .RS \fB0\fR: solving success. Captcha Word(s) must be echo'ed. .RE .RS \fB2\fR: external solver is not able to solve requested captcha. Let plowdel continue solving it normally (will consider \fB--captchamethod\fR if specified). .RE .RS \fB7\fR: external solver failed. Note: plowdel legacy exit errors can also be returned, for example: \fB1\fR (fatal) or \fB3\fR (network). .RE .SS Logging options .TP .BI -v, " " --verbose= LEVEL Set output verbosity level: .RS \fB0\fR none, .RE .RS \fB1\fR errors, .RE .RS \fB2\fR notice (default behavior), .RE .RS \fB3\fR debug, .RE .RS \fB4\fR report (very noisy, log HTML pages). .RE .TP .B -q, --quiet Alias for \fB-v0\fR. Do not print any debug messages. .SS Miscellaneous options .TP .B " " --no-color Disables log messages (stderr only) output coloring. .TP .B " " --no-curlrc Do not use curl config file (~/.curlrc). .TP .BI " " " " --curlrc= FILE Force using an alternate curl configuration file. Replaces ~/.curlrc if it exists. This option has no effect when .B --no\-curlrc is defined. .TP .B " " --no-plowsharerc Do not consider any configuration file. .TP .BI " " " " --plowsharerc= FILE Force using an alternate configuration file (instead of per-user or systemwide plowshare.conf). This option has no effect when .B --no\-plowsharerc is defined. .TP .B " " --modules Display all supported module names (one per line) and exit. Useful for wrappers. .SS Generic program information .TP .B -h, --help Display main help and exit. .TP .B -H, --longhelp Display complete help (with module options) and exit. .TP .B " " --version Output version information and exit. .\" **************************************************************************** .\" * Modules options * .\" **************************************************************************** .SH "MODULE OPTIONS" .SS Common options .TP .BI -a, " " --auth= "USER:PASSWORD" Use premium account. Free account can be used sometimes. .P All switches are not implemented nor required for all modules. See help message for detailed modules option list. .\" **************************************************************************** .\" * Files * .\" **************************************************************************** .SH "FILES" .TP .I ~/.config/plowshare/plowshare.conf This is the per-user configuration file. .TP .I /etc/plowshare.conf Systemwide configuration file. .PP The file format is described in .BR plowshare.conf (5). .TP .I ~/.config/plowshare/exec/ Additional directory considered when searching for executable. See \fB--captchaprogram\fR switch. .TP .I ~/.config/plowshare/modules.d/ User directory considered when searching for modules at startup (plowdel will try to open \fB~/.config/plowshare/modules.d/*/config\fR). One file per module (hoster). .\" **************************************************************************** .\" * Environment Variables * .\" **************************************************************************** .SH "ENVIRONMENT VARIABLES" The following environment variables may affect plowdel: .TP .I DISPLAY The X11 display server address is considered to display captchas. See \fB--captchamethod=x11\fR documentation below. .TP .I FRAMEBUFFER This variable is considered to display captchas. See \fB--captchamethod=fb\fR documentation below. .TP .I HOME Search for user configuration directory in \fB~/.config/plowshare\fR (see FILES section above). If found, \fB~/.curlrc\fR will be used (use \fB--no-curlrc\fR to disable it). .TP .I PLOWSHARE_CURL Specifies an alternate curl command (\fB$PATH\fR search is considered). If not defined, \fBcurl\fR is used. .TP .I XDG_CONFIG_HOME The directory to store user configuration files. If not defined, \fB~/.config\fR is assumed. .\" **************************************************************************** .\" * Exit codes * .\" **************************************************************************** .SH "EXIT CODES" Possible exit codes are: .IP 0 Success. File was successfully deleted. .IP 1 Fatal error. Upstream site updated or unexpected result. .IP 2 No available module (provided URL is not supported). .IP 3 Network error. Mostly curl related. .IP 4 Authentication failed (bad login/password). .IP 11 Link requires an admin or removal code. .IP 12 Authentication required (anonymous users can't delete files). .IP 13 Link is dead. File has been previously deleted. .IP 15 Unknown command line parameter or incompatible options. .PP If .B plowdel is invoked with multiple links and one or several errors occur, the first error code is returned added with 100. .\" **************************************************************************** .\" * Authors / See Also * .\" **************************************************************************** .SH AUTHORS Plowshare was initially written by Arnau Sanchez. See the AUTHORS file for a list of some of the many other contributors. Plowshare is (C) 2010-2016 The Plowshare Team .SH "SEE ALSO" .BR plowdown (1), .BR plowup (1), .BR plowlist (1), .BR plowprobe (1), .BR plowshare.conf (5), .BR plowmod (1). plowshare-2.1.7/docs/plowdown.1000066400000000000000000000400141314210002400163720ustar00rootroot00000000000000.\" Copyright (c) 2010\-2017 Plowshare Team .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 3 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, see .\" . .TH "plowdown" "1" "April 2, 2017" "GPL" "Plowshare for Bash 4" .SH NAME plowdown \- Simple download manager for file sharing websites .SH SYNOPSIS .B plowdown [\fIOPTIONS\fP]... [\fIMODULE_OPTIONS\fP]... \fIURL\fP|\fIFILE\fP... .SH DESCRIPTION .B plowdown is a command-line tool designed for automatic download on file-sharing websites. It acts like a web browser, retrieving pages and filling HTML forms (including captchas). .\" **************************************************************************** .\" * Options * .\" **************************************************************************** .SH OPTIONS .SS Common options .TP .BI -i, " " --interface= IFACE If your machine has several network interfaces, force using \fIIFACE\fR interface. .TP .B -m, --mark-downloaded Mark downloaded links in (regular) file arguments. .TP .BI -o, " " --output-directory= DIRECTORY Directory where files will be saved. Default is current directory. .TP .BI -r, " " --max-retries= N Set maximum retries for download failures. Apply on module exit status: \fB3\fR (network error), \fB7\fR (captcha error). Default option value is 2 (i.e. 3 tries) and applies for one single URL download. .TP .BI -t, " " --timeout= SECS Cancel download after \fISECS\fR seconds of waits. Apply on module exit status: \fB10\fR (temporary unavailable error). \ This error can be returned in various cases: unallowed parallel download, daily downloads limit reached, remote hoster overloaded. \ Default option value is disabled (no timeout, infinite) and applies for one single URL download. .TP .B -x, --no-overwrite Do not overwrite existing files. Existing file will be preserved and filename will be suffixed with .1, .2, and so on. \ Default option value is disabled: files are overwritten (whatever their size) or resumed (if module supports it). .TP .BI " " " " --cache= METHOD Cache policy regarding module storage space. \ Each module is able to save data (credentials, authentication session, or tokens) in order to be reused later. Available values: .RS \fBnone\fR: module storage file is deleted before each URL processing. Temporary directory is used. .RE .RS \fBsession\fR (default): module storage file is deleted at the end of plowdown execution. Temporary directory is used. .RE .RS \fBshared\fR: module storage file is global and located (in \fI~/.config/plowshare/storage/\fR). It can be accessed by any other instance of plow* scripts. Warning: There is no atomicity (or file locking) on concurrent access. Example: Multiple links download using a premium account. If supported by module, login stage could be performed once. .RE .SS Captcha options .TP .BI " " " " --9kweu= KEY Use 9kw.eu service to solve captchas. .TP .BI " " " " --antigate= KEY Use Antigate.com service to solve captchas. .TP .BI " " " " --captchabhood= USER:PASSWORD Use Captcha Brotherhood service to solve captchas. .TP .BI " " " " --captchacoin= KEY Use CaptchaCoin service to solve captchas. .TP .BI " " " " --deathbycaptcha= USER:PASSWORD Use Death by Captcha service to solve captchas. .TP .BI " " " " --captchamethod= METHOD Force specific captcha solving method (if unspecified it is autodetected). Available values: .RS \fBimgur\fR: upload image to Imgur.com service, print image url in console and prompt for manual entering. Useful for NAS and embedded devices. .RE .RS \fBnone\fR: abort if captcha solving is requested (even if automatic solving service is available). .RE .RS \fBonline\fR: use captcha solving website only (9kweu, Antigate, CaptchaBrotherhood, CaptchaCoin or DeathByCaptcha account required). .RE .RS \fBfb\fR: display image in framebuffer console and prompt for manual entering. Looks for framebuffer viewers: fbi, fim. \fIFRAMEBUFFER\fR environment variable can contain device file. Default is \fI/dev/fb0\fR. .RE .RS \fBnox\fR: display image in console (text) and prompt for manual entering. Looks for ascii viewers: img2txt, aview, tiv. .RE .RS \fBx11\fR: display image in an X11 window and prompt for manual entering. Looks for viewers: display, feh, sxiv, qiv. \fIDISPLAY\fR environment variable must not be empty. .RE .TP .BI " " " " --captchaprogram= PROGRAM Call external program or script for solving captchas. Provided executable can be located in \fIPATH\fR environment variable. Three arguments are given: .RS \fB$1\fR module name (lowercase). For example: \fImediafire\fR. .RE .RS \fB$2\fR image filename (with full path). .RE .RS \fB$3\fR hint or captcha type (string). For example: \fIrecaptcha\fR, \fIsolvemedia\fR or \fIdigits-4\fR. Return value (on stdout) and exit status: .RE .RS \fB0\fR: solving success. Captcha Word(s) must be echo'ed. .RE .RS \fB2\fR: external solver is not able to solve requested captcha. Let plowdown continue solving it normally (will consider \fB--captchamethod\fR if specified). .RE .RS \fB7\fR: external solver failed. Note: this exit code is eligible with retry policy (\fB-r\fR/\fB--max-retries\fR). Note: plowdown legacy exit errors can also be returned, for example: \fB1\fR (fatal) or \fB3\fR (network). .RE .SS Tuning settings .TP .BI " " " " --min-space= LIMIT Define threshold amount of available disk space before quitting plowdown. You must specify a suffix. Suffixes are: .RS \fBM\fR for megabytes (MB i.e. 1000^2), .RE .RS \fBG\fR for gigabytes (GB i.e. 1000^3), .RE .RS \fBMi\fR or \fBm\fR for mebibytes (MiB i.e. 1024^2), .RE .RS \fBGi\fR for gibibytes (GiB i.e. 1024^3). .RE .TP .BI " " " " --max-rate= SPEED Limit download speed in bytes per second. Suffixes are: .RS \fBk\fR for kilobytes (kB i.e. 1000), .RE .RS \fBM\fR for megabytes (MB i.e. 1000^2), .RE .RS \fBK\fR or \fBKi\fR for kibibytes (KB or KiB i.e. 1024), .RE .RS \fBm\fR or \fBMi\fR for mebibytes (mB or MiB i.e. 1024^2). .RE .TP .BI " " " " --min-rate= SPEED Limit download minimum speed in bytes per second (for a delay of 30 seconds). Suffixes are the same than \fB--max-rate\fR. .TP .BI " " " " --temp-directory= DIRECTORY Directory for temporary files: final link download, cookies, images, ... .TP .B " " --temp-rename Append .part suffix to filename while file is being downloaded. Download resume will not work with this option. .TP .B " " --skip-final Don't process final link (returned by module download function), just skip it. This is applied for each input URL. If you are using this option, you should need .B --run-after or .B --printf too. Note: Depending hosters, final (generated) link may have restrictions: validity timeout (few hours), access limitation (usually one unique HTTP GET request for anonymous users), same IP address, etc. .TP .BI " " " " --run-before= PROGRAM Call external program or script before new link processing (before calling module download function). Provided executable can be located in \fIPATH\fR environment variable. Messages can be sent to stderr, stdout is trashed. Three arguments are given: .RS \fB$1\fR module name (lowercase). For example: \fImediafire\fR. .RE .RS \fB$2\fR download URL. .RE .RS \fB$3\fR cookie (empty) file given to download module function. Exit status: .RE .RS \fB0\fR: script success. plowdown continue normally. .RE .RS \fB2\fR: script explicitly requests skipping current link. Note: Any other script exit status like \fB1\fR (fatal) or \fB3\fR (network) will be ignored (an error message will be reported). .RE .TP .BI " " " " --run-after= PROGRAM Call external program or script after final link successful download. Provided executable can be located in \fIPATH\fR environment variable. Messages can be sent to stderr, stdout is trashed. Five arguments are given: .RS \fB$1\fR module name (lowercase). For example: \fImediafire\fR. .RE .RS \fB$2\fR download URL. .RE .RS \fB$3\fR cookie file fulfilled by download module function. .RE .RS \fB$4\fR final URL. .RE .RS \fB$5\fR final filename. Exit status: .RE .RS \fB0\fR: script success. plowdown continue normally. Note: Any other (non zero) exit status will be ignored (an error message will be reported). .RE .TP .BI " " " " --printf= FORMAT Print results (on stdout) in a given format (for each successful download). Default format string is \fI"%F%n"\fR. Interpreted sequences are: .RS .TP \fI%%\fR raw % character .TP \fI%c\fR final cookie filename (with output directory if specified). Name template is \fBplowdown-cookies-NNNN.txt\fR. .TP \fI%C\fR \fB%c\fR or empty string if module does not require it .TP \fI%d\fR download (final) url .TP \fI%D\fR same as \fB%d\fR but url is escaped for JSON usage .TP \fI%f\fR destination (local) filename .TP \fI%F\fR destination (local) filename (with output directory if specified) .TP \fI%m\fR module name .TP \fI%n\fR newline .TP \fI%s\fR destination (local) file size (positive integer in bytes). Important: Empty string is returned when \fB--skip\-final\fR switch is specified. .TP \fI%t\fR tabulation character .TP \fI%u\fR download (source) url .TP \fI%U\fR same as \fB%u\fR but url is escaped for JSON usage .RE .SS Logging options .TP .BI -v, " " --verbose= LEVEL Set output verbosity level: .RS \fB0\fR none, .RE .RS \fB1\fR errors, .RE .RS \fB2\fR notice (default behavior), .RE .RS \fB3\fR debug, .RE .RS \fB4\fR report (very noisy, log HTML pages). .RE .TP .B -q, --quiet Alias for \fB-v0\fR. Do not print any debug messages. .SS Miscellaneous options .TP .B " " --no-color Disables log messages (stderr only) output coloring. .TP .B " " --fallback If no module is found for link, simply download it (HTTP GET). .TP .B " " --no-curlrc Do not use curl config file (~/.curlrc). .TP .BI " " " " --curlrc= FILE Force using an alternate curl configuration file. Replaces ~/.curlrc if it exists. This option has no effect when .B --no\-curlrc is defined. .TP .B " " --no-plowsharerc Do not consider any configuration file. .TP .BI " " " " --plowsharerc= FILE Force using an alternate configuration file (instead of per-user or systemwide plowshare.conf). This option has no effect when .B --no\-plowsharerc is defined. .TP .B " " --modules Display all supported module names (one per line) and exit. Useful for wrappers. .SS Generic program information .TP .B -h, --help Display main help and exit. .TP .B -H, --longhelp Display complete help (with module options) and exit. .TP .B " " --version Output version information and exit. .\" **************************************************************************** .\" * Modules options * .\" **************************************************************************** .SH "MODULE OPTIONS" .SS Common options .TP .BI -a, " " --auth= USER:PASSWORD Use premium account. .TP .BI -b, " " --auth-free= USER:PASSWORD Use free account. .TP .BI -p, " " --link-password= PASSWORD Used for password-protected files. .P All switches are not implemented nor required for all modules. See long help message for detailed modules option list. .\" **************************************************************************** .\" * Notes * .\" **************************************************************************** .SH NOTES .SS Command line authentication string format Complete login must have .I USER:PASSWORD format. The first semi-colon character is the separator. So, .I PASSWORD can contain a semi-colon character without any trouble. .TP Don't forget to single-quote string if your password contain shell expandable characters (like space, $ or &). .\" **************************************************************************** .\" * Files * .\" **************************************************************************** .SH "FILES" .TP .I /etc/plowshare.conf Systemwide configuration file. .TP .I ~/.config/plowshare/plowshare.conf This is the per-user configuration file. .PP The file format is described in .BR plowshare.conf (5). .TP .I ~/.config/plowshare/exec/ Additional directory considered when searching for executable. \ See \fB--captchaprogram\fR, \fB--run-before\fR and \fB--run-after\fR switches. .TP .I ~/.config/plowshare/modules.d/ User directory considered when searching for modules at startup (plowdown will try to open \fB~/.config/plowshare/modules.d/*/config\fR). One file per module (hoster). .TP .I ~/.config/plowshare/storage/ Directory used for storing data (one file per module) among sessions. See \fB--cache=shared\fR switch. .\" **************************************************************************** .\" * Environment Variables * .\" **************************************************************************** .SH "ENVIRONMENT VARIABLES" The following environment variables may affect plowdown: .TP .I DISPLAY The X11 display server address is considered to display captchas. See \fB--captchamethod=x11\fR documentation below. .TP .I FRAMEBUFFER This variable is considered to display captchas. See \fB--captchamethod=fb\fR documentation below. .TP .I HOME Search for user configuration directory in \fB~/.config/plowshare\fR (see FILES section above). If found, \fB~/.curlrc\fR will be used (use \fB--no-curlrc\fR to disable it). .TP .I PLOWSHARE_CURL Specifies an alternate curl command (\fB$PATH\fR search is considered). If not defined, \fBcurl\fR is used. .TP .I PLOWSHARE_JS Specifies an alternate js command (\fB$PATH\fR search is considered). If not defined, \fBjs\fR is used. .TP .I XDG_CONFIG_HOME The directory to store user configuration files. If not defined, \fB~/.config\fR is assumed. .\" **************************************************************************** .\" * Exit codes * .\" **************************************************************************** .SH "EXIT CODES" Possible exit codes are: .IP 0 Success. .IP 1 Fatal error. Upstream site updated or unexpected result. .IP 2 No available module (provided URL is not supported). .IP 3 Network error. Mostly curl related. .IP 4 Authentication failed (bad login/password). .IP 5 Timeout reached (refer to \fB-t\fR/\fB--timeout\fR command-line option). .IP 6 Maximum tries reached (refer to \fB-r\fR/\fB--max-retries\fR command-line option). .IP 7 Captcha generic error. .IP 8 System generic error. .IP 10 Link alive but temporarily unavailable. .IP 11 Link alive but requires a password. .IP 12 Link alive but requires some authentication (private or premium link). .IP 13 Link is dead. .IP 14 Can't download link because file is too big (need permissions). .IP 15 Unknown command line parameter or incompatible options. .PP If .B plowdown is invoked with multiple links or link-list files and one or several errors occur, the first error code is returned added with 100. .\" **************************************************************************** .\" * Authors / See Also * .\" **************************************************************************** .SH AUTHORS Plowshare was initially written by Arnau Sanchez. See the AUTHORS file for a list of some of the many other contributors. Plowshare is (C) 2010-2017 The Plowshare Team .SH "SEE ALSO" .BR plowup (1), .BR plowdel (1), .BR plowlist (1), .BR plowprobe (1), .BR plowshare.conf (5), .BR plowmod (1). plowshare-2.1.7/docs/plowlist.1000066400000000000000000000167371314210002400164150ustar00rootroot00000000000000.\" Copyright (c) 2010\-2016 Plowshare Team .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 3 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, see .\" . .TH "plowlist" "1" "July 13, 2016" "GPL" "Plowshare for Bash 4" .SH NAME plowlist \- List links from shared folders websites .SH SYNOPSIS .B plowlist [\fIOPTIONS\fP]... [\fIMODULE_OPTIONS\fP]... \fIURL\fP... .SH DESCRIPTION .B plowlist is a command-line tool designed for listing links (files) on file-sharing websites. Provided links can be downloaded with plowdown(1). .\" **************************************************************************** .\" * Options * .\" **************************************************************************** .SH OPTIONS .SS Common options .TP .BI -i, " " --interface= IFACE If your machine has several network interfaces, force using \fIIFACE\fR interface. .TP .B -R, --recursive Recurse into sub folders. .TP .BI -t, " " --timeout= SECS This is useful for mirroring/multi-upload services. \ Remote links may not be available or partially, in this case, module exit status is \fB10\fR (temporary unavailable error). \ plowlist will wait exponentially until \fISECS\fR (seconds) is reached. \ When unspecified, this option is zero (no wait, same legacy behavior) and applies for one single URL listing. Note: Don't give a too big value here (I'll advise few minutes), some hosters may be stuck in some "queued for upload" state. .TP .BI " " " " --printf= FORMAT Print results (on stdout) in a given format (for each non-dead link). Default format string is \fI"%F%u%n"\fR. Interpreted sequences are: .RS .TP \fI%%\fR raw % character .TP \fI%f\fR filename (can be empty string if module list function does not report any name) .TP \fI%F\fR empty if \fB%f\fR is empty, or alias to "\fB# %f%n\fR". .TP \fI%m\fR module name .TP \fI%n\fR newline .TP \fI%t\fR tabulation character .TP \fI%u\fR download url .TP \fI%U\fR same as \fB%u\fR but url is escaped for JSON usage .SS Logging options .TP .BI -v, " " --verbose= LEVEL Set output verbosity level: .RS \fB0\fR none, .RE .RS \fB1\fR errors, .RE .RS \fB2\fR notice (default behavior), .RE .RS \fB3\fR debug, .RE .RS \fB4\fR report (very noisy, log HTML pages). .RE .TP .B -q, --quiet Alias for \fB-v0\fR. Do not print any debug messages. .SS Miscellaneous options .TP .B " " --no-color Disables log messages (stderr only) output coloring. .TP .B " " --fallback If no module is found for link, get page (HTTP GET) and simply grep all URLs contained inside. .TP .B " " --no-curlrc Do not use curl config file (~/.curlrc). .TP .BI " " " " --curlrc= FILE Force using an alternate curl configuration file. Replaces ~/.curlrc if it exists. This option has no effect when .B --no\-curlrc is defined. .TP .B " " --no-plowsharerc Do not consider any configuration file. .TP .BI " " " " --plowsharerc= FILE Force using an alternate configuration file (instead of per-user or systemwide plowshare.conf). This option has no effect when .B --no\-plowsharerc is defined. .TP .B " " --modules Display all supported module names (one per line) and exit. Useful for wrappers. .SS Generic program information .TP .B -h, --help Display main help and exit. .TP .B -H, --longhelp Display complete help (with module options) and exit. .TP .B " " --version Output version information and exit. .\" **************************************************************************** .\" * Modules options * .\" **************************************************************************** .SH "MODULE OPTIONS" .SS Common options .TP .BI -p, " " --link-password= PASSWORD Used for password-protected folders. .P All switches are not implemented nor required for all modules. See help message for detailed modules option list. .\" **************************************************************************** .\" * Files * .\" **************************************************************************** .SH "FILES" .TP .I ~/.config/plowshare/plowshare.conf This is the per-user configuration file. .TP .I /etc/plowshare.conf Systemwide configuration file. .PP The file format is described in .BR plowshare.conf (5). .TP .I ~/.config/plowshare/modules.d/ User directory considered when searching for modules at startup (plowlist will try to open \fB~/.config/plowshare/modules.d/*/config\fR). One file per module (hoster). .\" **************************************************************************** .\" * Environment Variables * .\" **************************************************************************** .SH "ENVIRONMENT VARIABLES" The following environment variables may affect plowlist: .TP .I HOME Search for user configuration directory in \fB~/.config/plowshare\fR (see FILES section above). If found, \fB~/.curlrc\fR will be used (use \fB--no-curlrc\fR to disable it). .TP .I PLOWSHARE_CURL Specifies an alternate curl command (\fB$PATH\fR search is considered). If not defined, \fBcurl\fR is used. .TP .I XDG_CONFIG_HOME The directory to store user configuration files. If not defined, \fB~/.config\fR is assumed. .\" **************************************************************************** .\" * Exit codes * .\" **************************************************************************** .SH "EXIT CODES" Possible exit codes are: .IP 0 Success. Folder contain one or several files. .IP 1 Fatal error. Upstream site updated or unexpected result. .IP 2 No available module (provided URL is not supported). .IP 3 Network error. Mostly curl related. .IP 5 Timeout reached (refer to \fB-t\fR/\fB--timeout\fR command-line option). .IP 10 Links are temporarily unavailable. This is used by mirroring/multi-upload services, maybe uploads are still being processed. .IP 11 Folder is password protected. .IP 13 Folder has been deleted or does not exist or is empty. .IP 15 Unknown command line parameter or incompatible options. .PP If .B plowlist is invoked with multiple links and one or several errors occur, the first error code is returned added with 100. .\" **************************************************************************** .\" * Authors / See Also * .\" **************************************************************************** .SH AUTHORS Plowshare was initially written by Arnau Sanchez. See the AUTHORS file for a list of some of the many other contributors. Plowshare is (C) 2010-2016 The Plowshare Team .SH "SEE ALSO" .BR plowdown (1), .BR plowup (1), .BR plowdel (1), .BR plowprobe (1), .BR plowshare.conf (5), .BR plowmod (1). plowshare-2.1.7/docs/plowmod.1000066400000000000000000000134501314210002400162060ustar00rootroot00000000000000.\" Copyright (c) 2016 Plowshare Team .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 3 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, see .\" . .TH "plowmod" "1" "July 13, 2016" "GPL" "Plowshare for Bash 4" .SH NAME plowmod \- Simple plowshare modules management tool .SH SYNOPSIS .B plowmod \fIACTION\fP [\fIOPTIONS\fP]... [\fIURL\fP]... .br .B plowmod --install [\fIURL\fP]... .br .B plowmod --update .br .B plowmod --status .SH DESCRIPTION .B plowmod is a command-line tool designed to ease plowshare modules installation and update. The script is standalone and not dependent of other plow* tools. At startup, plowdown, plowup, plowprobe, plowlist or plowdel search for \fI~/.config/plowshare/modules.d/*/config\fR files and build an available module list. Remote repository sources (URLs) can be only git repositories for now. .\" **************************************************************************** .\" * Options * .\" **************************************************************************** .SH OPTIONS .SS Action options .TP .B -i, --install Install from scratch from one or several URLs to plowshare modules directory (see \fB--modules-directory\fR switch below). \ For now, this is a simple \fBgit clone\fR. \ From repository URL, a sub-directory name is figured out (some kind of basename) and will be created in plowshare modules directory. .TP .B -s, --status Print some useful information about modules directories found and possible conflicts (when using \fB-v3\fR switch). .TP .B -u, --update Browse plowshare modules directory (each sub-directory) and try to update sources. For now, this is a simple \fBgit pull\fR. .SS Logging options .TP .BI -v, " " --verbose= LEVEL Set output verbosity level: .RS \fB0\fR none, .RE .RS \fB1\fR errors, .RE .RS \fB2\fR notice (default behavior), .RE .RS \fB3\fR debug, .RE .RS \fB4\fR report (very noisy, not very useful here). .RE .TP .B -q, --quiet Alias for \fB-v0\fR. Do not print any debug messages. .SS Miscellaneous options .TP .B " " --no-color Disables log messages (stderr only) output coloring. .TP .BI " " " " --modules-directory= DIR Set plowshare modules directory. Default is \fI~/.config/plowshare/modules.d/\fR. \ You should not modify this unless you are a package maintainer or want to embed plowshare into PHP. .SS Generic program information .TP .B -h, --help Display main help and exit. .TP .B " " --version Output version information and exit. .\" **************************************************************************** .\" * Files * .\" **************************************************************************** .SH "FILES" .TP .I ~/.config/plowshare/modules.d/ User plowshare modules directory for installation or update of repository sources. This location prevails over ones listed below. .TP .I /usr/share/plowshare/modules/ .B (replace /usr with your installation prefix) Since plowshare is not delivered with modules anymore, this is unused. \ This is still supported for compatibility purpose but you are discouraged using it. .TP .I ~/.config/plowshare/modules/ Obsolete user modules directory. Prefer using \fB~/.config/plowshare/modules.d/xxx/\fR instead. .\" **************************************************************************** .\" * Environment Variables * .\" **************************************************************************** .SH "ENVIRONMENT VARIABLES" The following environment variables may affect plowmod: .TP .I HOME Search for user configuration directory in \fB~/.config/plowshare\fR (see FILES section above). .TP .I PLOWSHARE_CURL Specifies an alternate curl command (\fB$PATH\fR search is considered). If not defined, \fBcurl\fR is used. .TP .I XDG_CONFIG_HOME The directory to store user configuration files. If not defined, \fB~/.config\fR is assumed. .\" **************************************************************************** .\" * Exit codes * .\" **************************************************************************** .SH "EXIT CODES" Possible exit codes are: .IP 0 Operation success. .IP 1 Fatal error. Unexpected result. .IP 8 System generic error. .IP 15 Unknown command line parameter or incompatible options. .PP If .B plowmod is invoked with multiple URLs (command-line arguments), and one or several errors occur, the first error code is returned added with 100. .\" **************************************************************************** .\" * Authors / See Also * .\" **************************************************************************** .SH AUTHORS Plowshare was initially written by Arnau Sanchez. See the AUTHORS file for a list of some of the many other contributors. Plowshare is (C) 2010-2016 The Plowshare Team .SH "SEE ALSO" .BR plowdown (1), .BR plowup (1), .BR plowdel (1), .BR plowlist (1), .BR plowprobe (1), .BR plowshare.conf (5). plowshare-2.1.7/docs/plowprobe.1000066400000000000000000000172721314210002400165440ustar00rootroot00000000000000.\" Copyright (c) 2013-2016 Plowshare Team .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 3 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, see .\" . .TH "plowprobe" "1" "July 13, 2016" "GPL" "Plowshare for Bash 4" .SH NAME plowprobe \- Gather information from file sharing download links .SH SYNOPSIS .B plowprobe [\fIOPTIONS\fP]... [\fIMODULE_OPTIONS\fP]... \fIURL\fP|\fIFILE\fP... .SH DESCRIPTION .B plowprobe is a command-line tool designed for retrieving metadata from file-sharing download links. Information are printed on stdout (only alive links). Provided links can also be downloaded with plowdown(1). .\" **************************************************************************** .\" * Options * .\" **************************************************************************** .SH OPTIONS .SS Common options .TP .BI -i, " " --interface= IFACE If your machine has several network interfaces, force using \fIIFACE\fR interface. .TP .BI " " " " --printf= FORMAT Print results (on stdout) in a given format (for each non-dead link). Default format string is \fI"%F%u%n"\fR. Interpreted sequences are: .RS .TP \fI%%\fR raw % character .TP \fI%c\fR probe function return status (0 for success, 13 for dead link, see list below) .TP \fI%f\fR filename (can be empty string) .TP \fI%F\fR empty if \fB%f\fR is empty, or alias to "\fB# %f%n\fR". .TP \fI%h\fR filehash (can be empty string if not available). Usually MD5 or SHA1. If hoster supports several algorithms, the longest digest is used. .TP \fI%i\fR file identifier (can be empty string if not available). Usually included in input URL. .TP \fI%m\fR module name .TP \fI%n\fR newline .TP \fI%s\fR filesize (positive integer) in bytes (can be empty string if not available). Note: It's often approximative. .TP \fI%t\fR tabulation character .TP \fI%T\fR file timestamp (can be empty string if not available). Unix epoch time is preferred. .TP \fI%u\fR download (source) url .TP \fI%U\fR same as \fB%u\fR but url is escaped for JSON usage .TP \fI%v\fR alternate or refactored download url. This can be for example fixing primary hostname (to avoid HTTP 301 redirection), or force HTTPS protocol. \ If not available, alias to \fB%u\fR. .TP \fI%V\fR same as \fB%v\fR but url is escaped for JSON usage .P Note: Metadata are often not fully available from hosters nor implemented by all modules. .SS Logging options .TP .BI -v, " " --verbose= LEVEL Set output verbosity level: .RS \fB0\fR none, .RE .RS \fB1\fR errors, .RE .RS \fB2\fR notice (default behavior), .RE .RS \fB3\fR debug, .RE .RS \fB4\fR report (very noisy, log HTML pages). .RE .TP .B -q, --quiet Alias for \fB-v0\fR. Do not print any debug messages. .SS Miscellaneous options .TP .B " " --no-color Disables log messages (stderr only) output coloring. .TP .B " " --follow If no module is found for link, follow HTTP redirects (curl \-L). Default is disabled. .TP .B " " --get-module Echo module name for each URL and exit. Faster than \fB--printf=%m\fR. Useful for wrappers. .TP .B " " --no-curlrc Do not use curl config file (~/.curlrc). .TP .BI " " " " --curlrc= FILE Force using an alternate curl configuration file. Replaces ~/.curlrc if it exists. This option has no effect when .B --no\-curlrc is defined. .TP .B " " --no-plowsharerc Do not consider any configuration file. .TP .BI " " " " --plowsharerc= FILE Force using an alternate configuration file (instead of per-user or systemwide plowshare.conf). This option has no effect when .B --no\-plowsharerc is defined. .TP .B " " --modules Display all supported module names (one per line) and exit. Useful for wrappers. .SS Generic program information .TP .B -h, --help Display this help and exit. .TP .B -H, --longhelp Display complete help (with module options) and exit. .TP .B " " --version Output version information and exit. .\" **************************************************************************** .\" * Modules options * .\" **************************************************************************** .SH "MODULE OPTIONS" .P There is none yet! .\" **************************************************************************** .\" * Files * .\" **************************************************************************** .SH "FILES" .TP .I ~/.config/plowshare/plowshare.conf This is the per-user configuration file. .TP .I /etc/plowshare.conf Systemwide configuration file. .PP The file format is described in .BR plowshare.conf (5). .TP .I ~/.config/plowshare/modules.d/ User directory considered when searching for modules at startup (plowprobe will try to open \fB~/.config/plowshare/modules.d/*/config\fR). One file per module (hoster). .\" **************************************************************************** .\" * Environment Variables * .\" **************************************************************************** .SH "ENVIRONMENT VARIABLES" The following environment variables may affect plowprobe: .TP .I HOME Search for user configuration directory in \fB~/.config/plowshare\fR (see FILES section above). If found, \fB~/.curlrc\fR will be used (use \fB--no-curlrc\fR to disable it). .TP .I PLOWSHARE_CURL Specifies an alternate curl command (\fB$PATH\fR search is considered). If not defined, \fBcurl\fR is used. .TP .I XDG_CONFIG_HOME The directory to store user configuration files. If not defined, \fB~/.config\fR is assumed. .\" **************************************************************************** .\" * Exit codes * .\" **************************************************************************** .SH "EXIT CODES" Possible exit codes are: .IP 0 Success. Folder contain one or several files. .IP 1 Fatal error. Upstream site updated or unexpected result. .IP 2 No available module (provided URL is not supported). .IP 3 Network error. Mostly curl related. .IP 8 System generic error. .IP 10 Link alive but temporarily unavailable. .IP 11 Link alive but requires a password. .IP 12 Link alive but requires some authentication (private or premium link). .IP 13 Link is dead. .IP 15 Unknown command line parameter or incompatible options. .PP If .B plowprobe is invoked with multiple links and one or several errors occur, the first error code is returned added with 100. .\" **************************************************************************** .\" * Authors / See Also * .\" **************************************************************************** .SH AUTHORS Plowshare was initially written by Arnau Sanchez. See the AUTHORS file for a list of some of the many other contributors. Plowshare is (C) 2010-2016 The Plowshare Team .SH "SEE ALSO" .BR plowdown (1), .BR plowup (1), .BR plowdel (1), .BR plowlist (1), .BR plowshare.conf (5), .BR plowmod (1). plowshare-2.1.7/docs/plowshare.conf.5000066400000000000000000000106431314210002400174620ustar00rootroot00000000000000.\" Copyright (c) 2010\-2016 Plowshare Team .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 3 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, see .\" . .\" .\" Based on: .\" - xorg.conf.5 .\" - sysctl.conf.5 .TH "plowshare.conf" "5" "March 24, 2016" "GPL" "Plowshare for Bash 4" .SH NAME plowshare.conf \- Configuration file for Plowshare .SH DESCRIPTION .B Plowshare (plowdown, plowup, plowdel, plowlist or plowprobe) uses a configuration file called .I plowshare.conf for its initial setup. This configuration file is searched for in the following places when plowshare is started: .PP .RS 4 .nf .I ~/.config/plowshare/plowshare.conf .I /etc/plowshare.conf .fi .RE .PP Instead of specifying long command lines with user's preferences (credentials, network settings or download retry number, ...), it is convenient to make them default. .PP Note: Usage of configuration file can be disabled using .B \-\-no-plowsharerc command-line option. There is also .BI --plowsharerc= FILE option to specify an alternate configuration file. .SH FILE FORMAT .I plowshare.conf file uses an INI-style format. It is composed of six sections which may be present in any order. Each section may contain lines of the form: .PP .RS 4 .nf .B [General] .RI " " token " " = " " value ... .B [Plowdown] .RI " " token " " = " " value ... .B [Plowup] .RI " " token " " = " " value ... .B [Plowdel] .RI " " token " " = " " value ... .B [Plowlist] .RI " " token " " = " " value ... .B [Plowprobe] .RI " " token " " = " " value ... .B # this is a comment .fi .RE .PP Notes: .IP \(bu 2 Sections are unordered. .IP \(bu 2 Blank lines or lines beginning with a hash character ('#') are treated as comments and ignored. .IP \(bu 2 Whitespace before and after a \fItoken\fP or \fIvalue\fP is ignored (although a \fIvalue\fP can contain whitespace within). .IP \(bu 2 Double quoting \fIvalue\fP is optional. Use them to preserve leading and trailing whitespace. .PP Valid tokens are always lowercase. Names are long-option command-line arguments of plowshare. For example: \fItemp-directory\fP for plowdown. For modules options, tokens are prepended by module name and a slash character. For example: \fIrapidgator/auth\fP (short-option are also possible here). For values, no backslash interpretation is made. "\\t" is a regular string with two characters, it is not a tab character. Options in general section prevail over Plow* section. Options given on the command line prevail over configuration file options. .\" **************************************************************************** .\" * Example * .\" **************************************************************************** .SH EXAMPLE .EX ### ### Plowshare configuration file ### [General] interface = eth1 rapidshare/a = matt:4deadbeef rapidgator/a = "matt:4 dead beef " antigate=bc427381269d702eccc509b8849e5b0d [Plowdown] timeout=3600 no-overwrite=1 [Plowup] max-retries=2 printf=Download URL: %u%nDelete URL: %d%n uploadmemodule/auth-free = foo@bar.com:kjguiy1581! uploadmemodule/folder = incoming [Plowlist] verbose = 3 .EE .\" **************************************************************************** .\" * Authors / See Also * .\" **************************************************************************** .SH AUTHORS Plowshare was initially written by Arnau Sanchez. See the AUTHORS file for a list of some of the many other contributors. Plowshare is (C) 2010-2016 The Plowshare Team .SH "SEE ALSO" .BR plowdown (1), .BR plowup (1), .BR plowdel (1), .BR plowlist (1), .BR plowprobe (1), .BR plowmod (1). plowshare-2.1.7/docs/plowshare.conf.sample000066400000000000000000000041001314210002400205660ustar00rootroot00000000000000# Example file for Plowshare configuration file # Copy to ~/.config/plowshare/plowshare.conf # $ man plowshare.conf # ========================================================= [General] # Put here plow* common options (long --options) and modules options # If option is non existing or module option unused, it will be just silently ignored # (for example modulename1 can have --auth option in plowdown but not in plowup). # I always want -v3 verbose=3 # Whitespace is stripped around token and value # Persistent storage: reuse cookies, sessions (as far as module supports it). cache = shared # For credentials, format is USER:PASSWORD # (it is not possible to have colon character in USER, but it is possible in PASSWORD) # /a is alias for /auth modulename1/a=foo@bar.com:password123++ modulename2/a = foo@bar.com:password123++ # Whitespace is inside, it is legal modulename3/a = foo@bar.com:password123 ++ modulename4/a = foo@bar.com: password123 ++ # For leading or trailing spaces, we must use double quotes # /b is alias for /auth-free modulename5/b = "foo@bar.com:password124++ " # ========================================================= [Plowdown] # Put here plowdown options (long --options) and modules options for plowdown # See available module names: $ plowdown --modules # See available options per module: $ plowdown --longhelp # This is a flag switch, any right value does the job no-overwrite=1 # Empty value, this following line has no effect temp-rename= # Specific download module options # No colon character here, you'll be prompted for a password modulename6/a = foo@bar.com # ========================================================= [Plowup] # Put here plowup options (long --options) and modules options for plowup # See available module names: $ plowup --modules # See available options per module: $ plowup --longhelp # On upload failure, retry 2 times (default is 0) max-retries=2 # Specific upload module options modulename5/folder = root modulename5/private = 1 # ========================================================= #[Plowlist] #[Plowdel] #[Plowprobe] plowshare-2.1.7/docs/plowup.1000066400000000000000000000352331314210002400160560ustar00rootroot00000000000000.\" Copyright (c) 2010\-2016 Plowshare Team .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 3 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, see .\" . .TH "plowup" "1" "July 13, 2016" "GPL" "Plowshare for Bash 4" .SH NAME plowup \- Simple upload manager for file sharing websites .SH SYNOPSIS .B plowup [\fIOPTIONS\fP]... [\fIMODULE_OPTIONS\fP]... \fIMODULE\fP \fIURL\fP|\fIFILE\fP[\fI:DESTNAME\fP]... .SH DESCRIPTION .B plowup is a command-line tool designed for automatic upload on file-sharing websites. It acts like a web browser, retrieving pages and filling HTML forms. Anonymous upload is not allowed by all sites, some of them may require authentication. See specific module options below. .\" **************************************************************************** .\" * Options * .\" **************************************************************************** .SH OPTIONS .SS Common options .TP .BI -i, " " --interface= IFACE If your machine has several network interfaces, force using \fIIFACE\fR interface. .TP .BI -r, " " --max-retries= N Set maximum retries for upload failures. Apply on module exit value: \fB1\fR (fatal error), \fB3\fR (network error), \fB7\fR (captcha error). Default option value is 0 (no retry) and applies for one single upload. .TP .BI -t, " " --timeout= SECS Cancel upload download after \fISECS\fR seconds of waits. Apply on module exit value: \fB10\fR (temporary unavailable error). This error mainly occurs on remote upload operations. Default option value is disabled (no timeout, infinite) and applies for one single upload. .TP .BI " " " " --cache= METHOD Cache policy regarding module storage space. \ Each module is able to save data (credentials, authentication session, or tokens) in order to be reused later. Available values: .RS \fBnone\fR: module storage file is deleted before each item processing. Temporary directory is used. .RE .RS \fBsession\fR (default): module storage file is deleted at the end of plowup execution. Temporary directory is used. .RE .RS \fBshared\fR: module storage file is global and located (in \fI~/.config/plowshare/storage/\fR). It can be accessed by any other instance of plow* scripts. Warning: There is no atomicity (or file locking) on concurrent access. Example: Multiple file upload using a premium account. If supported by module, login stage could be performed once. .RE .SS Captcha options .TP .BI " " " " --9kweu= KEY Use 9kw.eu service to solve captchas. .TP .BI " " " " --antigate= KEY Use Antigate.com service to solve captchas. .TP .BI " " " " --captchabhood= USER:PASSWORD Use Captcha Brotherhood service to solve captchas. .TP .BI " " " " --captchacoin= KEY Use CaptchaCoin service to solve captchas. .TP .BI " " " " --deathbycaptcha= USER:PASSWORD Use Death by Captcha service to solve captchas. .TP .BI " " " " --captchamethod= METHOD Force specific captcha solving method (if unspecified it is autodetected). Available values: .RS \fBimgur\fR: upload image to Imgur.com service, print image url in console and prompt for manual entering. Useful for NAS and embedded devices. .RE .RS \fBnone\fR: abort if captcha solving is requested (even if automatic solving service is available). .RE .RS \fBonline\fR: use captcha solving website only (9kweu, Antigate, CaptchaBrotherhood, CaptchaCoin or DeathByCaptcha account required). .RE .RS \fBfb\fR: display image in framebuffer console and prompt for manual entering. Looks for framebuffer viewers: fbi, fim. \fIFRAMEBUFFER\fR environment variable can contain device file. Default is \fI/dev/fb0\fR. .RE .RS \fBnox\fR: display image in console (text) and prompt for manual entering. Looks for ascii viewers: img2txt, aview, tiv. .RE .RS \fBx11\fR: display image in an X11 window and prompt for manual entering. Looks for viewers: display, feh, sxiv, qiv. \fIDISPLAY\fR environment variable must not be empty. .RE .TP .BI " " " " --captchaprogram= PROGRAM Call external program or script for solving captchas. Provided executable can be located in \fIPATH\fR environment variable. Three arguments are given: .RS \fB$1\fR module name (lowercase). For example: \fImediafire\fR. .RE .RS \fB$2\fR image filename (with full path). .RE .RS \fB$3\fR hint or captcha type (string). For example: \fIrecaptcha\fR, \fIsolvemedia\fR or \fIdigits-4\fR. Return value (on stdout) and exit status: .RE .RS \fB0\fR: solving success. Captcha Word(s) must be echo'ed. .RE .RS \fB2\fR: external solver is not able to solve requested captcha. Let plowup continue solving it normally (will consider \fB--captchamethod\fR if specified). .RE .RS \fB7\fR: external solver failed. Note: this exit code is eligible with retry policy (\fB-r\fR/\fB--max-retries\fR). Note: plowup legacy exit errors can also be returned, for example: \fB1\fR (fatal) or \fB3\fR (network). .RE .SS Tuning settings .TP .BI " " " " --max-rate= SPEED Limit upload maximum speed in bytes per second. Suffixes are: .RS \fBk\fR for kilobytes (kB i.e. 1000), .RE .RS \fBM\fR for megabytes (MB i.e. 1000^2), .RE .RS \fBK\fR or \fBKi\fR for kibibytes (KB or KiB i.e. 1024), .RE .RS \fBm\fR or \fBMi\fR for mebibytes (mB or MiB i.e. 1024^2). .RE .TP .BI " " " " --min-rate= SPEED Limit upload minimum speed in bytes per second (for a delay of 30 seconds). Suffixes are the same than \fB--max-rate\fR. .TP .BI " " " " --temp-directory= DIRECTORY Directory for temporary files: cookies, images, ... .TP .BI " " " " --name= FORMAT Format destination filename (applies on each file argument). Can be useful is you want to append or prepend a string to all your files. Default format string is \fI"%f"\fR. Interpreted sequences are: .RS .TP \fI%%\fR raw % character .TP \fI%f\fR destination (remote) filename .TP \fI%g\fR destination (remote) filename (without extension) .TP \fI%G\fR destination (remote) filename (without extension, greedy) .TP \fI%h\fR MD5 hash (32-digit hexadecimal number, lowercase letters) .TP \fI%l\fR source (local) filename .TP \fI%m\fR module name .TP \fI%s\fR file size (in bytes) .TP \fI%x\fR extension (without dot character) of %f (not greedy) .RE .TP .BI " " " " --run-before= PROGRAM Call external program or script before upload file processing. Provided executable can be located in \fIPATH\fR environment variable. Messages can be sent to stderr, stdout is trashed. Three arguments are given: .RS \fB$1\fR module name (lowercase). For example: \fImediafire\fR. .RE .RS \fB$2\fR local filename .RE .RS \fB$3\fR destination filename .RE .RS \fB$4\fR cookie (initially empty) file given to upload module function. Exit status: .RE .RS \fB0\fR: script success. plowup continue normally. .RE .RS \fB2\fR: script explicitly requests skipping current file. Note: Any other script exit status like \fB1\fR (fatal) or \fB3\fR (network) will be ignored (an error message will be reported). .RE .TP .BI " " " " --printf= FORMAT Print results (on stdout) in a given format (for each successful upload). Default format string is \fI"%L%M%u%n"\fR. Interpreted sequences are: .RS .TP \fI%%\fR raw % character .TP \fI%a\fR admin url or admin code (rare case) .TP \fI%A\fR same as \fB%a\fR but url is escaped for JSON usage .TP \fI%M\fR empty if \fB%a\fR is empty, or alias to "\fB#ADM %a%n\fR". .TP \fI%d\fR delete url .TP \fI%D\fR same as \fB%d\fR but url is escaped for JSON usage .TP \fI%L\fR empty if \fB%d\fR is empty, or alias to "\fB#DEL %d%n\fR". .TP \fI%f\fR destination (remote) filename .TP \fI%l\fR source (local) filename .TP \fI%m\fR module name .TP \fI%n\fR newline .TP \fI%s\fR filesize (positive integer in bytes) .TP \fI%t\fR tabulation character .TP \fI%T\fR 24-hour clock time of finished file upload. 8 characters string in the format "\fBHH:MM:SS\fR" (invoke \fI/bin/date +%T\fR). .TP \fI%u\fR download url .TP \fI%U\fR same as \fB%u\fR but url is escaped for JSON usage .RE .SS Logging options .TP .BI -v, " " --verbose= LEVEL Set output verbosity level: .RS \fB0\fR none, .RE .RS \fB1\fR errors, .RE .RS \fB2\fR notice (default behavior), .RE .RS \fB3\fR debug, .RE .RS \fB4\fR report (very noisy, log HTML pages). .RE .TP .B -q, --quiet Alias for \fB-v0\fR. Do not print any debug messages. .SS Miscellaneous options .TP .B " " --no-color Disables log messages (stderr only) output coloring. .TP .B " " --no-curlrc Do not use curl config file (~/.curlrc). .TP .BI " " " " --curlrc= FILE Force using an alternate curl configuration file. Replaces ~/.curlrc if it exists. This option has no effect when .B --no\-curlrc is defined. .TP .B " " --no-plowsharerc Do not consider any configuration file. .TP .BI " " " " --plowsharerc= FILE Force using an alternate configuration file (instead of per-user or systemwide plowshare.conf). This option has no effect when .B --no\-plowsharerc is defined. .TP .B " " --modules Display all supported module names (one per line) and exit. Useful for wrappers. .SS Generic program information .TP .B -h, --help Display main help and exit. .TP .B -H, --longhelp Display complete help (with module options) and exit. .TP .B " " --version Output version information and exit. .\" **************************************************************************** .\" * Modules options * .\" **************************************************************************** .SH "MODULE OPTIONS" .SS Common options .TP .BI -a, " " --auth= USER:PASSWORD Use premium account. .TP .BI -b, " " --auth-free= USER:PASSWORD Use free account. .TP .BI -d, " " --description= DESCRIPTION Set file description. .TP .BI " " " " --folder= FOLDER Folder to upload files into. Usually a (leaf) folder name (no hierarchy assumed). .TP .BI -p, " " --link-password= PASSWORD Protect your files with a password. May require premium account. .TP .BI " " " " --email-from= EMAIL field for notification email. .TP .BI " " " " --email-to= EMAIL field for notification email. .SS Advanced options .TP .B " " --async Asynchronous remote upload (only start upload, don't wait for link). .TP .B " " --private Do not allow others to download the file. .P All switches are not implemented nor required for all modules. See long help message for detailed modules option list. .\" **************************************************************************** .\" * Files * .\" **************************************************************************** .SH "FILES" .TP .I /etc/plowshare.conf Systemwide configuration file. .TP .I ~/.config/plowshare/plowshare.conf This is the per-user configuration file. .PP The file format is described in .BR plowshare.conf (5). .TP .I ~/.config/plowshare/exec/ Additional directory considered when searching for executable. See \fB--captchaprogram\fR switch. .TP .I ~/.config/plowshare/modules.d/ User directory considered when searching for modules at startup (plowup will try to open \fB~/.config/plowshare/modules.d/*/config\fR). One file per module (hoster). .TP .I ~/.config/plowshare/storage/ Directory used for storing data (one file per module) among sessions. See \fB--cache=shared\fR switch. .\" **************************************************************************** .\" * Environment Variables * .\" **************************************************************************** .SH "ENVIRONMENT VARIABLES" The following environment variables may affect plowup: .TP .I DISPLAY The X11 display server address is considered to display captchas. See \fB--captchamethod=x11\fR documentation below. .TP .I FRAMEBUFFER This variable is considered to display captchas. See \fB--captchamethod=fb\fR documentation below. .TP .I HOME Search for user configuration directory in \fB~/.config/plowshare\fR (see FILES section above). If found, \fB~/.curlrc\fR will be used (use \fB--no-curlrc\fR to disable it). .TP .I PLOWSHARE_CURL Specifies an alternate curl command (\fB$PATH\fR search is considered). If not defined, \fBcurl\fR is used. .TP .I PLOWSHARE_JS Specifies an alternate js command (\fB$PATH\fR search is considered). If not defined, \fBjs\fR is used. .TP .I XDG_CONFIG_HOME The directory to store user configuration files. If not defined, \fB~/.config\fR is assumed. .\" **************************************************************************** .\" * Exit codes * .\" **************************************************************************** .SH "EXIT CODES" Possible exit codes are: .IP 0 Success. .IP 1 Fatal error. Upstream site updated or unexpected result. .IP 2 No available module (provided module name does not exist). .IP 3 Network error. Mostly curl related. .IP 4 Authentication failed (bad login/password). .IP 5 Timeout reached (refer to \fB-t\fR/\fB--timeout\fR command-line option). .IP 6 Maximum tries reached (refer to \fB-r\fR/\fB--max-retries\fR command-line option). .IP 7 Captcha generic error. .IP 8 System generic error. .IP 10 Feature (upload service) seems temporarily unavailable from upstream (user account may be temporarily banned). .IP 12 Authentication required (example: anonymous users can't do remote upload). .IP 14 Can't upload too big file (hoster limitation or requires more permissions). .IP 15 Unknown command line parameter or incompatible options. .IP 16 Asynchronous remote upload started (can't predict final status). .PP If .B plowup is invoked with multiple files and one or several errors occur, the first error code is returned added with 100. .\" **************************************************************************** .\" * Authors / See Also * .\" **************************************************************************** .SH AUTHORS Plowshare was initially written by Arnau Sanchez. See the AUTHORS file for a list of some of the many other contributors. Plowshare is (C) 2010-2016 The Plowshare Team .SH "SEE ALSO" .BR plowdown (1), .BR plowdel (1), .BR plowlist (1), .BR plowprobe (1), .BR plowshare.conf (5), .BR plowmod (1). plowshare-2.1.7/scripts/000077500000000000000000000000001314210002400151775ustar00rootroot00000000000000plowshare-2.1.7/scripts/minify.sed000077500000000000000000000004241314210002400171720ustar00rootroot00000000000000#!/bin/sed -nf # Basic minification of bash sources. # Actions: # - delete empty lines # - delete comment lines # - shrink (but preserve) indentation (4n spaces => n spaces) 1{ /^#!/p } /^\s*$/d /^\s*#/!{ :a s/^\(#*\)\s\{4\}/\1#/ ta :b s/^\(\s*\)#/\1 / tb p } plowshare-2.1.7/scripts/plowshare.completion000066400000000000000000000173551314210002400213110ustar00rootroot00000000000000# plowshare completion -*- shell-script -*- # Note: -a/--auth, -p/--link-password are common modules options. _plowup() { local cur prev words cword split _init_completion -s -n : || return case "$prev" in -v|--verbose) COMPREPLY=( $( compgen -W '0 1 2 3 4' -- $cur ) ) return 0 ;; -i|--interface) _available_interfaces -a return 0 ;; -a|-b|-d|-p|--auth|--description|--link-password|--min-rate|--max-rate|-r|--max-retries|-t|--timeout|--printf|--9kweu|--antigate|--captchabhood|--captchacoin|--deathbycaptcha) # argument required but no completion available return 0 ;; --cache) COMPREPLY=( $( compgen -W 'none session shared' -- $cur ) ) return 0 ;; --captchaprogram|--run-before|---plowsharerc|--curlrc) _filedir return 0 ;; --captchamethod) COMPREPLY=( $( compgen -W 'imgur none online fb nox x11' -- $cur ) ) return 0 ;; --name) if [ -z "$cur" ]; then COMPREPLY=( "'%f'" ) fi return 0 ;; --temp-directory) _filedir -d return 0 ;; esac if [[ $cur = -* ]]; then COMPREPLY=( $( compgen -W '--help --longhelp --version --quiet --verbose \ -v -q -i -t -r \ --min-rate --max-rate --interface --max-retries --timeout --name --cache \ --captchamethod --captchaprogram --9kweu --antigate --captchabhood --captchacoin --deathbycaptcha \ --temp-directory --printf --run-before --no-curlrc --curlrc --no-plowsharerc --plowsharerc' -- $cur ) ) else local i files for i in /usr/local/share/plowshare/modules/config \ $HOME/.config/plowshare/modules.d/*/config \ $HOME/.config/plowshare/modules/config; do test -f $i && files+=($i) done if [ ${#files[@]} -gt 0 ]; then local m list list=$(sed -ne '/^[^#].*|[[:space:]]*upload[[:space:]]*|/s/|.*//p' "${files[@]}" | sort -u) if [[ $list ]]; then # check for already given module name # note: _get_first_arg is not accurate enough (option with argument) for m in $list; do for (( i=1; i < ${#COMP_WORDS[@]}-1; i++ )); do if [ "${COMP_WORDS[i]//./_}" = $m ]; then _filedir return 0 fi done done COMPREPLY=( $(compgen -W "$list" -- ${cur//./_} ) ) else # no module found _filedir fi else # no config file found _filedir fi fi } && complete -F _plowup plowup _plowdown() { local cur prev words cword split _init_completion -s -n : || return case "$prev" in -v|--verbose) COMPREPLY=( $( compgen -W '0 1 2 3 4' -- $cur ) ) return 0 ;; -a|-b|-p|--auth-free|--auth|--link-password|--9kweu|--antigate|--captchabhood|--captchacoin|--deathbycaptcha|--min-space|--max-rate|--min-rate|-r|--max-retries|-t|--timeout|--printf) # argument required but no completion available return 0 ;; -o|--output-directory|--temp-directory) _filedir -d return 0 ;; -i|--interface) _available_interfaces -a return 0 ;; --cache) COMPREPLY=( $( compgen -W 'none session shared' -- $cur ) ) return 0 ;; --captchamethod) COMPREPLY=( $( compgen -W 'imgur none online fb nox x11' -- $cur ) ) return 0 ;; --captchaprogram|--run-before|--run-after|--plowsharerc|--curlrc) _filedir return 0 ;; esac if [[ $cur = -* ]]; then COMPREPLY=( $( compgen -W '--help --longhelp --version --quiet --verbose \ -v -q -i -o -m -r -t -x \ --min-space --max-rate --min-rate --interface --mark-downloaded --no-overwrite --cache \ --output-directory --temp-directory --temp-rename --timeout --max-retries \ --captchamethod --captchaprogram --9kweu --antigate --captchabhood --captchacoin --deathbycaptcha \ --fallback --printf --run-before --run-after --no-curlrc --curlrc --no-plowsharerc --plowsharerc' -- $cur ) ) else _filedir fi } && complete -F _plowdown plowdown _plowdel() { local cur prev words cword split _init_completion -s -n : || return case "$prev" in -v|--verbose) COMPREPLY=( $( compgen -W '0 1 2 3 4' -- $cur ) ) return 0 ;; -a|-b|-p|--auth|--auth-free|--link-password|--9kweu|--antigate|--captchabhood|--captchacoin|--deathbycaptcha) # argument required but no completion available return 0 ;; -i|--interface) _available_interfaces -a return 0 ;; --captchamethod) COMPREPLY=( $( compgen -W 'imgur none online fb nox x11' -- $cur ) ) return 0 ;; --captchaprogram|--plowsharerc|--curlrc) _filedir return 0 ;; esac if [[ $cur = -* ]]; then COMPREPLY=( $( compgen -W '--help --longhelp --version --quiet --verbose \ -v -q -i \ --captchamethod --captchaprogram --9kweu --antigate --captchabhood --captchacoin --deathbycaptcha \ --interface --no-curlrc --curlrc --no-plowsharerc --plowsharerc' -- $cur ) ) else # URL pattern expected _filedir fi } && complete -F _plowdel plowdel _plowlist() { local cur prev words cword split _init_completion -s -n : || return case "$prev" in -v|--verbose) COMPREPLY=( $( compgen -W '0 1 2 3 4' -- $cur ) ) return 0 ;; -p|--link-password|--printf|-t|--timeout) # argument required but no completion available return 0 ;; -i|--interface) _available_interfaces -a return 0 ;; --plowsharerc|--curlrc) _filedir return 0 ;; esac if [[ $cur = -* ]]; then COMPREPLY=( $( compgen -W '--help --longhelp --version --quiet --verbose \ -v -q -i -R -t \ --interface --printf --recursive --timeout --fallback \ --no-curlrc --curlrc --no-plowsharerc --plowsharerc' -- $cur ) ) else # URL pattern expected _filedir fi } && complete -F _plowlist plowlist _plowprobe() { local cur prev words cword split _init_completion -s -n : || return case "$prev" in -v|--verbose) COMPREPLY=( $( compgen -W '0 1 2 3 4' -- $cur ) ) return 0 ;; --printf) # argument required but no completion available return 0 ;; -i|--interface) _available_interfaces -a return 0 ;; --plowsharerc|--curlrc) _filedir return 0 ;; esac if [[ $cur = -* ]]; then COMPREPLY=( $( compgen -W '--help --longhelp --version --quiet --verbose \ -v -q -i --get-module --interface --printf --follow --no-curlrc --curlrc --no-plowsharerc --plowsharerc' -- $cur ) ) else # URL pattern expected _filedir fi } && complete -F _plowprobe plowprobe # ex: ts=4 sw=4 et filetype=sh plowshare-2.1.7/scripts/version000077500000000000000000000013161314210002400166130ustar00rootroot00000000000000#!/bin/sh -e # # Note: # Choose "git describe" revision syntax: v1.0.1-17-g390e0fa # over usual (distro) one: 1.0.1~git20140411-390e0fa if [ $# -ne 0 ]; then echo 'warning: this script does not take any argument.' >&2 fi # Check environment variable PLOWSHARE_FORCE_VERSION # For example: "1.0.1" if [ -n "$PLOWSHARE_FORCE_VERSION" ]; then date=$(date +'%Y-%m-%d') echo "v${PLOWSHARE_FORCE_VERSION#v} ($date)" elif git rev-parse --is-inside-work-tree 1>/dev/null 2>&1; then rev=$(git describe --always --tags) date=$(git log "$rev" -n1 --pretty=%ci | cut -d' ' -f1) echo "$rev ($date)" else echo 'warning: unable to detect plowshare version.' >&2 date=$(date +'%Y-%m-%d') echo "UNKNOWN ($date)" fi plowshare-2.1.7/src/000077500000000000000000000000001314210002400142775ustar00rootroot00000000000000plowshare-2.1.7/src/core.sh000066400000000000000000004025361314210002400155750ustar00rootroot00000000000000#!/usr/bin/env bash # # Common set of functions used by modules # Copyright (c) 2010-2016 Plowshare team # # This file is part of Plowshare. # # Plowshare is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Plowshare is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Plowshare. If not, see . # Make pipes fail on the first failed command (requires Bash 3+) set -o pipefail # Each time an API is updated, this value will be increased declare -r PLOWSHARE_API_VERSION=6 # User configuration directory (contains plowshare.conf, exec/, storage/, modules.d/) declare -r PLOWSHARE_CONFDIR="${XDG_CONFIG_HOME:-$HOME/.config}/plowshare" # Dependencies declare -r PLOWCORE_JS=${PLOWSHARE_JS:-js} declare -r PLOWCORE_CURL=${PLOWSHARE_CURL:-curl} # Global error codes # 0 means success or link alive declare -r ERR_FATAL=1 # Unexpected result (upstream site updated, etc) declare -r ERR_NOMODULE=2 # No module found for processing request declare -r ERR_NETWORK=3 # Generic network error (socket failure, curl, firewall, etc) declare -r ERR_LOGIN_FAILED=4 # Correct login/password argument is required declare -r ERR_MAX_WAIT_REACHED=5 # Wait timeout (see -t/--timeout command line option) declare -r ERR_MAX_TRIES_REACHED=6 # Max tries reached (see -r/--max-retries command line option) declare -r ERR_CAPTCHA=7 # Captcha solving failure declare -r ERR_SYSTEM=8 # System failure (missing executable, local filesystem, wrong behavior, etc) declare -r ERR_LINK_TEMP_UNAVAILABLE=10 # plowdown: Link alive but temporarily unavailable # plowup: Feature (upload service) seems temporarily unavailable from upstream # plowlist: Links are temporarily unavailable. Upload still pending? declare -r ERR_LINK_PASSWORD_REQUIRED=11 # plowdown: Link alive but requires a password # plowdel: Link requires an admin or removal code # plowlist: Remote folder is password protected declare -r ERR_LINK_NEED_PERMISSIONS=12 # plowdown: Link alive but requires some authentication (private or premium link) # plowup, plowdel: Operation not allowed for anonymous users declare -r ERR_LINK_DEAD=13 # plowdel: File not found or previously deleted # plowlist: Remote folder does not exist or is empty declare -r ERR_SIZE_LIMIT_EXCEEDED=14 # plowdown: Can't download link because file is too big (need permissions) # plowup: Can't upload too big file (need permissions) declare -r ERR_BAD_COMMAND_LINE=15 # Unknown command line parameter or incompatible options declare -r ERR_ASYNC_REQUEST=16 # plowup: Asynchronous remote upload started (can't predict final status) declare -r ERR_EXPIRED_SESSION=17 # Related to local storage module file, expired session declare -r ERR_FATAL_MULTIPLE=100 # 100 + (n) with n = first error code (when multiple arguments) # Global variables used (defined in plow* scripts): # - VERBOSE Verbosity level (0=none, 1=error, 2=notice, 3=debug, 4=report) # - INTERFACE (curl) Network interface # - MAX_LIMIT_RATE (curl) Network maximum speed # - MIN_LIMIT_RATE (curl) Network minimum speed # - NO_CURLRC (curl) Do not read of use curlrc config # - EXT_CURLRC (curl) Alternate curlrc config file # - CAPTCHA_METHOD User-specified captcha method # - CAPTCHA_ANTIGATE Antigate.com captcha key # - CAPTCHA_9KWEU 9kw.eu captcha key # - CAPTCHA_BHOOD Captcha Brotherhood account # - CAPTCHA_COIN captchacoin.com captcha key # - CAPTCHA_DEATHBY DeathByCaptcha account # - CAPTCHA_PROGRAM External solver program/script # - MODULE Module name (don't include .sh), used by storage API # - TMPDIR Temporary directory # - CACHE Storage API policy: none, session (default or empty), shared. # - COLOR Display log_notice & log_error messages with colors # Note: captchas are handled in plowdown, plowup and plowdel. # # Logs are sent to stderr stream. # Policies: # - error: core/modules error messages, lastest curl call (plowdown, plowup) # - notice: core messages (wait, timeout, retries), lastest curl call (plowdown, plowup) # - debug: all core/modules messages, curl calls # - report: debug plus curl content (html pages, cookies) # # Global variables defined here (FIXME later): # - PS_TIMEOUT (plowdown, plowup) Timeout (in seconds) for one item # - CONT_SIGNAL SIGCONT signal received # log_report for a file # $1: filename logcat_report() { if test -s "$1"; then test $VERBOSE -lt 4 || \ stderr "$(sed -e 's/^/rep:/' "$1")" fi return 0 } # This should not be called within modules log_report() { test $VERBOSE -lt 4 || stderr 'rep:' "$@" } log_debug() { test $VERBOSE -lt 3 || stderr 'dbg:' "$@" } # This should not be called within modules log_notice() { if [[ $COLOR ]]; then # 33 is yellow test $VERBOSE -lt 2 || echo -e "\033[0;33m$@\033[0m" >&2 else test $VERBOSE -lt 2 || stderr "$@" fi } log_error() { if [[ $COLOR ]]; then # 31 is red test $VERBOSE -lt 1 || echo -e "\033[0;31m$@\033[0m" >&2 else test $VERBOSE -lt 1 || stderr "$@" fi } ## ---------------------------------------------------------------------------- ## ## All helper functions below can be called by modules ## (see documentation...) ## # Wrapper for curl: debug and infinite loop control # $1..$n are curl arguments # Important note: -D/--dump-header or -o/--output temporary files are deleted in case of error curl() { local -a CURL_ARGS=("$@") local -a OPTIONS=(--insecure --compressed --speed-time 600 --connect-timeout 240) local DRETVAL=0 # Check if caller has specified a User-Agent, if so, don't put one if ! find_in_array CURL_ARGS[@] '-A' '--user-agent'; then OPTIONS+=(--user-agent \ 'Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20100101 Firefox/6.0') fi # If caller has allowed redirection but did not limit it, do it now if find_in_array CURL_ARGS[@] '-L' '--location'; then find_in_array CURL_ARGS[@] '--max-redirs' || OPTIONS+=(--max-redirs 5) fi if [ -n "$NO_CURLRC" ]; then OPTIONS=(-q "${OPTIONS[@]}") elif [ -n "$EXT_CURLRC" ]; then OPTIONS=(-q --config "$EXT_CURLRC" "${OPTIONS[@]}") fi # No verbose unless debug level; don't show progress meter for report level too if [ "${FUNCNAME[1]}" = 'curl_with_log' ]; then test $VERBOSE -eq 0 && OPTIONS[${#OPTIONS[@]}]='--silent' else test $VERBOSE -ne 3 && OPTIONS[${#OPTIONS[@]}]='--silent' fi if test -n "$INTERFACE"; then OPTIONS+=(--interface $INTERFACE) fi if test -n "$MAX_LIMIT_RATE"; then OPTIONS+=(--limit-rate $MAX_LIMIT_RATE) fi if test -n "$MIN_LIMIT_RATE"; then OPTIONS+=(--speed-time 30 --speed-limit $MIN_LIMIT_RATE) fi if test $VERBOSE -lt 4; then command "$PLOWCORE_CURL" "${OPTIONS[@]}" "${CURL_ARGS[@]}" || DRETVAL=$? else local FILESIZE TEMPCURL=$(create_tempfile) log_report "${OPTIONS[@]}" "${CURL_ARGS[@]}" command "$PLOWCORE_CURL" "${OPTIONS[@]}" "${CURL_ARGS[@]}" --show-error --silent >"$TEMPCURL" 2>&1 || DRETVAL=$? FILESIZE=$(get_filesize "$TEMPCURL") log_report "Received $FILESIZE bytes. DRETVAL=$DRETVAL" log_report '=== CURL BEGIN ===' logcat_report "$TEMPCURL" log_report '=== CURL END ===' cat "$TEMPCURL" rm -f "$TEMPCURL" fi if [ "$DRETVAL" != 0 ]; then local INDEX FILE if INDEX=$(index_in_array CURL_ARGS[@] '-D' '--dump-header'); then FILE=${OPTIONS[$INDEX]} if [ -f "$FILE" ]; then log_debug "deleting temporary HTTP header file: $FILE" rm -f "$FILE" fi fi if INDEX=$(index_in_array CURL_ARGS[@] '-o' '--output'); then FILE=${OPTIONS[$INDEX]} # Test to reject "-o /dev/null" and final plowdown call if [ -f "$FILE" ] && ! find_in_array OPTIONS[@] '--globoff'; then log_debug "deleting temporary output file: $FILE" rm -f "$FILE" fi fi case $DRETVAL in # Failed to initialize. 2|27) log_error "$FUNCNAME: out of memory?" return $ERR_SYSTEM ;; # Couldn't resolve host. The given remote host was not resolved. 6) log_notice "$FUNCNAME: couldn't resolve host" return $ERR_NETWORK ;; # Failed to connect to host. 7) log_notice "$FUNCNAME: couldn't connect to host" return $ERR_NETWORK ;; # Partial file 18) return $ERR_LINK_TEMP_UNAVAILABLE ;; # HTTP retrieve error / Operation timeout 22|28) log_error "$FUNCNAME: HTTP retrieve error" return $ERR_NETWORK ;; # Write error 23) log_error "$FUNCNAME: write failed, disk full?" return $ERR_SYSTEM ;; # Too many redirects 47) if ! find_in_array CURL_ARGS[@] '--max-redirs'; then log_error "$FUNCNAME: too many redirects" return $ERR_FATAL fi ;; # Invalid LDAP URL. See command_not_found_handle() 62) return $ERR_SYSTEM ;; *) log_error "$FUNCNAME: failed with exit code $DRETVAL" return $ERR_NETWORK ;; esac fi return 0 } # Force debug verbose level (unless -v0/-q specified) curl_with_log() { curl "$@" } # Substring replacement (replace all matches) # # stdin: input string # $1: substring to find (this is not a regexp) # $2: replacement string (this is not a regexp) replace_all() { # Using $(< /dev/stdin) gives same results local S=$(cat) # We must escape '\' character local FROM=${1//\\/\\\\} echo "${S//$FROM/$2}" } # Substring replacement (replace first match) # # stdin: input string # $1: substring to find (this is not a regexp) # $2: replacement string (this is not a regexp) replace() { local S=$(cat) local FROM=${1//\\/\\\\} echo "${S/$FROM/$2}" } # Return uppercase string # $*: input string(s) uppercase() { echo "${*^^}" } # Return lowercase string # $*: input string(s) lowercase() { echo "${*,,}" } # Grep first line of a text # $1: (optional) How many head lines to take (default is 1) # stdin: input string (multiline) first_line() { local -r N=${1:-1} if (( N < 1 )); then log_error "$FUNCNAME: negative index not expected" return $ERR_FATAL fi # Equivalent to `sed -ne 1p` or `sed -e q` or `sed -e 1q` (N=1 here) head -n$((N)) } # Grep last line of a text # $1: (optional) How many tail lines to take (default is 1) # stdin: input string (multiline) last_line() { local -r N=${1:-1} if (( N < 1 )); then log_error "$FUNCNAME: negative index not expected" return $ERR_FATAL fi # Equivalent to `sed -ne '$p'` or `sed -e '$!d'` (N=1 here) tail -n$((N)) } # Grep nth line of a text # stdin: input string (multiline) # $1: line number (start at index 1) nth_line() { local -r N=${1:-1} if (( N < 1 )); then log_error "$FUNCNAME: negative index not expected" return $ERR_FATAL fi # Equivalent to `sed -e "${1}q;d"` or `sed -e "${1}!d"` sed -ne "$((N))p" } # Delete fist line(s) of a buffer # $1: (optional) How many head lines to delete (default is 1) # stdin: input string (multiline) delete_first_line() { local -r N=${1:-1} if (( N < 1 )); then log_error "$FUNCNAME: negative index not expected" return $ERR_FATAL fi # Equivalent to `tail -n +2` (if $1=1) sed -ne "$((N+1)),\$p" } # Delete last line(s) of a text # $1: (optional) How many tail lines to delete (default is 1) # stdin: input string (multiline) delete_last_line() { local -r N=${1:-1} if (( N < 1 )); then log_error "$FUNCNAME: negative index not expected" return $ERR_FATAL fi # Equivalent to `head -n -1` (if $1=1) sed -ne :a -e "1,$N!{P;N;D;};N;ba" } # Delete lines up to regexp (included). # In a nutshell: eat lines until regexp is met, if nothing match, # delete lines until the end of input data (not really useful). # In vim, it would look like this: ":.,/regex/d" or ":.+5,/regex/+1d" ($3=5,$2=1). # # Examples: # $ echo -e "aa\nbb\ncc\ndd\ee" >/tmp/f # $ delete_filter_line 'cc' 0 )); then # Line $N must be displayed STR=$(sed -e "${N}p" -e "$N,${FILTER}d") else # 0,/regexp/ is valid, match can occur on first line STR=$(sed -e "$N,${FILTER}d") fi elif [ $FUZZ -eq 1 ]; then if (( $N > 0 )); then STR=$(sed -e "${N}p" -e "$N,${FILTER}{${FILTER}N;d}") else STR=$(sed -e "$N,${FILTER}{${FILTER}N;d}") fi elif [ $FUZZ -eq -1 ]; then if (( $N > 0 )); then # If regexp matches at line $N do not print it twice STR=$(sed -e "${N}p" -e "$N,${FILTER}{${N}d;${FILTER}p;d}") else STR=$(sed -e "$N,${FILTER}{${FILTER}p;d}") fi else local -i FUZZ_ABS=$(( FUZZ < 0 ? -FUZZ : FUZZ )) [ $FUZZ_ABS -gt 10 ] && log_notice "$FUNCNAME: are you sure you want to skip $((N+1)) lines?" if [ $FUZZ -gt 0 ]; then local SKIPS='N' # printf '=%.0s' {1..n} while (( --FUZZ_ABS )); do SKIPS+=';N' done if (( $N > 0 )); then STR=$(sed -e "${N}p" -e "$N,${FILTER}{${FILTER}{${SKIPS}};d}") else STR=$(sed -e "$N,${FILTER}{${FILTER}{${SKIPS}};d}") fi else local LINES='.*' while (( --FUZZ_ABS )); do LINES+='\n.*' done if (( $N > 0 )); then # Notes: could display duplicated lines when fuzz is below $N # This is not a bug, just a side effect... STR=$(sed -e "${N}p" -e "1h;1!H;x;s/^.*\\n\\($LINES\)$/\\1/;x" \ -e "$N,${FILTER}{${N}d;${FILTER}{g;p};d}") else STR=$(sed -e "1h;1!H;x;s/^.*\\n\\($LINES\)$/\\1/;x" \ -e "$N,${FILTER}{${FILTER}{g;p};d}") fi fi fi if [ -z "$STR" ]; then log_error "$FUNCNAME failed (sed): \"$N,/$1/d\" (skip $FUZZ)" log_notice_stack return $ERR_FATAL fi echo "$STR" } # Check if a string ($2) matches a regexp ($1) # This is case sensitive. # # $?: 0 for success match() { if [ -z "$2" ]; then log_debug "$FUNCNAME: input buffer is empty" return $ERR_FATAL else grep -q -- "$1" <<< "$2" fi } # Check if a string ($2) matches a regexp ($1) # This is not case sensitive. # # $?: 0 for success matchi() { if [ -z "$2" ]; then log_debug "$FUNCNAME: input buffer is empty" return $ERR_FATAL else grep -iq -- "$1" <<< "$2" fi } # Check if URL is suitable for remote upload # # $1: string (URL or anything) # $2..$n: additional URI scheme names to match. For example: "ftp" # $?: 0 for success match_remote_url() { local -r URL=$1 local RET=$ERR_FATAL [[ $URL =~ ^[[:space:]]*[Hh][Tt][Tt][Pp][Ss]?:// ]] && return 0 shopt -s nocasematch while [[ $# -gt 1 ]]; do shift if [[ $1 =~ ^[[:alpha:]][-.+[:alnum:]]*$ ]]; then if [[ $URL =~ ^[[:space:]]*$1:// ]]; then RET=0 break fi else log_error "$FUNCNAME: invalid scheme \`$1'" break fi done shopt -u nocasematch return $RET } # Get lines that match filter+parse regular expressions and extract string from it. # # $1: regexp to filter (take lines matching $1 pattern; "." or "" disable filtering). # $2: regexp to parse (must contain parentheses to capture text). Example: "url:'\(http.*\)'" # $3: (optional) how many lines to skip (default is 0: filter and match regexp on same line). # Note: $3 may only be used if line filtering is active ($1 != ".") # Example ($3=1): get lines matching filter regexp, then apply parse regexp on the line after. # Example ($3=-1): get lines matching filter regexp, then apply parse regexp on the line before. # stdin: text data # stdout: result parse_all() { local PARSE=$2 local -i N=${3:-0} local -r D=$'\001' # Change sed separator to allow '/' characters in regexp local STR FILTER if [ -n "$1" -a "$1" != '.' ]; then FILTER="\\${D}$1${D}" # /$1/ elif [ $N -ne 0 ]; then log_error "$FUNCNAME: wrong argument, offset argument is $N and filter regexp is \"$1\"" return $ERR_FATAL fi [ '^' = "${PARSE:0:1}" ] || PARSE="^.*$PARSE" [ '$' = "${PARSE:(-1):1}" ] || PARSE+='.*$' PARSE="s${D}$PARSE${D}\1${D}p" # s/$PARSE/\1/p if [ $N -eq 0 ]; then # STR=$(sed -ne "/$1/ s/$2/\1/p") STR=$(sed -ne "$FILTER $PARSE") elif [ $N -eq 1 ]; then # Note: Loop (with label) is required for consecutive matches # STR=$(sed -ne ":a /$1/ {n;h; s/$2/\1/p; g;ba;}") STR=$(sed -ne ":a $FILTER {n;h; $PARSE; g;ba;}") elif [ $N -eq -1 ]; then # STR=$(sed -ne "/$1/ {x; s/$2/\1/p; b;}" -e 'h') STR=$(sed -ne "$FILTER {x; $PARSE; b;}" -e 'h') else local -r FIRST_LINE='^\([^\n]*\).*$' local -r LAST_LINE='^.*\n\(.*\)$' local N_ABS=$(( N < 0 ? -N : N )) local I=$(( N_ABS - 2 )) # Note: N_ABS >= 2 due to "elif" above local LINES='.*' local INIT='N' local FILTER_LINE PARSE_LINE [ $N_ABS -gt 10 ] && log_notice "$FUNCNAME: are you sure you want to skip $N lines?" while (( I-- )); do INIT+=';N' done while (( N_ABS-- )); do LINES+='\n.*' done if [ $N -gt 0 ]; then FILTER_LINE=$FIRST_LINE PARSE_LINE=$LAST_LINE else FILTER_LINE=$LAST_LINE PARSE_LINE=$FIRST_LINE fi STR=$(sed -ne "1 {$INIT;h;n}" \ -e "H;g;s/^.*\\n\\($LINES\)$/\\1/;h" \ -e "s/$FILTER_LINE/\1/" \ -e "$FILTER {g;s/$PARSE_LINE/\1/;$PARSE }") # Explanation: [1], [2] let hold space always contain the current line # as well as the previous N lines # [3] let pattern space contain only the line we test filter regex # on (i.e. first buffered line on skip > 0, last line on skip < 0) # [4] if filter regex matches, let pattern space contain the line to # be parsed and apply parse command fi if [ -z "$STR" ]; then log_error "$FUNCNAME failed (sed): \"/$1/ ${PARSE//$D//}\" (skip $N)" log_notice_stack return $ERR_FATAL fi echo "$STR" } # Like parse_all, but hide possible error parse_all_quiet() { parse_all "$@" 2>/dev/null return 0 } # Like parse_all, but get only first match parse() { local PARSE=$2 local -i N=${3:-0} local -r D=$'\001' # Change sed separator to allow '/' characters in regexp local STR FILTER if [ -n "$1" -a "$1" != '.' ]; then FILTER="\\${D}$1${D}" # /$1/ elif [ $N -ne 0 ]; then log_error "$FUNCNAME: wrong argument, offset argument is $N and filter regexp is \"$1\"" return $ERR_FATAL fi [ '^' = "${PARSE:0:1}" ] || PARSE="^.*$PARSE" [ '$' = "${PARSE:(-1):1}" ] || PARSE+='.*$' PARSE="s${D}$PARSE${D}\1${D}p" # s/$PARSE/\1/p if [ $N -eq 0 ]; then # Note: This requires GNU sed (which is assumed by Plowshare) #STR=$(sed -ne "$FILTER {$PARSE;ta;b;:a;q;}") STR=$(sed -ne "$FILTER {$PARSE;T;q;}") elif [ $N -eq 1 ]; then #STR=$(sed -ne ":a $FILTER {n;h;$PARSE;tb;ba;:b;q;}") STR=$(sed -ne ":a $FILTER {n;$PARSE;Ta;q;}") elif [ $N -eq -1 ]; then #STR=$(sed -ne "$FILTER {g;$PARSE;ta;b;:a;q;}" -e 'h') STR=$(sed -ne "$FILTER {g;$PARSE;T;q;}" -e 'h') else local -r FIRST_LINE='^\([^\n]*\).*$' local -r LAST_LINE='^.*\n\(.*\)$' local N_ABS=$(( N < 0 ? -N : N )) local I=$(( N_ABS - 2 )) local LINES='.*' local INIT='N' local FILTER_LINE PARSE_LINE [ $N_ABS -gt 10 ] && log_notice "$FUNCNAME: are you sure you want to skip $N lines?" while (( I-- )); do INIT+=';N' done while (( N_ABS-- )); do LINES+='\n.*' done if [ $N -gt 0 ]; then FILTER_LINE=$FIRST_LINE PARSE_LINE=$LAST_LINE else FILTER_LINE=$LAST_LINE PARSE_LINE=$FIRST_LINE fi # Note: Need to "clean" conditionnal flag after s/$PARSE_LINE/\1/ STR=$(sed -ne "1 {$INIT;h;n}" \ -e "H;g;s/^.*\\n\\($LINES\)$/\\1/;h" \ -e "s/$FILTER_LINE/\1/" \ -e "$FILTER {g;s/$PARSE_LINE/\1/;ta;:a;$PARSE;T;q;}") fi if [ -z "$STR" ]; then log_error "$FUNCNAME failed (sed): \"/$1/ ${PARSE//$D//}\" (skip $N)" log_notice_stack return $ERR_FATAL fi echo "$STR" } # Like parse, but hide possible error parse_quiet() { parse "$@" 2>/dev/null return 0 } # Simple and limited JSON parsing # # Notes: # - Single line parsing oriented (user should strip newlines first): no tree model # - Array and Object types: basic poor support (depth 1 without complex types) # - String type: support for escaped unicode characters (\uXXXX) with bash >= 4.2 (and proper locale) # - No non standard C/C++ comments handling (like in JSONP) # - If several entries exist on same line: last occurrence is taken, but: # consider precedence (order of priority): number, boolean/empty, string. # - If several entries exist on different lines: all are returned (it's a parse_all_json) # # $1: variable name (string) # $2: (optional) preprocess option. Accepted values are: # - "join": make a single line of input stream. # - "split": split input buffer on comma character (,). # stdin: JSON data # stdout: result parse_json() { local -r NAME="\"$1\"[[:space:]]*:[[:space:]]*" local STR PRE # Note: Be nice with unicode chars and don't use $ (end-of-line). # Because dot will not match everything. local -r END='\([,}[:space:]].*\)\?' if [ "$2" = 'join' ]; then PRE="tr -d '\n\r'" elif [ "$2" = 'split' ]; then PRE=sed\ -e\ 's/,[[:space:]]*\(["{]\)/\n\1/g' else PRE='cat' fi # Note: "ta;:a" is a trick for cleaning conditionnal flag STR=$($PRE | sed \ -ne "/$NAME\[/{s/^.*$NAME\(\[[^]]*\]\).*$/\1/;ta;:a;s/^\[.*\[//;t;p;q;}" \ -ne "/$NAME{/{s/^.*$NAME\({[^}]*}\).*$/\1/;ta;:a;s/^{.*{//;t;p;q;}" \ -ne "s/^.*$NAME\(-\?\(0\|[1-9][[:digit:]]*\)\(\.[[:digit:]]\+\)\?\([eE][-+]\?[[:digit:]]\+\)\?\)$END/\1/p" \ -ne "s/^.*$NAME\(true\|false\|null\)$END/\1/p" \ -ne "s/\\\\\"/\\\\q/g;s/^.*$NAME\"\([^\"]*\)\"$END/\1/p") if [ -z "$STR" ]; then log_error "$FUNCNAME failed (json): \"$1\"" log_notice_stack return $ERR_FATAL fi # Translate two-character sequence escape representations STR=${STR//\\\//\/} STR=${STR//\\\\/\\} STR=${STR//\\q/\"} STR=${STR//\\b/$'\b'} STR=${STR//\\f/$'\f'} STR=${STR//\\n/$'\n'} STR=${STR//\\r/$'\r'} STR=${STR//\\t/ } echo -e "$STR" } # Like parse_json, but hide possible error parse_json_quiet() { parse_json "$@" 2>/dev/null return 0 } # Check if JSON variable is true # # $1: JSON variable name # $2: JSON data # $? is zero on success match_json_true() { grep -q "\"$1\"[[:space:]]*:[[:space:]]*true" <<< "$2" } # Grep "Xxx" HTTP header. Can be: # - Location # - Content-Location # - Content-Type # - Content-Length # # Notes: # - This is using parse_all, so result can be multiline # (rare usage is: curl -I -L ...). # - Use [:cntrl:] instead of \r because Busybox sed <1.19 # does not support it. # # stdin: result of curl request (with -i/--include, -D/--dump-header # or -I/--head flag) # stdout: result grep_http_header_location() { parse_all '^[Ll]ocation:' 'n:[[:space:]]\+\(.*\)[[:cntrl:]]$' } grep_http_header_location_quiet() { parse_all '^[Ll]ocation:' 'n:[[:space:]]\+\(.*\)[[:cntrl:]]$' 2>/dev/null return 0 } grep_http_header_content_location() { parse_all '^[Cc]ontent-[Ll]ocation:' 'n:[[:space:]]\+\(.*\)[[:cntrl:]]$' } grep_http_header_content_type() { parse_all '^[Cc]ontent-[Tt]ype:' 'e:[[:space:]]\+\(.*\)[[:cntrl:]]$' } grep_http_header_content_length() { parse_all '^[Cc]ontent-[Ll]ength:' 'h:[[:space:]]\+\(.*\)[[:cntrl:]]$' } # Grep "Content-Disposition" HTTP header # See RFC5987 and RFC2183. # # stdin: HTTP response headers (see below) # stdout: attachment filename grep_http_header_content_disposition() { parse_all '^[Cc]ontent-[Dd]isposition:' "filename\*\?=[\"']\?\([^\"'[:cntrl:]]*\)" } # Extract a named form from a HTML content. # Notes: # - if several forms (with same name) are available: return all of them # - start marker
    and end marker
    must be on separate lines # - HTML comments are just ignored # # $1: (X)HTML data # $2: (optional) "name" attribute of
    marker. # If not specified: take forms having any "name" attribute (empty or not) # stdout: result grep_form_by_name() { local -r A=${2:-'.*'} local STR=$(sed -ne \ "/<[Ff][Oo][Rr][Mm][[:space:]].*name[[:space:]]*=[[:space:]]*[\"']\?$A[\"']\?[[:space:]/>]/,/<\/[Ff][Oo][Rr][Mm]>/p" <<< "$1") if [ -z "$STR" ]; then log_error "$FUNCNAME failed (sed): \"name=$A\"" return $ERR_FATAL fi echo "$STR" } # Extract a id-specified form from a HTML content. # Notes: # - if several forms (with same name) are available: return all of them # - start marker and end marker
    must be on separate lines # - HTML comments are just ignored # # $1: (X)HTML data # $2: (optional) "id" attribute of
    marker. # If not specified: take forms having any "id" attribute (empty or not) # stdout: result grep_form_by_id() { local -r A=${2:-'.*'} local STR=$(sed -ne \ "/<[Ff][Oo][Rr][Mm][[:space:]].*id[[:space:]]*=[[:space:]]*[\"']\?$A[\"']\?[[:space:]/>]/,/<\/[Ff][Oo][Rr][Mm]>/p" <<< "$1") if [ -z "$STR" ]; then log_error "$FUNCNAME failed (sed): \"id=$A\"" return $ERR_FATAL fi echo "$STR" } # Extract a specific FORM block from a HTML content. # $1: (X)HTML data # $2: (optional) Nth block grep_form_by_order() { grep_block_by_order '[Ff][Oo][Rr][Mm]' "$@" } # Extract a specific SCRIPT block from a HTML content. # $1: (X)HTML data # $2: (optional) Nth