{"_id":"4chan-downloader","_rev":"11-e29e73a5d2fec8f648b4e45992590a53","name":"4chan-downloader","description":"Downloads all files in 4chan threads.","dist-tags":{"latest":"0.0.0"},"versions":{"0.0.0":{"name":"4chan-downloader","version":"0.0.0","description":"Downloads all files in 4chan threads.","main":"index.js","files":["cli.js","index.js"],"bin":{"4chan":"./cli.js"},"dependencies":{"chalk":"~0.5.1","cheerio":"~0.17.0","mkdirp":"^0.5.0","request":"^2.39.0","yargs":"^1.3.1"},"keywords":["4chan","download","watch","cli"],"license":"MIT","_id":"4chan-downloader@0.0.0","_shasum":"8ef663d3610914afb9e7e964b290515c9101b655","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"ythis","email":"ythis@outlook.com"},"maintainers":[{"name":"ythis","email":"ythis@outlook.com"}],"dist":{"shasum":"8ef663d3610914afb9e7e964b290515c9101b655","tarball":"https://registry.npmjs.org/4chan-downloader/-/4chan-downloader-0.0.0.tgz","integrity":"sha512-7Yo4pWtsi26sqJGldHkDA04Z8dSPmHj/X7XOet0VSzLlI2h3c/gb/HOY11UORY9XYnbxz2iQpyHv+l9HCnt5iw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDEpLP2RD4xuqSxJuoedNXBtsDT/y2+slavPlvDiHI+sAIgHdvsQGGsI4ccd7XmrWLfLGLiKc+bYVdVAvPx61Zkjcg="}]}}},"readme":"# 4chan-downloader\n\nDownloads all files in 4chan threads.\n\n## Install\n\n```\nnpm install -g 4chan-downloader\n```\n\n## CLI\n\nHelp output:\n\n```\nUsage: 4chan [options] <url> [<dir>]\n\nExamples:\n  4chan <url>                Download all files in a thread into {cwd}.\n  4chan <url> foo            Download all files in a thread into {cwd}/foo.\n  4chan <url> foo/bar        Download all files in a thread into {cwd}/foo/bar.\n  4chan -w <url>             Download all and watch for new files.\n  4chan -w -i 20 <url>       Download all and check for new files every 20 seconds.\n  4chan -f gif,webm <url>    Download all gif and webm files.\n  4chan -s 200x100 <url>     Download all files bigger than 200x100 pixels.\n  4chan -s 100 <url>         Download all files bigger than 100x100 pixels.\n\n\nOptions:\n  -w, --watch     Watch for new files.\n  -i, --interval  Watching interval in seconds.     [default: 10]\n  -f, --filter    Filter specific file types.       [default: \"jpg,gif,png,webm\"]\n  -o, --override  Override existing files.\n  -n, --names     Save with original file names.\n  -s, --size      Smallest files to download.       [default: \"100x100\"]\n  -t, --threads   Limit of simultaneous downloads.  [default: 1]\n  -v, --version   Show version.\n  -h, --help      Show help.\n```\n\n## API\n\n```js\nvar FortuneDownloader = require('4chan-downloader');\nvar thread = new FortuneDownloader('http://boards...')\n\t.threads(4)\n\t.watch()\n\t.downloadTo('foo/bar');\n// ...\nthread.stop();\n```\n\n#### FortuneDownloader(url)\n\nConsturctor. `new` keyword is optional. All methods are chaining.\n\n#### #threads(count)\n\nSet number of downloading threads.\n\n#### #watch([interval])\n\nMake instance watch for new files.\n\n**interval** `Integer` Watching interval in millisecods. Default: `10000`\n\n#### #filter(fun)\n\nCustom function that filters out specific files. Function returns `true` when the file should be downloaded and `false` otherwise.\n\nFunction arguments:\n\n1. **file** `Object` File description object:\n\t```js\n\t{\n\t\turl: 'http://i.4cdn.org/g/1407348528901.jpg',\n\t\tprettysize: '650 KB',\n\t\twidth: 1920,\n\t\theight: 1080,\n\t\tname: 'Original file name.jpg',\n\t\tidname: '1407348528901.jpg',\n\t\ttype: 'jpg',\n\t\tsize: 0, // set when file stars downloading\n\t\tcompleted: 0, // updated during downloading\n\t\tprogress: 0   // updated during downloading\n\t}\n\t```\n\n#### #namer(fun)\n\nCustom function that returns the name to be used when saving files.\n\nFunction arguments:\n\n1. **file** `Object` File description object:\n\t```js\n\t{\n\t\turl: 'http://i.4cdn.org/g/1407348528901.jpg',\n\t\tprettysize: '650 KB',\n\t\twidth: 1920,\n\t\theight: 1080,\n\t\tname: 'Original file name.jpg',\n\t\tidname: '1407348528901.jpg',\n\t\ttype: 'jpg',\n\t\tsize: 0, // set when file stars downloading\n\t\tcompleted: 0, // updated during downloading\n\t\tprogress: 0   // updated during downloading\n\t}\n\t```\n\n#### #override(state)\n\nSet whether instance should override already existing files. Default behavior is `false`.\n\n- **state** `Boolean`\n\n#### #destination(path)\n\nWhere to save files. By default files are saved into current working directory.\n\n- **path** `String`\n\n#### #download()\n\nStarts downloading.\n\n#### #downloadTo(path)\n\nShorthand for:\n\n```js\nFortuneDownloader(url)\n\t.destination('foo/bar')\n\t.download();\n```\n\n#### #stop()\n\nClears current download queue, and cancels watching when in progress.\n\nIt does **not** cancel ongoing download streams.\n\nAfter `#stop()` has been called and ongoing downloads finished, `end` event will be fired. If there were no ongoing downloads, `end` will be fired immediately.\n\n### Properties\n\n#### url\n\nType `String`. Thread URL.\n\n#### queue\n\nType `Array`. Array of files (file descriptor objects) to be downloaded. File is removed from here right before `file:start` event.\n\n#### finished\n\nType `Array`. Array of downloaded file URLs. When watching is active, any subsequent download will filter out files in this array.\n\n#### active\n\nType `Integer`. Number of currently active download threads in progress.\n\n### Events\n\n`FortuneDownloader` instance is an event emitter.\n\n#### parse\n\nTriggered when page has been parsed, and `#queue` array has been populated with files soon to be downloaded.\n\n#### error\n\nTriggered when download canceling error has happened. When this event fires, `end` event won't.\n\nCallback arguments:\n\n1. **error** `Error`\n\n#### end\n\nTriggered when download instance has finished downloading all files, and watching is not enabled.\n\nAlso fires when `#stop()` is called and all ongoing downloads finish.\n\n#### file:start\n\nTriggered when file starts downloading.\n\nCallback arguments:\n\n1. **file** `Object` File descriptor object:\n\t```js\n\t{\n\t\turl: 'http://i.4cdn.org/g/1407348528901.jpg',\n\t\tprettysize: '650 KB',\n\t\twidth: 1920,\n\t\theight: 1080,\n\t\tname: 'Original file name.jpg',\n\t\tidname: '1407348528901.jpg',\n\t\ttype: 'jpg',\n\t\tsize: 665600, // available now\n\t\tcompleted: 0,\n\t\tprogress: 0\n\t}\n\t```\n\n#### file:chunk\n\nTriggered when chunk of a file has been received.\n\nCallback arguments:\n\n1. **chunk** `Buffer`\n2. **file** `Object` File descriptor object:\n\t```js\n\t{\n\t\turl: 'http://i.4cdn.org/g/1407348528901.jpg',\n\t\tprettysize: '650 KB',\n\t\twidth: 1920,\n\t\theight: 1080,\n\t\tname: 'Original file name.jpg',\n\t\tidname: '1407348528901.jpg',\n\t\ttype: 'jpg',\n\t\tsize: 665600,\n\t\tcompleted: 40253, // sum of all chunks till now\n\t\tprogress: 0.06139871873093349603416717510677 // completed / size\n\t}\n\t```\n\n#### file:progress\n\nSame as chunk, but without the **chunk** argument:\n\n1. **file** `Object` File descriptor object:\n\t```js\n\t{\n\t\turl: 'http://i.4cdn.org/g/1407348528901.jpg',\n\t\tprettysize: '650 KB',\n\t\twidth: 1920,\n\t\theight: 1080,\n\t\tname: 'Original file name.jpg',\n\t\tidname: '1407348528901.jpg',\n\t\ttype: 'jpg',\n\t\tsize: 665600,\n\t\tcompleted: 40253, // sum of all chunks till now\n\t\tprogress: 0.06139871873093349603416717510677 // completed / size\n\t}\n\t```\n\n#### file:error\n\nTriggered when file downloading error has happened. These errors don't stop the downloading process.\n\nCallback arguments:\n\n1. **error** `Error`\n2. **file** `Object` File descriptor object.\n\n#### file:end\n\nTriggered when file has finished with downloading.\n\nCallback arguments:\n\n1. **file** `Object` File descriptor object.\n\n## License\n\nMIT","maintainers":[{"name":"ythis","email":"ythis@outlook.com"}],"time":{"modified":"2022-06-12T14:07:45.932Z","created":"2014-08-06T21:23:43.227Z","0.0.0":"2014-08-06T21:23:43.227Z"},"keywords":["4chan","download","watch","cli"],"license":"MIT","readmeFilename":"README.md","users":{"pingjiang":true,"jessman2186":true,"nateollie4":true}}