Skip to content

[import] 404 assets are downloaded #200

@kptdobe

Description

@kptdobe

Using the multi output version of the import, you can reference assets. If an asset is 404, it will still download the asset which will obviously be corrupted.

Input page: https://www.xeljanz.com/psa
Import code:

export default {

  transform: ({
    document, url, html, params,
  }) => {
    const main = document.body;

    let path = WebImporter.FileUtils.sanitizePath(new URL(url).pathname.replace(/\.html$/, '').replace(/\/$/, ''));

    const results = [{
      path,
      element: main,
    }];

    main.querySelectorAll('video').forEach((video) => {
      const source = video.querySelector('source');
      if (source && source.src) {
        const u = new URL(source.src, url);
        const newPath = WebImporter.FileUtils.sanitizePath(u.pathname);
        results.push({
          path: newPath,
          from: u.toString(),
        });
      }
    });

    return results;
  },
};

This will download some mp4 but most of them do not exist. Also the status is not up-to-date.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions