Skip to content

Instagram image enumeration dedupes videos but not images #46

Description

@jamditis

Found while fixing the same class on Facebook (#23, PR #45). Filing rather than widening that PR, since it is a different platform file.

src/platforms/instagram.js builds a usedVideoUrls Set and checks it on every video branch, so a repeated video is emitted once. The image loop just above it has no equivalent:

container.querySelectorAll('img[src*="cdninstagram.com"]').forEach((img) => {
  const url = upgradeImageUrl(img.src, img);
  if (url) {
    items.push({ url, type: 'image', filename: shortcode ? `post_${shortcode}_${index}` : null });
    index++;
  }
});

Whether this actually duplicates depends on how much upgradeImageUrl normalizes. On Facebook the equivalent function strips the size segment from the CDN path, which is what turns two src values for one carousel slide into one identical URL, so the missing dedupe does not merely permit duplicates, it produces them. Someone should check whether upgradeImageUrl collapses Instagram's size variants the same way before assuming this is or is not live. That check is the first task here, not the fix.

If it does duplicate, the symptom matches Facebook's: the _${index} suffix gives each copy a distinct filename, so one photo saved twice reads as a two-photo carousel rather than as a bug.

Worth deciding at the same time whether the dedupe belongs in each platform file or in common.js. Three platforms now walk a container for CDN images and number the results, and the tie-break is not always the same: document order wants the first sighting kept, and a recency-ordered capture list wants the last.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions