sindresorhus/pageres

Multiple output filenames #370

bendadaniel posted onGitHub

Hello, Is there way to set multiple output filenames in one instance of pageres? I use bash version of pageres cli.

Someting like this:

pageres [ http://google.com --filename='goo' ] [ http://facebook.com --filename='face' ]


It's intended that

pageres [ http://google.com --filename='goo' ] [ http://facebook.com --filename='face' ]

should work for this, but from testing it now, it doesn't.

posted by sindresorhus almost 6 years ago

@issuehunt has funded $40.00 to this issue.


posted by IssueHuntBot almost 6 years ago

I am currently looking into this issue. Bear with me as it's my first contribution to a Node project ✨

Investigation

pageres-cli without setting a filename

Without setting a file name everything seems to work as expected. Separate files get saved as facebook.com-1366x768.png and google.com-1366x768.png.

āžœ  pageres-cli git:(master) āœ— node cli.js [ http://google.com ] [ http://facebook.com ]
http://google.com [ '1366x768' ] {
  verbose: false,
  v: false,
  crop: false,
  c: false,
  overwrite: false,
  delay: 0,
  d: 0,
  scale: 1,
  cookies: undefined,
  headers: undefined
}
http://facebook.com [ '1366x768' ] {
  verbose: false,
  v: false,
  crop: false,
  c: false,
  overwrite: false,
  delay: 0,
  d: 0,
  scale: 1,
  cookies: undefined,
  headers: undefined
}

āœ” Generated 2 screenshots from 2 urls and 1 size

pageres-cli with setting a filename

The problem here is that both URLs will receive the same file name filename: [ 'goo', 'face' ] and it will end up as goo,face.png, which might be a screenshot of Facebook or Google.

āžœ  pageres-cli git:(master) āœ— node cli.js [ http://google.com --filename='goo' ] [ http://facebook.com --filename='face' ]
http://google.com [ '1366x768' ] {
  verbose: false,
  v: false,
  crop: false,
  c: false,
  overwrite: false,
  filename: [ 'goo', 'face' ],
  delay: 0,
  d: 0,
  scale: 1,
  cookies: undefined,
  headers: undefined
}
http://facebook.com [ '1366x768' ] {
  verbose: false,
  v: false,
  crop: false,
  c: false,
  overwrite: false,
  filename: [ 'goo', 'face' ],
  delay: 0,
  d: 0,
  scale: 1,
  cookies: undefined,
  headers: undefined
}

āœ” Generated 2 screenshots from 2 urls and 1 size
posted by femueller over 5 years ago

Anybody working on this or is it okay that I take it?

posted by ghost over 5 years ago

I'm continuing working on this issue together with @lfroment0.

posted by femueller over 5 years ago

Problem is trickier than it seems. This behavior is the result of the way meow handles args and the way the pagers CLI handles multiple screenshot targets through square brackets. Meow handles flags in a standard way: example: Considering meow-cli --arg=1 --arg=2 option arg will be available as [1, 2] on the other side pageres-cli needs this value to be split according to its groups.

There are two solutions to this problem:

  1. change the way pageres-cli handles multiple screenshot url
  2. some small hack to map the occurences of flags to the screenshot groups via their respective indexes, which should be working fine but feels a bit like a hack.

First option is a Major change which might not be welcome, and involves quite some work. Second one seems hacky...

we'll open a pull request for the second option in the coming days for review and feedback.

(cc @femueller)

posted by lfroment0 over 5 years ago

@sindresorhus has rewarded $36.00 to @sushantdhiman. See it on IssueHunt

  • :moneybag: Total deposit: $40.00
  • :tada: Repository reward(0%): $0.00
  • :wrench: Service fee(10%): $4.00
posted by issuehunt-app[bot] over 2 years ago

Fund this Issue

$40.00
Rewarded

Rewarded pull request

Recent activities

sushantdhiman was rewarded by sindresorhus for sindresorhus/pageres# 370
over 2 years ago
sushantdhiman submitted an output to  sindresorhus/ pageres# 370
over 3 years ago