Skip to content

Fix PNG original photo URLs - #2

Open
O0000-code wants to merge 3 commits into
sytelus:mainfrom
O0000-code:fix-author-fields
Open

O0000-code wants to merge 3 commits into
sytelus:mainfrom
O0000-code:fix-author-fields

Conversation

@O0000-code

@O0000-code O0000-code commented Aug 15, 2026 •

Copy link
Copy Markdown

Summary

  • build original-resolution photo URLs from each asset's real extension instead of hardcoding format=jpg
  • add a dependency-free parser regression test for PNG and JPEG photo URLs

The author-field half of this PR is no longer part of the proposed diff. Upstream main fixed the current author name, handle, avatar, and quoted-author paths in ae9d026; this branch is merged with that commit before applying the remaining media-only change.

Problem and reproduction

  1. Parse a photo whose media_url_https ends in .png.
  2. Current main emits <id>.png?format=jpg&name=orig.
  3. pbs.twimg.com rejects the mismatch between the path extension and format, returning 404.

extractMedia() currently appends ?format=jpg&name=orig to every photo URL. The fix removes the extension from the request path and uses it as the format parameter, producing <id>?format=png&name=orig. JPEGs continue to produce format=jpg.

The bug was found while exporting a real bookmark archive: PNG-hosted photos failed to download until the extension was carried into the format parameter.

Validation

Run against upstream main at ae9d026 with Node v25.4.0 (README asks for Node 24):

  • node --test tests/*.test.mjs on ae9d026, before this change: 65 pass / 0 fail.
  • The new focused test on ae9d026, before this change: fails, with the actual URL https://pbs.twimg.com/media/image.png?format=jpg&name=orig.
  • The same test after this change: 1 pass / 0 fail.
  • node --test tests/*.test.mjs after this change: 66 pass / 0 fail.
  • The final diff against main contains only lib/parser.js and tests/parser-media.test.mjs; no author-field change remains.

Bo added 2 commits August 15, 2026 21:55
X moved the author display fields out of `legacy` on `user_results.result`
into sibling objects: `core` holds `name` and `screen_name`, `avatar` holds
`image_url`, `verification` holds `verified`. `legacy` is still there and
still carries `followers_count`.

`extractAuthor` only read `legacy`, so exports came back with a numeric
`user_id` and null name, handle and profile image. Nothing surfaces it: the
export completes, every bookmark is well-formed, and permalinks still work
because `x.com/i/status/<id>` redirects.

Both locations are read, the current one first, so responses predating the
move still parse. Quoted-tweet authors use the same fields and are fixed
alongside.
pbs.twimg.com rejects a path extension that disagrees with `format`, so a PNG
asked for as `<id>.png?format=jpg&name=orig` returns 404. JPEGs happened to
work because the path extension matched the hardcoded `format=jpg`.

Measured on an export of 833 bookmarks: 50 images across 45 tweets, every one
of them a PNG. The download is attempted per file, so the failure surfaces as
a handful of unrelated-looking 404s rather than as anything about PNGs.

Dropping the extension and taking `format` from it fetches all of them.
@O0000-code O0000-code changed the title Read author fields from their new location on the user result Fix author fields and PNG media URLs Aug 15, 2026
@O0000-code O0000-code changed the title Fix author fields and PNG media URLs Fix PNG original photo URLs Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant