Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

4chan

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

4chan - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

53

4chan.js

@@ -21,2 +21,8 @@ var optimist = require('optimist');

.boolean('f')
.alias('t', 'threads')
.describe('t', 'Separate the downloaded pics into directories by forum threads. Requires -f. Ignores -m.')
.boolean('t')
.alias('v', 'move')
.describe('v', 'Special exclusive operation. Run after -f and -t to move all pics from subdirs to the current dir.')
.boolean('v')
.argv;

@@ -43,2 +49,20 @@

if(argv.v)
return movePics(tcb);
function movePics(cb) {
fs.readdirSync('.').forEach(function(d) {
if(/^\./.test(d) || !fs.statSync(d).isDirectory())
return;
fs.readdirSync(d).forEach(function(f) {
fs.renameSync(d + '/' + f, f);
});
fs.rmdirSync(d);
});
}
if(argv._.length != 1) {

@@ -90,2 +114,6 @@ console.log(optimist.help());

}
else if(argv.t && argv.f) {
console.log('Separating pictures based on thread.');
delete argv.m;
}
else if(argv.m) {

@@ -192,3 +220,4 @@ console.log('Separating pictures based on landscape/portrait orientation.');

function getPics(url, cb) {
function getPics(url, thread, cb) {
request(url, _x(cb, true, function(err, res, body) {

@@ -231,3 +260,4 @@

width: m3 ? m3[1] : Number(m2[2]),
height: m3 ? m3[2] : Number(m2[1])
height: m3 ? m3[2] : Number(m2[1]),
thread: thread
};

@@ -262,3 +292,11 @@

function getThread(url, cb) { // cb(err, msg)
getPics(url, _x(cb, true, function(err, ret) {
var thread = /([^\/]+)$/.exec(url)[1];
if(argv.t) {
var threadDir = basedir + '/' + thread;
if(!fs.existsSync(threadDir))
fs.mkdirSync(threadDir);
}
getPics(url, thread, _x(cb, true, function(err, ret) {

@@ -274,3 +312,3 @@ downloadPics(ret, _x(cb, true, function(err) {

getPics(url, _x(cb, true, function(err, ret) {
getPics(url, thread, _x(cb, true, function(err, ret) {
downloadPics(ret, _x(cb, true, function(err) {

@@ -305,3 +343,6 @@ }));

function getFilenameFromEntry(entry) {
if(argv.m) {
if(argv.t) {
return basedir + '/' + entry.thread + '/' + entry.file;
}
else if(argv.m) {
if(entry.width < entry.height)

@@ -333,3 +374,3 @@ return portraitDir + '/' + entry.file;

_.each(ret.order, function(entry) {
var fname = getFilenameFromEntry(entry);

@@ -336,0 +377,0 @@ if(fileExists(fname))

2

package.json

@@ -6,3 +6,3 @@ {

"keywords": [ "4chan", "picture", "downloader", "utility", "command line" ],
"version": "0.0.5",
"version": "0.0.6",
"homepage": "http://github.com/ypocat/4chan",

@@ -9,0 +9,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc