[Reproducer Required] onDownload: Using, and an error

I am really enjoying Kantu and have written a script to download photos from FB.

It works but the file names are annoying, so I wanted to rename the image files to the timestamp the photo was taken.

But… every time I try using onDownload I get the error
[error] until: download start expired!

What happens is the onDownload row runs, and it moves to the next row, where it hangs.

I have tried setting the second parameter to true, false and <<blank>>, but none of them work.

This is:

  • Windows 10
  • Chrome 71
  • Kantu 3.5.5
    • Storage mode: File system (on hard drive)

Here’s the script. To use:

  1. Go to a photo gallery
  2. Open the first photo in the lightbox by clicking on it
  3. Start the macro running
{
  "Name": "FB test with OnDownload",
  "CreationDate": "2018-12-19",
  "Commands": [
    {
      "Command": "storeAttribute",
      "Target": "//*[@id='fbPhotoSnowliftTimestamp']//abbr@data-utime",
      "Value": "myfilename"
    },
    {
      "Command": "onDownload",
      "Target": "${myfilename}.jpg",
      "Value": "true"
    },
    {
      "Command": "click",
      "Target": "//a[@data-action-type=\"open_options_flyout\"]/span",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "//div[@class='uiContextualLayerPositioner uiLayer']//a[@data-action-type='download_photo']/span/span",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "//*[@id=\"photos_snowlift\"]/div[2]/div/div[1]/div[1]/div[1]/a[2]/i",
      "Value": ""
    },
    {
      "Command": "pause",
      "Target": "2400",
      "Value": "2400"
    },
    {
      "Command": "echo",
      "Target": "${myfilename}",
      "Value": ""
    }
  ]
}

Is there a better approach?

Ideally I want to append the timestamp to the existing file name. The alternative idea I’ve had is to log the file name and timestamp to a CSV, and then write another (offline) program to rename the photos.

some questions:

  • if you don’t use onDownload, does it work then?
  • does the download actually start?
  • do you maybe see a dialog like this:

download%20multiple%20files

  • If I don’t use onDownload, it works.
  • Yes, the downloads work (I have downloaded 1000+ images)
  • The first run, yes. And I clicked ‘Allow’.

If you have a FB profile, please run the script to see the error happen.

Is there a bug in onDownload, or does it require specific conditions to work?

… I am not sure yet what is the right answer - we are debugging this currently :wink:

At the moment, we can not recreate the problems described here :sweat:

As a test, if you run the DemoDownload macro that ships with Kantu, does it work for you? In my test, all works ok and the downloaded files get renamed.

@pppppppepe I tried to run it, but the macro fails on the first command already. I guess I need to be at a specific start page for it work?

@admin Here’s a reproducible demo:

  1. Go to https://www.facebook.com/401798653189125/photos/pb.401798653189125.-2207520000.1546629461./1968133486555626/?type=3&theater
  2. Run the macro provided above
  3. The result will be something like

By contrast if you use the macro below, it works but does not rename the image files:

{
  "Name": "FB no x methods",
  "CreationDate": "2019-1-4",
  "Commands": [
    {
      "Command": "storeAttribute",
      "Target": "//*[@id='fbPhotoSnowliftTimestamp']//abbr@data-utime",
      "Value": "myfilename"
    },
    {
      "Command": "click",
      "Target": "//a[@data-action-type=\"open_options_flyout\"]/span",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "//div[@class='uiContextualLayerPositioner uiLayer']//a[@data-action-type='download_photo']/span/span",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "//*[@id=\"photos_snowlift\"]/div[2]/div/div[1]/div[1]/div[1]/a[2]/i",
      "Value": ""
    },
    {
      "Command": "pause",
      "Target": "2400",
      "Value": "2400"
    }
  ]
}

You can set this macro to run 30+ times and it will download 30+ images.

Hi :slight_smile:, I’ve copied and run the code in the example (https://github.com/A9T9/Kantu/blob/master/testmacros/demomacros/DemoDownload.json), but it doesn’t work.

Could you kindly help me please? I’m trying to understard how to rename downloaded files…

Ah, the screenshot explains the issue: It seems the website (Facebook?) is blocking EVAL on its website, just like Github. This problem is not related to OnDownload, but to storeEval.

For a workaround see 'unsafe-eval' is not an allowed source of script

1 Like

Hi to all, I’m trying to use correctly the onDownload feature too. Currently in this way:

{
  "Command": "onDownload",
  "Target": "example.xls",
  "Value": ""
}    

But if I set Chrome settings to automatically download files, Kantu doesn’t rename them.
What I’m doing wrong? Anyone could help me please?

Many thank & best regards,
Chris.

I got the same problem here. This error only shows up for certain website. I tried ulrich’s advise to run all storeEval in another tab, but it doesn’t work. Please help.

Every time I clear the browser history and data, all my data loses and you can simply visit hard drive recovery to get it solved on your system. I have got huge help from it.